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

Ticket 1312/new ptx out of skaled #1313

Open
wants to merge 49 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f9adb82
JS-only IMA agent, early alpha version
sergiy-skalelabs Sep 26, 2022
c29d273
Merge remote-tracking branch 'origin/develop' into ticket-1248/js-onl…
sergiy-skalelabs Sep 27, 2022
da46552
transient commit, working on JS only IMA agent
sergiy-skalelabs Sep 27, 2022
8c8e25f
transient commit, working on JS only IMA agent
sergiy-skalelabs Sep 28, 2022
180e240
transient commit, working on JS only IMA agent
sergiy-skalelabs Sep 30, 2022
6c616cf
transient commit, working on JS only IMA agent
sergiy-skalelabs Sep 30, 2022
50fa39b
transient commit, working on JS only IMA agent
sergiy-skalelabs Oct 3, 2022
b8f512f
JS only IMA agent, first working version
sergiy-skalelabs Oct 3, 2022
2ca1046
transient commit, working on JS only IMA agent
sergiy-skalelabs Oct 3, 2022
319bbc3
Added IMA message verfication into skale_imaVerifyAndSign handler
sergiy-skalelabs Oct 11, 2022
33dec68
Added IMA message verfication into skale_imaVerifyAndSign handler
sergiy-skalelabs Oct 11, 2022
a65fc4c
Added IMA message verfication into skale_imaVerifyAndSign handler
sergiy-skalelabs Oct 11, 2022
c3ad648
unit test fix
sergiy-skalelabs Oct 11, 2022
fb3bae7
runtime fix
sergiy-skalelabs Oct 11, 2022
43516f8
runtime fix
sergiy-skalelabs Oct 11, 2022
430f313
unit test fix
sergiy-skalelabs Oct 11, 2022
e55d703
better web socket handling
sergiy-skalelabs Oct 12, 2022
5235749
Force disconnect from SGX when no longer needed
sergiy-skalelabs Oct 13, 2022
610506f
disconnectable RPC calls
sergiy-skalelabs Oct 13, 2022
2c20771
disconnectable RPC calls
sergiy-skalelabs Oct 13, 2022
68ffddb
code cleanup
sergiy-skalelabs Oct 13, 2022
3ffb155
basic Oracle U256 signing implementation
sergiy-skalelabs Oct 13, 2022
7b13e59
code cleanup
sergiy-skalelabs Oct 13, 2022
a6e064b
improved Oracle U256 signing implementation
sergiy-skalelabs Oct 13, 2022
5dbfe9c
Detached PTX(pendint transaction analysis)
sergiy-skalelabs Oct 26, 2022
2b1a53d
lint
sergiy-skalelabs Oct 26, 2022
d5adfa3
loop state tracking refactored
sergiy-skalelabs Oct 26, 2022
46edcf9
various small fixes
sergiy-skalelabs Oct 27, 2022
2dfe82b
logging improvements
sergiy-skalelabs Oct 27, 2022
0ddfc10
logging improvements
sergiy-skalelabs Oct 27, 2022
1f93e8c
PTX replaced with PWA, first basic version
sergiy-skalelabs Oct 28, 2022
1c9e380
Agent JSON RPC fix
sergiy-skalelabs Oct 28, 2022
828f068
PWA fix
sergiy-skalelabs Oct 28, 2022
f939ad9
various runtime fixes
sergiy-skalelabs Oct 29, 2022
cfbfbc2
IMA Agent JSON RPC improvements and fixes
sergiy-skalelabs Oct 29, 2022
828963c
PWA tracking fix
sergiy-skalelabs Oct 29, 2022
2b4fbf2
PWA tracking fix
sergiy-skalelabs Oct 29, 2022
4c68e97
PWA state messages are partially BLS signed
sergiy-skalelabs Oct 30, 2022
9da35b9
PWA state messages are BLS signed and verified
sergiy-skalelabs Oct 30, 2022
4e2d92d
dox rm redundant linhas
sergiy-skalelabs Nov 1, 2022
5e92a5e
agent test runtime fix
sergiy-skalelabs Nov 1, 2022
288e1ac
agent test runtime fix
sergiy-skalelabs Nov 1, 2022
c8948ae
Merge remote-tracking branch 'origin/develop' into ticket-1312/new-PT…
sergiy-skalelabs Nov 21, 2022
7e99c47
safier and error-loged PoW
sergiy-skalelabs Nov 21, 2022
bd22f72
opit raw RPC logging
sergiy-skalelabs Nov 21, 2022
31ca097
Fixed occasional double IMA message verifications for S2S transfers
sergiy-skalelabs Nov 21, 2022
d0bc069
SGX error handler fix
sergiy-skalelabs Nov 22, 2022
fb9cf5c
SGX error handler fix
sergiy-skalelabs Nov 23, 2022
141dc93
Merge branch 'develop' into ticket-1312/new-PTX-out-of-skaled
sergiy-skalelabs Nov 23, 2022
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
2 changes: 0 additions & 2 deletions agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,6 @@ node ./main.js --verbose=9 --expose --colors \
--nodes-count=value.............S-Chain nodes count.
--time-framing=value............Specifies period(in seconds) for time framing. Zero means disable time framing.
--time-gap=value................Specifies gap(in seconds) before next time frame.
--ptx...........................Enable pending transaction analysis to avoid transaction conflicts.
--no-ptx........................Disable pending transaction analysis. Not recommended for slow and overloaded blockchains.
```

### S-Chain specific configuration for more then one node S-Chains
Expand Down
787 changes: 687 additions & 100 deletions agent/bls.js

Large diffs are not rendered by default.

145 changes: 99 additions & 46 deletions agent/cli.js

Large diffs are not rendered by default.

317 changes: 275 additions & 42 deletions agent/main.js

Large diffs are not rendered by default.

61 changes: 39 additions & 22 deletions agent/oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

const numberToBN = require( "number-to-bn" );
const { keccak256 } = require( "js-sha3" );
const { cc } = require( "./utils" );

const MIN_POW_RESULT = 10000;
const MAX_POW_NUMBER = 100000;
Expand Down Expand Up @@ -90,9 +91,10 @@ function oracle_get_gas_price( oracleOpts, details ) {
cntAttempts = 1;
rpcCall.create( url, callOpts || { }, async function( joCall, err ) {
if( err ) {
details.write( cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " RPC connection problem for url " ) + cc.u( url ) + cc.error( ", error description: " ) + cc.warning( err.toString() ) + "\n" );
details.write( err.stack + "\n" );
reject( new Error( "CRITICAL ORACLE CALL ERROR: RPC connection problem for url \"" + url + "\", error description: " + err.toString() ) );
details.write( cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " RPC connection problem for url " ) + cc.u( url ) + cc.error( ", error description: " ) + cc.warning( owaspUtils.extract_error_message( err ) ) + "\n" );
if( joCall )
await joCall.disconnect();
reject( new Error( "CRITICAL ORACLE CALL ERROR: RPC connection problem for url \"" + url + "\", error description: " + owaspUtils.extract_error_message( err ) ) );
return;
}
try {
Expand All @@ -109,18 +111,21 @@ function oracle_get_gas_price( oracleOpts, details ) {
details.write( cc.debug( "RPC call" ) + cc.normal( "(" ) + cc.attention( "oracle_submitRequest" ) + cc.normal( ")" ) + cc.debug( " is " ) + cc.j( joIn ) + "\n" );
await joCall.call( joIn, async function( joIn, joOut, err ) {
if( err ) {
if( isVerboseTraceDetails ) {
details.write( cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " JSON RPC call" ) + cc.debug( "(" ) + cc.attention( "oracle_submitRequest" ) + cc.normal( ")" ) + cc.error( " failed, error: " ) + cc.warning( err.toString() ) + "\n" );
details.write( err.stack + "\n" );
}
reject( new Error( "CRITICAL ORACLE CALL ERROR: JSON RPC call(oracle_submitRequest) failed, error: " + err.toString() ) );
if( isVerboseTraceDetails )
details.write( cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " JSON RPC call" ) + cc.debug( "(" ) + cc.attention( "oracle_submitRequest" ) + cc.normal( ")" ) + cc.error( " failed, error: " ) + cc.warning( owaspUtils.extract_error_message( err ) ) + "\n" );
await joCall.disconnect();
reject( new Error( "CRITICAL ORACLE CALL ERROR: JSON RPC call(oracle_submitRequest) failed, error: " + owaspUtils.extract_error_message( err ) ) );
return;
}
if( isVerboseTraceDetails )
details.write( cc.debug( "RPC call" ) + cc.normal( "(" ) + cc.attention( "oracle_submitRequest" ) + cc.normal( ")" ) + cc.debug( " result is: " ) + cc.j( joOut ) + "\n" );
if( !( "result" in joOut && typeof joOut.result == "string" && joOut.result.length > 0 ) ) {
details.write( cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " bad unexpecected result" ) + cc.normal( "(" ) + cc.attention( "oracle_submitRequest" ) + cc.normal( ")" ) + "\n" );
details.write( err.stack + "\n" );
details.write(
cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " bad unexpecected result" ) +
cc.normal( "(" ) + cc.attention( "oracle_submitRequest" ) + cc.normal( ")" ) +
+ cc.error( ", error description is" ) + waspUtils.extract_error_message( err ) +
"\n" );
await joCall.disconnect();
reject( new Error( "CRITICAL ORACLE CALL ERROR: bad unexpecected result(oracle_submitRequest)" ) );
return;
}
Expand All @@ -140,19 +145,24 @@ function oracle_get_gas_price( oracleOpts, details ) {
await joCall.call( joIn, async function( joIn, joOut, err ) {
if( err ) {
if( isVerboseTraceDetails ) {
details.write( cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " JSON RPC call" ) + cc.debug( "(" ) + cc.attention( "oracle_checkResult" ) + cc.normal( ")" ) + cc.error( " failed, error: " ) + cc.warning( err.toString() ) + "\n" );
details.write( err.stack + "\n" );
details.write(
cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " JSON RPC call" ) +
cc.debug( "(" ) + cc.attention( "oracle_checkResult" ) + cc.normal( ")" ) +
cc.error( " failed, error: " ) + cc.warning( owaspUtils.extract_error_message( err ) ) + "\n" );
}
//reject( new Error( "CRITICAL ORACLE CALL ERROR: JSON RPC call(oracle_checkResult) failed, error: " + err.toString() ) );
await joCall.disconnect();
//reject( new Error( "CRITICAL ORACLE CALL ERROR: JSON RPC call(oracle_checkResult) failed, error: " + owaspUtils.extract_error_message( err ) ) );
return;
}
if( isVerboseTraceDetails )
details.write( cc.debug( "RPC call" ) + cc.normal( "(" ) + cc.attention( "oracle_checkResult" ) + cc.normal( ")" ) + cc.debug( " result is: " ) + cc.j( joOut ) + "\n" );
if( !( "result" in joOut && typeof joOut.result == "string" && joOut.result.length > 0 ) ) {
if( isVerboseTraceDetails ) {
details.write( cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " bad unexpecected result" ) + cc.normal( "(" ) + cc.attention( "oracle_checkResult" ) + cc.normal( ")" ) + "\n" );
details.write( err.stack + "\n" );
details.write(
cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " bad unexpecected result" ) +
cc.normal( "(" ) + cc.attention( "oracle_checkResult" ) + cc.normal( ")" ) + "\n" );
}
await joCall.disconnect();
// reject( new Error( "CRITICAL ORACLE CALL ERROR: bad unexpecected result(oracle_checkResult)" ) );
return;
}
Expand All @@ -163,29 +173,36 @@ function oracle_get_gas_price( oracleOpts, details ) {
if( isVerbose )
details.write( cc.success( "success, computed " ) + cc.sunny( "Gas Price" ) + cc.success( "=" ) + cc.info( gp.toString() ) + cc.success( "=" ) + cc.info( "0x" + gp.toString( 16 ) ) + "\n" );
resolve( gp );
await joCall.disconnect();
return;
} );
} catch ( err ) {
details.write( cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " RPC call" ) + cc.normal( "(" ) + cc.attention( "oracle_checkResult" ) + cc.normal( ")" ) + cc.error( " exception is: " ) + cc.warning( err.toString() ) + "\n" );
details.write( err.stack + "\n" );
details.write(
cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " RPC call" ) +
cc.normal( "(" ) + cc.attention( "oracle_checkResult" ) + cc.normal( ")" ) +
cc.error( " exception is: " ) + cc.warning( owaspUtils.extract_error_message( err ) ) + "\n" );
reject( err );
await joCall.disconnect();
return;
}
} // for( let idxAttempt = 0; idxAttempt < cntAttempts; ++idxAttempt )
details.write( cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " RPC call" ) + cc.normal( "(" ) + cc.attention( "oracle_checkResult" ) + cc.normal( ")" ) + cc.error( " all attempts timed out" ) + "\n" );
reject( new Error( "RPC call(oracle_checkResult) all attempts timed out" ) );
await joCall.disconnect();
return;
} );
} catch ( err ) {
details.write( cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " RPC call" ) + cc.normal( "(" ) + cc.attention( "oracle_submitRequest" ) + cc.normal( ")" ) + cc.error( " exception is: " ) + cc.warning( err.toString() ) + "\n" );
details.write( err.stack + "\n" );
details.write(
cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " RPC call" ) + cc.normal( "(" ) + cc.attention( "oracle_submitRequest" ) + cc.normal( ")" ) +
cc.error( " exception is: " ) + cc.warning( owaspUtils.extract_error_message( err ) ) + "\n" );
reject( err );
return;
}
await joCall.disconnect();
} );
} catch ( err ) {
details.write( cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " RPC call object creation failed, error is: " ) + cc.warning( err.toString() ) + "\n" );
details.write( err.stack + "\n" );
details.write(
cc.fatal( "CRITICAL ORACLE CALL ERROR:" ) + cc.error( " RPC call object creation failed, error is: " ) +
cc.warning( owaspUtils.extract_error_message( err ) ) + "\n" );
reject( err );
return;
}
Expand Down
3 changes: 3 additions & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"ethereumjs-util": "^7.1.4",
"web3": "^1.6.1",
"uuid": "8.3.2",
"express": "^4.18.2",
"body-parser": "^1.20.1",
"jayson": "^4.0.0",
"ws": "^8.6.0",
"urllib": "2.38.0",
"sha3": "2.1.4",
Expand Down
Loading