@@ -410,7 +410,7 @@ export const handlers: Map<number, OpHandler> = new Map([
410
410
async function ( runState : RunState ) {
411
411
const addressBN = runState . stack . pop ( )
412
412
const address = new Address ( addressToBuffer ( addressBN ) )
413
- accessAddressEIP2929 ( runState , address . buf , runState . _common . param ( 'gasPrices' , 'balance' ) )
413
+ accessAddressEIP2929 ( runState , address , runState . _common . param ( 'gasPrices' , 'balance' ) )
414
414
const balance = await runState . eei . getExternalBalance ( address )
415
415
runState . stack . push ( balance )
416
416
} ,
@@ -509,27 +509,29 @@ export const handlers: Map<number, OpHandler> = new Map([
509
509
[
510
510
0x3b ,
511
511
async function ( runState : RunState ) {
512
- const address = runState . stack . pop ( )
512
+ const addressBN = runState . stack . pop ( )
513
+ const address = new Address ( addressToBuffer ( addressBN ) )
513
514
accessAddressEIP2929 ( runState , address , runState . _common . param ( 'gasPrices' , 'extcodesize' ) )
514
- const size = await runState . eei . getExternalCodeSize ( address )
515
+ const size = await runState . eei . getExternalCodeSize ( addressBN )
515
516
runState . stack . push ( size )
516
517
} ,
517
518
] ,
518
519
// 0x3c: EXTCODECOPY
519
520
[
520
521
0x3c ,
521
522
async function ( runState : RunState ) {
522
- const [ address , memOffset , codeOffset , length ] = runState . stack . popN ( 4 )
523
+ const [ addressBN , memOffset , codeOffset , length ] = runState . stack . popN ( 4 )
523
524
524
525
// FIXME: for some reason this must come before subGas
525
526
subMemUsage ( runState , memOffset , length )
527
+ const address = new Address ( addressToBuffer ( addressBN ) )
526
528
accessAddressEIP2929 ( runState , address , runState . _common . param ( 'gasPrices' , 'extcodecopy' ) )
527
529
// copy fee
528
530
runState . eei . useGas (
529
531
new BN ( runState . _common . param ( 'gasPrices' , 'copy' ) ) . imul ( divCeil ( length , new BN ( 32 ) ) )
530
532
)
531
533
532
- const code = await runState . eei . getExternalCode ( address )
534
+ const code = await runState . eei . getExternalCode ( addressBN )
533
535
534
536
const data = getDataSlice ( code , codeOffset , length )
535
537
const memOffsetNum = memOffset . toNumber ( )
@@ -544,7 +546,7 @@ export const handlers: Map<number, OpHandler> = new Map([
544
546
async function ( runState : RunState ) {
545
547
const addressBN = runState . stack . pop ( )
546
548
const address = new Address ( addressToBuffer ( addressBN ) )
547
- accessAddressEIP2929 ( runState , address . buf , runState . _common . param ( 'gasPrices' , 'extcodehash' ) )
549
+ accessAddressEIP2929 ( runState , address , runState . _common . param ( 'gasPrices' , 'extcodehash' ) )
548
550
const empty = await runState . eei . isAccountEmpty ( address )
549
551
if ( empty ) {
550
552
runState . stack . push ( new BN ( 0 ) )
@@ -986,7 +988,7 @@ export const handlers: Map<number, OpHandler> = new Map([
986
988
}
987
989
subMemUsage ( runState , inOffset , inLength )
988
990
subMemUsage ( runState , outOffset , outLength )
989
- accessAddressEIP2929 ( runState , toAddressBuf , runState . _common . param ( 'gasPrices' , 'call' ) )
991
+ accessAddressEIP2929 ( runState , toAddress , runState . _common . param ( 'gasPrices' , 'call' ) )
990
992
991
993
if ( ! value . isZero ( ) ) {
992
994
runState . eei . useGas ( new BN ( runState . _common . param ( 'gasPrices' , 'callValueTransfer' ) ) )
@@ -1038,7 +1040,7 @@ export const handlers: Map<number, OpHandler> = new Map([
1038
1040
1039
1041
subMemUsage ( runState , inOffset , inLength )
1040
1042
subMemUsage ( runState , outOffset , outLength )
1041
- accessAddressEIP2929 ( runState , toAddressBuf , runState . _common . param ( 'gasPrices' , 'callcode' ) )
1043
+ accessAddressEIP2929 ( runState , toAddress , runState . _common . param ( 'gasPrices' , 'callcode' ) )
1042
1044
1043
1045
if ( ! value . isZero ( ) ) {
1044
1046
runState . eei . useGas ( new BN ( runState . _common . param ( 'gasPrices' , 'callValueTransfer' ) ) )
@@ -1075,11 +1077,7 @@ export const handlers: Map<number, OpHandler> = new Map([
1075
1077
1076
1078
subMemUsage ( runState , inOffset , inLength )
1077
1079
subMemUsage ( runState , outOffset , outLength )
1078
- accessAddressEIP2929 (
1079
- runState ,
1080
- toAddressBuf ,
1081
- runState . _common . param ( 'gasPrices' , 'delegatecall' )
1082
- )
1080
+ accessAddressEIP2929 ( runState , toAddress , runState . _common . param ( 'gasPrices' , 'delegatecall' ) )
1083
1081
1084
1082
gasLimit = maxCallGas ( gasLimit , runState . eei . getGasLeft ( ) , runState )
1085
1083
// note that TangerineWhistle or later this cannot happen (it could have ran out of gas prior to getting here though)
@@ -1108,11 +1106,7 @@ export const handlers: Map<number, OpHandler> = new Map([
1108
1106
1109
1107
subMemUsage ( runState , inOffset , inLength )
1110
1108
subMemUsage ( runState , outOffset , outLength )
1111
- accessAddressEIP2929 (
1112
- runState ,
1113
- toAddressBuf ,
1114
- runState . _common . param ( 'gasPrices' , 'staticcall' )
1115
- )
1109
+ accessAddressEIP2929 ( runState , toAddress , runState . _common . param ( 'gasPrices' , 'staticcall' ) )
1116
1110
gasLimit = maxCallGas ( gasLimit , runState . eei . getGasLeft ( ) , runState ) // we set TangerineWhistle or later to true here, as STATICCALL was available from Byzantium (which is after TangerineWhistle)
1117
1111
1118
1112
let data = Buffer . alloc ( 0 )
@@ -1187,7 +1181,7 @@ export const handlers: Map<number, OpHandler> = new Map([
1187
1181
runState . eei . useGas ( new BN ( runState . _common . param ( 'gasPrices' , 'callNewAccount' ) ) )
1188
1182
}
1189
1183
1190
- accessAddressEIP2929 ( runState , selfdestructToAddress . buf , 0 )
1184
+ accessAddressEIP2929 ( runState , selfdestructToAddress , 0 )
1191
1185
return runState . eei . selfDestruct ( selfdestructToAddress )
1192
1186
} ,
1193
1187
] ,
0 commit comments