@@ -24,6 +24,7 @@ function printUsage() {
24
24
console . log ( " GetBlobTxs: get BlobTxs of a block range" ) ;
25
25
console . log ( " GetFaucetStatus: get faucet status of BSC testnet" ) ;
26
26
console . log ( " GetKeyParameters: dump some key governance parameter" ) ;
27
+ console . log ( " GetMevStatus: get mev blocks of a block range" ) ;
27
28
console . log ( "\nOptions:" ) ;
28
29
console . log ( " --rpc specify the url of RPC endpoint" ) ;
29
30
console . log ( " --startNum the start block number" ) ;
@@ -43,6 +44,7 @@ function printUsage() {
43
44
console . log ( " node getchainstatus.js GetFaucetStatus --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000010" )
44
45
console . log ( " node getchainstatus.js GetKeyParameters --rpc https://bsc-testnet-dataseed.bnbchain.org" ) // default: latest block
45
46
console . log ( " node getchainstatus.js GetEip7623 --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000010" )
47
+ console . log ( " node getchainstatus.js GetMevStatus --rpc https://bsc-testnet-dataseed.bnbchain.org --startNum 40000001 --endNum 40000010" )
46
48
}
47
49
48
50
program . usage = printUsage ;
@@ -162,7 +164,38 @@ const validatorMap = new Map([
162
164
[ "0xfA4d592F9B152f7a10B5DE9bE24C27a74BCE431A" , "MyTWFMM" ]
163
165
] ) ;
164
166
165
-
167
+ const builderMap = new Map ( [
168
+ // BSC mainnet
169
+ // blockrazor
170
+ [ "0x5532CdB3c0c4278f9848fc4560b495b70bA67455" , "blockrazor dublin" ] ,
171
+ [ "0xBA4233f6e478DB76698b0A5000972Af0196b7bE1" , "blockrazor frankfurt" ] ,
172
+ [ "0x539E24781f616F0d912B60813aB75B7b80b75C53" , "blockrazor nyc" ] ,
173
+ [ "0x49D91b1Ab0CC6A1591c2e5863E602d7159d36149" , "blockrazor relay" ] ,
174
+ [ "0x50061047B9c7150f0Dc105f79588D1B07D2be250" , "blockrazor tokyo" ] ,
175
+ [ "0x0557E8CB169F90F6eF421a54e29d7dd0629Ca597" , "blockrazor virginia" ] ,
176
+ [ "0x488e37fcB2024A5B2F4342c7dE636f0825dE6448" , "blockrazor x" ] ,
177
+ // puissant
178
+ [ "0x48a5Ed9abC1a8FBe86ceC4900483f43a7f2dBB48" , "puissant ap" ] ,
179
+ [ "0x487e5Dfe70119C1b320B8219B190a6fa95a5BB48" , "puissant eu" ] ,
180
+ [ "0x48FeE1BB3823D72fdF80671ebaD5646Ae397BB48" , "puissant us" ] ,
181
+ [ "0x48B4bBEbF0655557A461e91B8905b85864B8BB48" , "puissant x" ] ,
182
+ [ "0x4827b423D03a349b7519Dda537e9A28d31ecBB48" , "puissant y" ] ,
183
+ [ "0x48B2665E5E9a343409199D70F7495c8aB660BB48" , "puissant:z" ] ,
184
+ // blockroute
185
+ [ "0xD4376FdC9b49d90e6526dAa929f2766a33BFFD52" , "blockroute dublin" ] ,
186
+ [ "0x2873fc7aD9122933BECB384f5856f0E87918388d" , "blockroute frankfurt" ] ,
187
+ [ "0x432101856a330aafdeB049dD5fA03a756B3f1c66" , "blockroute japan" ] ,
188
+ [ "0x2B217a4158933AAdE6D6494e3791D454B4D13AE7" , "blockroute nyc" ] ,
189
+ [ "0x0da52E9673529b6E06F444FbBED2904A37f66415" , "blockroute relay" ] ,
190
+ [ "0xE1ec1AeCE7953ecB4539749B9AA2eEF63354860a" , "blockroute singapore" ] ,
191
+ [ "0x89434FC3a09e583F2cb4e47A8B8fe58De8BE6a15" , "blockroute virginia" ] ,
192
+ [ "0x10353562E662E333C0c2007400284e0e21cF74fF" , "blockroute x" ] ,
193
+ // txboost
194
+ [ "0x6Dddf681C908705472D09B1D7036B2241B50e5c7" , "puissant ap" ] ,
195
+ [ "0x76736159984AE865a9b9Cc0Df61484A49dA68191" , "puissant eu" ] ,
196
+ [ "0x5054b21D8baea3d602dca8761B235ee10bc0231E" , "puissant us" ] ,
197
+ // Chapel
198
+ ] ) ;
166
199
167
200
// 1.cmd: "GetMaxTxCountInBlockRange", usage:
168
201
// node getchainstatus.js GetMaxTxCountInBlockRange --rpc https://bsc-testnet-dataseed.bnbchain.org \
@@ -550,6 +583,71 @@ async function getEip7623() {
550
583
console . log ( `Script executed in: ${ duration } seconds` ) ;
551
584
}
552
585
586
+ // 10.cmd: "getMevStatus", usage:
587
+ // node getchainstatus.js GetMeVStatus \
588
+ // --rpc https://bsc-testnet-dataseed.bnbchain.org \
589
+ // --startNum 40000001 --endNum 40000005
590
+ async function getMevStatus ( ) {
591
+ let localCount = 0
592
+ let blockrazorCount = 0
593
+ let puissantCount = 0
594
+ let blockrouteCount = 0
595
+ let txboostCount = 0
596
+ var startBlock = parseInt ( program . startNum )
597
+ var endBlock = parseInt ( program . endNum )
598
+ if ( isNaN ( endBlock ) || isNaN ( startBlock ) || startBlock == 0 ) {
599
+ console . error ( "invalid input, --startNum" , program . startNum , "--end" , program . endNum )
600
+ return
601
+ }
602
+ // if --endNum is not specified, set it to the latest block number.
603
+ if ( endBlock == 0 ) {
604
+ endBlock = await provider . getBlockNumber ( ) ;
605
+ }
606
+ if ( startBlock > endBlock ) {
607
+ console . error ( "invalid input, startBlock:" , startBlock , " endBlock:" , endBlock ) ;
608
+ return
609
+ }
610
+
611
+ for ( let i = startBlock ; i <= endBlock ; i ++ ) {
612
+ let blockData = await provider . getBlock ( i ) ;
613
+ let miner = validatorMap . get ( blockData . miner )
614
+ const payBidTxReverseIdxMax = 3
615
+ let mevBlock = false
616
+ for ( let idx = 0 ; idx <= payBidTxReverseIdxMax && blockData . transactions . length - 1 - idx >= 0 ; idx ++ ) {
617
+ var txIndex = blockData . transactions . length - 1 - idx
618
+ let txHash = blockData . transactions [ txIndex ]
619
+ let txData = await provider . getTransaction ( txHash ) ;
620
+ if ( builderMap . has ( txData . to ) ) {
621
+ let builder = builderMap . get ( txData . to )
622
+ if ( builder . search ( "blockrazor" ) != - 1 ) {
623
+ blockrazorCount ++
624
+ } else if ( builder . search ( "puissant" ) != - 1 ) {
625
+ puissantCount ++
626
+ } else if ( builder . search ( "blockroute" ) != - 1 ) {
627
+ blockrouteCount ++
628
+ } else if ( builder . search ( "txboost" ) != - 1 ) {
629
+ txboostCount ++
630
+ }
631
+ mevBlock = true
632
+ console . log ( "blockNum:" , i , " miner:" , miner , " builder:(" + builderMap . get ( txData . to ) + ")" , txData . to ) ;
633
+ break
634
+ }
635
+ }
636
+ if ( ! mevBlock ) {
637
+ localCount ++
638
+ console . log ( "blockNum:" , i , " miner:" , miner , " builder:local" ) ;
639
+ }
640
+ }
641
+ console . log ( "Get Mev Status between [" , program . startNum , "," , program . endNum , "]" ) ;
642
+ let total = program . endNum - program . startNum + 1
643
+ console . log ( "total =" , total )
644
+ console . log ( "local =" , localCount , " ratio =" , ( localCount / total ) . toFixed ( 2 ) )
645
+ console . log ( "blockrazor =" , blockrazorCount , " ratio =" , ( blockrazorCount / total ) . toFixed ( 2 ) )
646
+ console . log ( "puissant =" , puissantCount , " ratio =" , ( puissantCount / total ) . toFixed ( 2 ) )
647
+ console . log ( "blockroute =" , blockrouteCount , " ratio =" , ( blockrouteCount / total ) . toFixed ( 2 ) )
648
+ console . log ( "txboost =" , txboostCount , " ratio =" , ( txboostCount / total ) . toFixed ( 2 ) )
649
+ } ;
650
+
553
651
const main = async ( ) => {
554
652
if ( process . argv . length <= 2 ) {
555
653
console . error ( 'invalid process.argv.length' , process . argv . length ) ;
@@ -579,6 +677,8 @@ const main = async () => {
579
677
await getKeyParameters ( )
580
678
} else if ( cmd === "GetEip7623" ) {
581
679
await getEip7623 ( )
680
+ } else if ( cmd === "GetMevStatus" ) {
681
+ await getMevStatus ( )
582
682
} else {
583
683
console . log ( "unsupported cmd" , cmd ) ;
584
684
printUsage ( )
0 commit comments