Skip to content

Commit b475e58

Browse files
committed
add legacy vm && fix hooks gas usage
1 parent d9f557c commit b475e58

File tree

17 files changed

+55
-33
lines changed

17 files changed

+55
-33
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ require (
348348
)
349349

350350
replace (
351-
github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.3.0-hotfix
351+
github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.3.0-hotfix-3
352352
github.com/CosmWasm/wasmvm => github.com/sei-protocol/sei-wasmvm v1.5.4-sei.0.0.1
353353
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
354354
github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.55-hotfix

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,8 +1360,8 @@ github.com/sei-protocol/sei-tendermint v0.5.5 h1:JBORWwZBMjaeB7ASEgjZu4Tae2hT8Jw
13601360
github.com/sei-protocol/sei-tendermint v0.5.5/go.mod h1:4LSlJdhl3nf3OmohliwRNUFLOB1XWlrmSodrIP7fLh4=
13611361
github.com/sei-protocol/sei-tm-db v0.0.5 h1:3WONKdSXEqdZZeLuWYfK5hP37TJpfaUa13vAyAlvaQY=
13621362
github.com/sei-protocol/sei-tm-db v0.0.5/go.mod h1:Cpa6rGyczgthq7/0pI31jys2Fw0Nfrc+/jKdP1prVqY=
1363-
github.com/sei-protocol/sei-wasmd v0.3.0-hotfix h1:BinSgooby9l8mToGNRTaah1L+6HWmGr+OtzJccxeG/M=
1364-
github.com/sei-protocol/sei-wasmd v0.3.0-hotfix/go.mod h1:KiTBxf0Tw2bektolsGAu+E8LhUOYI/wU5J7j/aj72lw=
1363+
github.com/sei-protocol/sei-wasmd v0.3.0-hotfix-3 h1:KdQApNmUsnCheycOhGTWqrlEyBMVlrGATdJvpL7mATU=
1364+
github.com/sei-protocol/sei-wasmd v0.3.0-hotfix-3/go.mod h1:QFXKoSy8+9RbGcsBiGXw+L5EkYXa/pn/Rtul8Oa/fH8=
13651365
github.com/sei-protocol/sei-wasmvm v1.5.4-sei.0.0.1 h1:OhDRa2VSvc5cjygSY15+ymLlWqsuVJNm3PibTPlR2IE=
13661366
github.com/sei-protocol/sei-wasmvm v1.5.4-sei.0.0.1/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys=
13671367
github.com/sei-protocol/tm-db v0.0.4 h1:7Y4EU62Xzzg6wKAHEotm7SXQR0aPLcGhKHkh3qd0tnk=

precompiles/bank/bank.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,10 @@ func (p PrecompileExecutor) sendNative(ctx sdk.Context, method *abi.Method, args
228228
}
229229

230230
if hooks != nil {
231-
remainingGas := pcommon.GetRemainingGas(ctx, p.evmKeeper)
231+
newCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx))
232+
remainingGas := pcommon.GetRemainingGas(newCtx, p.evmKeeper)
232233
if hooks.OnEnter != nil {
233-
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(ctx, receiverSeiAddr), []byte{}, remainingGas, value)
234+
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(newCtx, receiverSeiAddr), []byte{}, remainingGas, value)
234235
}
235236
defer func() {
236237
if hooks.OnExit != nil {

precompiles/bank/legacy/v552/bank.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,10 @@ func (p Precompile) sendNative(ctx sdk.Context, method *abi.Method, args []inter
244244
}
245245

246246
if hooks != nil {
247-
remainingGas := pcommon.GetRemainingGas(ctx, p.evmKeeper)
247+
newCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx))
248+
remainingGas := pcommon.GetRemainingGas(newCtx, p.evmKeeper)
248249
if hooks.OnEnter != nil {
249-
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(ctx, receiverSeiAddr), []byte{}, remainingGas, value)
250+
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(newCtx, receiverSeiAddr), []byte{}, remainingGas, value)
250251
}
251252
defer func() {
252253
if hooks.OnExit != nil {

precompiles/bank/legacy/v555/bank.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,10 @@ func (p Precompile) sendNative(ctx sdk.Context, method *abi.Method, args []inter
243243
}
244244

245245
if hooks != nil {
246-
remainingGas := pcommon.GetRemainingGas(ctx, p.evmKeeper)
246+
newCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx))
247+
remainingGas := pcommon.GetRemainingGas(newCtx, p.evmKeeper)
247248
if hooks.OnEnter != nil {
248-
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(ctx, receiverSeiAddr), []byte{}, remainingGas, value)
249+
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(newCtx, receiverSeiAddr), []byte{}, remainingGas, value)
249250
}
250251
defer func() {
251252
if hooks.OnExit != nil {

precompiles/bank/legacy/v562/bank.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,10 @@ func (p PrecompileExecutor) sendNative(ctx sdk.Context, method *abi.Method, args
215215
p.accountKeeper.SetAccount(ctx, p.accountKeeper.NewAccountWithAddress(ctx, receiverSeiAddr))
216216
}
217217
if hooks != nil {
218-
remainingGas := pcommon.GetRemainingGas(ctx, p.evmKeeper)
218+
newCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx))
219+
remainingGas := pcommon.GetRemainingGas(newCtx, p.evmKeeper)
219220
if hooks.OnEnter != nil {
220-
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(ctx, receiverSeiAddr), []byte{}, remainingGas, value)
221+
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(newCtx, receiverSeiAddr), []byte{}, remainingGas, value)
221222
}
222223
defer func() {
223224
if hooks.OnExit != nil {

precompiles/bank/legacy/v580/bank.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,10 @@ func (p PrecompileExecutor) sendNative(ctx sdk.Context, method *abi.Method, args
201201
p.accountKeeper.SetAccount(ctx, p.accountKeeper.NewAccountWithAddress(ctx, receiverSeiAddr))
202202
}
203203
if hooks != nil {
204-
remainingGas := pcommon.GetRemainingGas(ctx, p.evmKeeper)
204+
newCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx))
205+
remainingGas := pcommon.GetRemainingGas(newCtx, p.evmKeeper)
205206
if hooks.OnEnter != nil {
206-
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(ctx, receiverSeiAddr), []byte{}, remainingGas, value)
207+
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(newCtx, receiverSeiAddr), []byte{}, remainingGas, value)
207208
}
208209
defer func() {
209210
if hooks.OnExit != nil {

precompiles/bank/legacy/v600/bank.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,10 @@ func (p PrecompileExecutor) sendNative(ctx sdk.Context, method *abi.Method, args
201201
p.accountKeeper.SetAccount(ctx, p.accountKeeper.NewAccountWithAddress(ctx, receiverSeiAddr))
202202
}
203203
if hooks != nil {
204-
remainingGas := pcommon.GetRemainingGas(ctx, p.evmKeeper)
204+
newCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx))
205+
remainingGas := pcommon.GetRemainingGas(newCtx, p.evmKeeper)
205206
if hooks.OnEnter != nil {
206-
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(ctx, receiverSeiAddr), []byte{}, remainingGas, value)
207+
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(newCtx, receiverSeiAddr), []byte{}, remainingGas, value)
207208
}
208209
defer func() {
209210
if hooks.OnExit != nil {

precompiles/bank/legacy/v601/bank.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,10 @@ func (p PrecompileExecutor) sendNative(ctx sdk.Context, method *abi.Method, args
221221
p.accountKeeper.SetAccount(ctx, p.accountKeeper.NewAccountWithAddress(ctx, receiverSeiAddr))
222222
}
223223
if hooks != nil {
224-
remainingGas := pcommon.GetRemainingGas(ctx, p.evmKeeper)
224+
newCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx))
225+
remainingGas := pcommon.GetRemainingGas(newCtx, p.evmKeeper)
225226
if hooks.OnEnter != nil {
226-
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(ctx, receiverSeiAddr), []byte{}, remainingGas, value)
227+
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(newCtx, receiverSeiAddr), []byte{}, remainingGas, value)
227228
}
228229
defer func() {
229230
if hooks.OnExit != nil {

precompiles/bank/legacy/v603/bank.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,10 @@ func (p PrecompileExecutor) sendNative(ctx sdk.Context, method *abi.Method, args
227227
p.accountKeeper.SetAccount(ctx, p.accountKeeper.NewAccountWithAddress(ctx, receiverSeiAddr))
228228
}
229229
if hooks != nil {
230-
remainingGas := pcommon.GetRemainingGas(ctx, p.evmKeeper)
230+
newCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx))
231+
remainingGas := pcommon.GetRemainingGas(newCtx, p.evmKeeper)
231232
if hooks.OnEnter != nil {
232-
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(ctx, receiverSeiAddr), []byte{}, remainingGas, value)
233+
hooks.OnEnter(evm.GetDepth()+1, byte(vm.CALL), caller, p.evmKeeper.GetEVMAddressOrDefault(newCtx, receiverSeiAddr), []byte{}, remainingGas, value)
233234
}
234235
defer func() {
235236
if hooks.OnExit != nil {

0 commit comments

Comments
 (0)