@@ -667,6 +667,11 @@ func TestColdAccountAccessCost(t *testing.T) {
667
667
Execute (tc .code , nil , & Config {
668
668
EVMConfig : vm.Config {
669
669
Tracer : & tracing.Hooks {
670
+ OnGasChange : func (old , new uint64 , reason tracing.GasChangeReason ) {
671
+ if step - 1 == tc .step && reason == tracing .GasChangeCallOpCodeDynamic {
672
+ have += old - new
673
+ }
674
+ },
670
675
OnOpcode : func (pc uint64 , op byte , gas , cost uint64 , scope tracing.OpContext , rData []byte , depth int , err error ) {
671
676
// Uncomment to investigate failures:
672
677
//t.Logf("%d: %v %d", step, vm.OpCode(op).String(), cost)
@@ -700,10 +705,15 @@ func TestRuntimeJSTracer(t *testing.T) {
700
705
this.exits++;
701
706
this.gasUsed = res.getGasUsed();
702
707
}}` ,
703
- `{enters: 0, exits: 0, enterGas: 0, gasUsed: 0, steps:0,
708
+ `{enters: 0, exits: 0, enterGas: 0, gasUsed: 0, steps:0, dynamicGas:0,
704
709
fault: function() {},
705
710
result: function() {
706
- return [this.enters, this.exits,this.enterGas,this.gasUsed, this.steps].join(",")
711
+ return [this.enters, this.exits,this.enterGas,this.gasUsed, this.steps, this.dynamicGas].join(",")
712
+ },
713
+ gas: function(change) {
714
+ if (change.getReason() == "CallOpCodeDynamic") {
715
+ this.dynamicGas += change.getOld() - change.getNew();
716
+ }
707
717
},
708
718
enter: function(frame) {
709
719
this.enters++;
@@ -726,7 +736,7 @@ func TestRuntimeJSTracer(t *testing.T) {
726
736
Push (0 ). // value
727
737
Op (vm .CREATE ).
728
738
Op (vm .POP ).Bytes (),
729
- results : []string {`"1,1,952853,6,12"` , `"1,1,952853,6,0"` },
739
+ results : []string {`"1,1,952853,6,12"` , `"1,1,952853,6,0,5 "` },
730
740
},
731
741
{ // CREATE2
732
742
code : program .New ().MstoreSmall (initcode , 0 ).
@@ -736,27 +746,27 @@ func TestRuntimeJSTracer(t *testing.T) {
736
746
Push (0 ). // value
737
747
Op (vm .CREATE2 ).
738
748
Op (vm .POP ).Bytes (),
739
- results : []string {`"1,1,952844,6,13"` , `"1,1,952844,6,0"` },
749
+ results : []string {`"1,1,952844,6,13"` , `"1,1,952844,6,0,11 "` },
740
750
},
741
751
{ // CALL
742
752
code : program .New ().Call (nil , 0xbb , 0 , 0 , 0 , 0 , 0 ).Op (vm .POP ).Bytes (),
743
- results : []string {`"1,1,981796,6,13"` , `"1,1,981796,6,0"` },
753
+ results : []string {`"1,1,981796,6,13"` , `"1,1,981796,6,0,984296 "` },
744
754
},
745
755
{ // CALLCODE
746
756
code : program .New ().CallCode (nil , 0xcc , 0 , 0 , 0 , 0 , 0 ).Op (vm .POP ).Bytes (),
747
- results : []string {`"1,1,981796,6,13"` , `"1,1,981796,6,0"` },
757
+ results : []string {`"1,1,981796,6,13"` , `"1,1,981796,6,0,984296 "` },
748
758
},
749
759
{ // STATICCALL
750
760
code : program .New ().StaticCall (nil , 0xdd , 0 , 0 , 0 , 0 ).Op (vm .POP ).Bytes (),
751
- results : []string {`"1,1,981799,6,12"` , `"1,1,981799,6,0"` },
761
+ results : []string {`"1,1,981799,6,12"` , `"1,1,981799,6,0,984299 "` },
752
762
},
753
763
{ // DELEGATECALL
754
764
code : program .New ().DelegateCall (nil , 0xee , 0 , 0 , 0 , 0 ).Op (vm .POP ).Bytes (),
755
- results : []string {`"1,1,981799,6,12"` , `"1,1,981799,6,0"` },
765
+ results : []string {`"1,1,981799,6,12"` , `"1,1,981799,6,0,984299 "` },
756
766
},
757
767
{ // CALL self-destructing contract
758
768
code : program .New ().Call (nil , 0xff , 0 , 0 , 0 , 0 , 0 ).Op (vm .POP ).Bytes (),
759
- results : []string {`"2,2,0,5003,12"` , `"2,2,0,5003,0"` },
769
+ results : []string {`"2,2,0,5003,12"` , `"2,2,0,5003,0,984296 "` },
760
770
},
761
771
}
762
772
calleeCode := []byte {
@@ -921,6 +931,11 @@ func TestDelegatedAccountAccessCost(t *testing.T) {
921
931
State : statedb ,
922
932
EVMConfig : vm.Config {
923
933
Tracer : & tracing.Hooks {
934
+ OnGasChange : func (old , new uint64 , reason tracing.GasChangeReason ) {
935
+ if step - 1 == tc .step && reason == tracing .GasChangeCallOpCodeDynamic {
936
+ have += old - new
937
+ }
938
+ },
924
939
OnOpcode : func (pc uint64 , op byte , gas , cost uint64 , scope tracing.OpContext , rData []byte , depth int , err error ) {
925
940
// Uncomment to investigate failures:
926
941
t .Logf ("%d: %v %d" , step , vm .OpCode (op ).String (), cost )
0 commit comments