@@ -29,16 +29,17 @@ function printUsage() {
2929 console . log ( " GetLargeTxs: get large txs of a block range" ) ;
3030 console . log ( "\nOptions:" ) ;
3131 console . log ( " --rpc specify the url of RPC endpoint" ) ;
32+ console . log ( " mainnet: https://bsc-mainnet.nodereal.io/v1/454e504917db4f82b756bd0cf6317dce" ) ;
33+ console . log ( " testnet: https://bsc-testnet-dataseed.bnbchain.org" ) ;
3234 console . log ( " --startNum the start block number" ) ;
3335 console . log ( " --endNum the end block number" ) ;
3436 console . log ( " --miner the miner address" ) ;
3537 console . log ( " --num the number of blocks to be checked" ) ;
3638 console . log ( " --topNum the topNum of blocks to be checked" ) ;
3739 console . log ( " --blockNum the block number to be checked" ) ;
3840 console . log ( "\nExample:" ) ;
39- // mainnet https://bsc-mainnet.nodereal.io/v1/454e504917db4f82b756bd0cf6317dce
4041 console . log ( " node getchainstatus.js GetMaxTxCountInBlockRange --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000005" ) ;
41- console . log ( " node getchainstatus.js GetBinaryVersion --rpc https://bsc-testnet-dataseed.bnbchain.org --num 21 --turnLength 4 " ) ;
42+ console . log ( " node getchainstatus.js GetBinaryVersion --rpc https://bsc-testnet-dataseed.bnbchain.org --num 21 --turnLength 8 " ) ;
4243 console . log ( " node getchainstatus.js GetTopAddr --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000010 --topNum 10" ) ;
4344 console . log ( " node getchainstatus.js GetSlashCount --rpc https://bsc-testnet-dataseed.bnbchain.org --blockNum 40000001" ) ; // default: latest block
4445 console . log ( " node getchainstatus.js GetPerformanceData --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000010" ) ;
@@ -59,6 +60,7 @@ const addrValidatorSet = "0x0000000000000000000000000000000000001000";
5960const addrSlash = "0x0000000000000000000000000000000000001001" ;
6061const addrStakeHub = "0x0000000000000000000000000000000000002002" ;
6162const addrGovernor = "0x0000000000000000000000000000000000002004" ;
63+ const TimelockContract = "0x0000000000000000000000000000000000002006" ;
6264
6365const validatorSetAbi = [
6466 "function validatorExtraSet(uint256 offset) external view returns (uint256, bool, bytes)" ,
@@ -92,17 +94,25 @@ const stakeHubAbi = [
9294 "function felonySlashAmount() public view returns (uint256)" , // default 200BNB, valid: > max(100, downtimeSlashAmount)
9395 "function downtimeJailTime() public view returns (uint256)" , // default 2days,
9496 "function felonyJailTime() public view returns (uint256)" , // default 30days,
95- ] ;
97+ "function getValidators(uint256, uint256) external view returns(address[], address[], uint256)" ,
98+ "function getNodeIDs(address[] validatorsToQuery) external view returns(address[], bytes32[][])" ,
99+ ] ;
100+
96101
97102const governorAbi = [
98103 "function votingPeriod() public view returns (uint256)" ,
99104 "function lateQuorumVoteExtension() public view returns (uint64)" , // it represents minPeriodAfterQuorum
100105] ;
101106
107+ const timelockAbi = [
108+ "function getMinDelay() public view returns (uint256)" ,
109+ ] ;
110+
102111const validatorSet = new ethers . Contract ( addrValidatorSet , validatorSetAbi , provider ) ;
103112const slashIndicator = new ethers . Contract ( addrSlash , slashAbi , provider ) ;
104113const stakeHub = new ethers . Contract ( addrStakeHub , stakeHubAbi , provider ) ;
105114const governor = new ethers . Contract ( addrGovernor , governorAbi , provider ) ;
115+ const timelock = new ethers . Contract ( TimelockContract , timelockAbi , provider ) ;
106116
107117const validatorMap = new Map ( [
108118 // BSC mainnet
@@ -279,7 +289,7 @@ async function getMaxTxCountInBlockRange() {
279289// node getchainstatus.js GetBinaryVersion \
280290// --rpc https://bsc-testnet-dataseed.bnbchain.org \
281291// --num(optional): default 21, the number of blocks that will be checked
282- // --turnLength(optional): default 4 , the consecutive block length
292+ // --turnLength(optional): default 8 , the consecutive block length
283293async function getBinaryVersion ( ) {
284294 const blockNum = await provider . getBlockNumber ( ) ;
285295 let turnLength = program . turnLength ;
@@ -408,7 +418,7 @@ async function getPerformanceData() {
408418 let gasUsedTotal = 0 ;
409419 let inturnBlocks = 0 ;
410420 let justifiedBlocks = 0 ;
411- let turnLength = 4 ;
421+ let turnLength = 8 ;
412422 let lastTimestamp = null ;
413423 let parliaEnabled = true ;
414424
@@ -621,21 +631,40 @@ async function getKeyParameters() {
621631 let validatorTable = [ ] ;
622632 for ( let i = 0 ; i < totalLength ; i ++ ) {
623633 validatorTable . push ( {
624- addr : consensusAddrs [ i ] ,
634+ consensusAddr : consensusAddrs [ i ] ,
625635 votingPower : Number ( votingPowers [ i ] / BigInt ( 10 ** 18 ) ) ,
626636 voteAddr : voteAddrs [ i ] ,
627637 moniker : await getValidatorMoniker ( consensusAddrs [ i ] , blockNum ) ,
628638 } ) ;
629639 }
630640 validatorTable . sort ( ( a , b ) => b . votingPower - a . votingPower ) ;
631641 console . table ( validatorTable ) ;
642+ // get EVN node ids
643+ let validators = await stakeHub . getValidators ( 0 , 1000 , { blockTag : blockNum } ) ;
644+ let operatorAddrs = validators [ 0 ] ;
645+ let nodeIdss = await stakeHub . getNodeIDs ( Array . from ( operatorAddrs ) , { blockTag : blockNum } ) ;
646+ let consensusAddrs2 = nodeIdss [ 0 ] ;
647+ let nodeIdArr = nodeIdss [ 1 ] ;
648+ for ( let i = 0 ; i < consensusAddrs2 . length ; i ++ ) {
649+ let addr = consensusAddrs2 [ i ] ;
650+ let nodeId = nodeIdArr [ i ] ;
651+ if ( nodeId . length > 0 ) {
652+ console . log ( "consensusAddr:" , addr , "nodeId:" , nodeId ) ;
653+ }
654+ }
655+
632656
633657 // part 4: governance
634658 let votingPeriod = await governor . votingPeriod ( { blockTag : blockNum } ) ;
635659 let minPeriodAfterQuorum = await governor . lateQuorumVoteExtension ( { blockTag : blockNum } ) ;
636660 console . log ( "\n##==== GovernorContract: 0x0000000000000000000000000000000000002004" )
637661 console . log ( "\tvotingPeriod" , Number ( votingPeriod ) ) ;
638662 console . log ( "\tminPeriodAfterQuorum" , Number ( minPeriodAfterQuorum ) ) ;
663+
664+ // part 5: timelock
665+ let minDelay = await timelock . getMinDelay ( { blockTag : blockNum } ) ;
666+ console . log ( "\n##==== TimelockContract: 0x0000000000000000000000000000000000002006" )
667+ console . log ( "\tminDelay" , Number ( minDelay ) ) ;
639668}
640669
641670// 9.cmd: "getEip7623", usage:
0 commit comments