@@ -460,6 +460,7 @@ type GasCallFuncTestCase struct {
460
460
targetEmpty bool // whether the target account is empty (no balance/code)
461
461
isEIP158 bool // whether EIP-158 rules apply (empty account handling)
462
462
isEIP4762 bool // whether EIP-4762 rules apply (Verkle trees)
463
+ addWitnessGas bool // whether to add witness gas for EIP-4762
463
464
isEIP2929 bool // whether EIP-2929 rules apply (access lists)
464
465
isSystemCall bool // whether this is a system call (bypasses some gas costs)
465
466
memorySize uint64 // memory size for the operation (triggers memory expansion)
@@ -576,6 +577,12 @@ func testGasCallFuncFuncWithCases(t *testing.T, config *params.ChainConfig, gasC
576
577
}
577
578
}
578
579
580
+ // For EIP-4762 (Witnesses gas)
581
+ if tc .addWitnessGas && ! contract .IsSystemCall {
582
+ // Calculated in `touchAddressAndChargeGas` WitnessBranchReadCost + WitnessChunkReadCost = 2100
583
+ expectedMultiGas .SafeIncrement (multigas .ResourceKindStorageAccess , 2100 )
584
+ }
585
+
579
586
// Call the function
580
587
multiGas , _ , err := gasCallFunc (evm , contract , stack , mem , tc .memorySize )
581
588
if err != nil {
@@ -760,7 +767,7 @@ func TestGasCallCode(t *testing.T) {
760
767
}
761
768
762
769
// CALL decorated with makeCallVariantGasCallEIP2929 gas function test
763
- func TestGasCallEIP2929 (t * testing.T ) {
770
+ func TestCallVariantGasCallEIP2929 (t * testing.T ) {
764
771
testCases := []GasCallFuncTestCase {
765
772
{
766
773
name : "Cold access to existing account" ,
@@ -793,3 +800,35 @@ func TestGasCallEIP2929(t *testing.T) {
793
800
gasCallEIP2929 = makeCallVariantGasCallEIP2929 (gasCall , 1 )
794
801
testGasCallFuncFuncWithCases (t , params .TestChainConfig , gasCallEIP2929 , testCases , false )
795
802
}
803
+
804
+ func TestVariantGasEIP4762 (t * testing.T ) {
805
+ testCases := []GasCallFuncTestCase {
806
+ {
807
+ name : "EIP4762 non-system call with witness cost" ,
808
+ transfersValue : false ,
809
+ valueTransferGas : 50000 ,
810
+ targetExists : true ,
811
+ targetEmpty : false ,
812
+ isEIP158 : true ,
813
+ isEIP4762 : true ,
814
+ addWitnessGas : true ,
815
+ isSystemCall : false ,
816
+ memorySize : 64 ,
817
+ },
818
+ {
819
+ name : "EIP4762 system call skips witness cost" ,
820
+ transfersValue : false ,
821
+ valueTransferGas : 50000 ,
822
+ targetExists : true ,
823
+ targetEmpty : false ,
824
+ isEIP158 : true ,
825
+ isEIP4762 : true ,
826
+ addWitnessGas : true ,
827
+ isSystemCall : true ,
828
+ memorySize : 64 ,
829
+ },
830
+ }
831
+
832
+ gasCallEIP4762 = makeCallVariantGasEIP4762 (gasCallCode )
833
+ testGasCallFuncFuncWithCases (t , params .TestChainConfig , gasCallEIP4762 , testCases , true )
834
+ }
0 commit comments