Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

develop to beta #1615

Merged
merged 12 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions agent/bls.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1717,9 +1717,11 @@ async function doSignProcessHandleCall(
}

async function doSignProcessOneImpl( i, optsSignOperation ) {
const imaState = state.get();
const isThisNode = ( i == imaState.nNodeNumber ) ? true : false;
const joNode = optsSignOperation.jarrNodes[i];
const strNodeURL = optsSignOperation.imaState.isCrossImaBlsMode
? imaUtils.composeImaAgentNodeUrl( joNode )
? imaUtils.composeImaAgentNodeUrl( joNode, isThisNode )
: imaUtils.composeSChainNodeUrl( joNode );
const strNodeDescColorized = cc.u( strNodeURL ) + " " +
cc.debug( "(" ) + cc.bright( i ) + cc.debug( "/" ) +
Expand Down Expand Up @@ -2010,10 +2012,13 @@ async function prepareSignU256( optsSignU256 ) {
return true;
}

async function doSignU256OneImpl( optsSignU256 ) {
async function doSignU256OneImpl( i, optsSignU256 ) {
const imaState = state.get();
const isThisNode = ( i == imaState.nNodeNumber ) ? true : false;
const joNode = optsSignU256.jarrNodes[i];
const strNodeURL = optsSignU256.imaState.isCrossImaBlsMode
? imaUtils.composeImaAgentNodeUrl( joNode ) : imaUtils.composeSChainNodeUrl( joNode );
? imaUtils.composeImaAgentNodeUrl( joNode, isThisNode )
: imaUtils.composeSChainNodeUrl( joNode );
const strNodeDescColorized = cc.u( strNodeURL ) + " " + cc.debug( "(" ) + cc.bright( i ) +
cc.debug( "/" ) + cc.bright( optsSignU256.jarrNodes.length ) +
cc.debug( ", ID " ) + cc.info( joNode.nodeID ) + cc.debug( ")" );
Expand Down Expand Up @@ -2429,7 +2434,7 @@ export async function doSignU256( u256, details, fn ) {
if( ! ( await prepareSignU256( optsSignU256 ) ) )
return;
for( let i = 0; i < optsSignU256.jarrNodes.length; ++i )
await doSignU256OneImpl( optsSignU256 );
await doSignU256OneImpl( i, optsSignU256 );
await doSignU256Gathering( optsSignU256 );
if( log.verboseGet() >= log.verboseReversed().trace )
optsSignU256.details.write( cc.debug( "Will await BLS u256 sign result..." ) + "\n" );
Expand Down
14 changes: 9 additions & 5 deletions agent/loop.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -746,10 +746,8 @@ export async function ensureHaveWorkers( opts ) {
"strPathHashG1": opts.imaState.strPathHashG1,
"strPathBlsVerify": opts.imaState.strPathBlsVerify,
"isEnabledMultiCall": opts.imaState.isEnabledMultiCall,

"bNoWaitSChainStarted": opts.imaState.bNoWaitSChainStarted,
"nMaxWaitSChainAttempts": opts.imaState.nMaxWaitSChainAttempts,

"nTransferBlockSizeM2S": opts.imaState.nTransferBlockSizeM2S,
"nTransferBlockSizeS2M": opts.imaState.nTransferBlockSizeS2M,
"nTransferBlockSizeS2S": opts.imaState.nTransferBlockSizeS2S,
Expand All @@ -768,7 +766,6 @@ export async function ensureHaveWorkers( opts ) {
"nBlockAgeS2S": opts.imaState.nBlockAgeS2S,

"nLoopPeriodSeconds": opts.imaState.nLoopPeriodSeconds,

"nNodeNumber": opts.imaState.nNodeNumber,
"nNodesCount": opts.imaState.nNodesCount,
"nTimeFrameSeconds": opts.imaState.nTimeFrameSeconds,
Expand All @@ -781,7 +778,6 @@ export async function ensureHaveWorkers( opts ) {
"joDepositBoxERC1155": null,
"joDepositBoxERC721WithMetadata": null,
"joLinker": null,

"isWithMetadata721": false,

"joTokenManagerETH": null,
Expand Down Expand Up @@ -841,7 +837,6 @@ export async function ensureHaveWorkers( opts ) {
while( ! aClient.logicalInitComplete ) {
if( log.verboseGet() >= log.verboseReversed().info )
log.write( "LOOP server is not inited yet...\n" );

await threadInfo.sleep( 1000 );
aClient.send( jo );
}
Expand All @@ -863,6 +858,15 @@ export async function ensureHaveWorkers( opts ) {
if( threadInfo.isMainThread() )
notifyCacheChangedSNB( eventData.detail.arrSChainsCached );
} );
// Force broadcast what we have in SNB right now because works above can start later than SNB
// is finished download connected chains quickly
if( log.verboseGet() >= log.verboseReversed().debug ) {
log.write(
cc.debug( "Loop module will do first initial broadcast of arrSChainsCached to its " ) +
cc.info( cntWorkers ) + cc.debug( " worker(s) in " ) +
threadInfo.threadDescription() + cc.debug( "..." ) + "\n" );
}
notifyCacheChangedSNB( skaleObserver.getLastCachedSChains() );
}

export async function runParallelLoops( opts ) {
Expand Down
4 changes: 2 additions & 2 deletions agent/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ function parseCommandLine() {
cc.info( imaState.nAutoExitAfterSeconds ) +
cc.warning( " second(s) is requested." ) + "\n" );
}
const iv = setInterval( function() {
const iv = owaspUtils.setInterval2( function() {
if( log.verboseGet() >= log.verboseReversed().warning ) {
log.write( cc.warning( "Performing automatic exit after " ) +
cc.info( imaState.nAutoExitAfterSeconds ) + cc.warning( " second(s)..." ) +
"\n" );
}
clearInterval( iv );
owaspUtils.clearInterval2( iv );
process.exit( 0 );
}, imaState.nAutoExitAfterSeconds * 1000 );
} else
Expand Down
5 changes: 3 additions & 2 deletions agent/pwa.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,11 @@ async function notifyOnLoopImpl( imaState, strLoopWorkType, nIndexS2S, isStart )
nIndexS2S, isStart, nUtcUnixTimeStamp, signature
); // save own started
for( let i = 0; i < jarrNodes.length; ++i ) {
if( i == imaState.nNodeNumber )
const isThisNode = ( i == imaState.nNodeNumber ) ? true : false;
if( isThisNode )
continue; // skip this node
const joNode = jarrNodes[i];
const strNodeURL = imaUtils.composeImaAgentNodeUrl( joNode );
const strNodeURL = imaUtils.composeImaAgentNodeUrl( joNode, isThisNode );
const rpcCallOpts = null;
rpcCall.create( // NOTICE: no await here, executed async
strNodeURL, rpcCallOpts, async function( joCall, err ) {
Expand Down
3 changes: 2 additions & 1 deletion agent/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ BASE_OPTIONS="--gas-price-multiplier=$GAS_PRICE_MULTIPLIER \
--time-gap=$TIME_GAP \
--monitoring-port=$MONITORING_PORT \
--pwa \
--no-expose-pwa"
--no-expose-pwa \
--auto-exit=86400"

echo "Running loop cmd..."
node "$DIR/main.mjs" --loop $BASE_OPTIONS
8 changes: 5 additions & 3 deletions agent/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ export function composeSChainNodeUrl( joNode ) {
return "";
}

export function composeImaAgentNodeUrl( joNode ) {
export function composeImaAgentNodeUrl( joNode, isThisNode ) {
let nPort = -1;
if( "imaAgentRpcPort" in joNode &&
typeof joNode.imaAgentRpcPort === "number" &&
Expand Down Expand Up @@ -542,7 +542,9 @@ export function composeImaAgentNodeUrl( joNode ) {
joNode.wssRpcPort > 0
)
nPort = joNode.wssRpcPort - 7 + 10;
if( nPort > 0 )
return "http://" + joNode.ip + ":" + nPort;
if( nPort > 0 ) {
const strNodeIP = isThisNode ? "127.0.0.1" : joNode.ip;
return "http://" + strNodeIP + ":" + nPort;
}
return "";
}
5 changes: 4 additions & 1 deletion test/agent-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,10 @@ describe( "Agent Utils Module-1", function() {
// as result, 14999 + 7 = 15006
assert.equal(
imaUtils.composeImaAgentNodeUrl(
{ ip: "127.0.0.1", httpRpcPort: 14999 } ), "http://127.0.0.1:15006" );
{ ip: "127.0.0.1", httpRpcPort: 14999 }, true ), "http://127.0.0.1:15006" );
assert.equal(
imaUtils.composeImaAgentNodeUrl(
{ ip: "127.0.0.1", httpRpcPort: 14999 }, false ), "http://127.0.0.1:15006" );
} );

} );
Expand Down