Skip to content

Commit 9ddb8f8

Browse files
Instrument WasmCallCost with multigas
1 parent 53a8281 commit 9ddb8f8

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

core/vm/operations_acl_arbitrum.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ func WasmStateStoreCost(db StateDB, program common.Address, key, value common.Ha
111111
// The code here is adapted from the following functions with the most recent parameters as of The Merge
112112
// - operations_acl.go makeCallVariantGasCallEIP2929()
113113
// - gas_table.go gasCall()
114-
func WasmCallCost(db StateDB, contract common.Address, value *uint256.Int, budget uint64) (uint64, error) {
115-
total := uint64(0)
116-
apply := func(amount uint64) bool {
117-
total += amount
118-
return total > budget
114+
func WasmCallCost(db StateDB, contract common.Address, value *uint256.Int, budget uint64) (multigas.MultiGas, error) {
115+
total := multigas.ZeroGas()
116+
apply := func(resource multigas.ResourceKind, amount uint64) bool {
117+
total.SaturatingIncrementInto(resource, amount)
118+
return total.SingleGas() > budget
119119
}
120120

121121
// EIP 2929: the static cost
122-
if apply(params.WarmStorageReadCostEIP2929) {
122+
if apply(multigas.ResourceKindComputation, params.WarmStorageReadCostEIP2929) {
123123
return total, ErrOutOfGas
124124
}
125125

@@ -129,7 +129,7 @@ func WasmCallCost(db StateDB, contract common.Address, value *uint256.Int, budge
129129
if !warmAccess {
130130
db.AddAddressToAccessList(contract)
131131

132-
if apply(coldCost) {
132+
if apply(multigas.ResourceKindStorageAccess, coldCost) {
133133
return total, ErrOutOfGas
134134
}
135135
}

0 commit comments

Comments
 (0)