Skip to content

Commit 64b8020

Browse files
committed
test
1 parent dfe083b commit 64b8020

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

evmrpc/simulate.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ func (s *SimulationAPI) CreateAccessList(ctx context.Context, args ethapi.Transa
8686
func (s *SimulationAPI) EstimateGas(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, overrides *ethapi.StateOverride) (result hexutil.Uint64, returnErr error) {
8787
startTime := time.Now()
8888
defer recordMetricsWithError("eth_estimateGas", s.connectionType, startTime, returnErr)
89-
defer func() {
90-
if err := recover(); err != nil {
91-
returnErr = fmt.Errorf("%s", err)
92-
}
93-
}()
9489
bNrOrHash := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
9590
if blockNrOrHash != nil {
9691
bNrOrHash = *blockNrOrHash

precompiles/bank/bank.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ type CoinBalance struct {
5959
Denom string
6060
}
6161

62+
func GetABI() abi.ABI {
63+
return pcommon.MustGetABI(f, "abi.json")
64+
}
65+
6266
func NewPrecompile(bankKeeper pcommon.BankKeeper, bankMsgServer pcommon.BankMsgServer, evmKeeper pcommon.EVMKeeper, accountKeeper pcommon.AccountKeeper) (*pcommon.DynamicGasPrecompile, error) {
63-
newAbi := pcommon.MustGetABI(f, "abi.json")
67+
newAbi := GetABI()
6468
p := &PrecompileExecutor{
6569
bankKeeper: bankKeeper,
6670
bankMsgServer: bankMsgServer,

precompiles/common/precompiles.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ type Contexter interface {
2424
Ctx() sdk.Context
2525
}
2626

27+
type StateEVMKeeperGetter interface {
28+
EVMKeeper() state.EVMKeeper
29+
}
30+
2731
type PrecompileExecutor interface {
2832
RequiredGas([]byte, *abi.Method) uint64
2933
Execute(ctx sdk.Context, method *abi.Method, caller common.Address, callingContract common.Address, args []interface{}, value *big.Int, readOnly bool, evm *vm.EVM) ([]byte, error)
@@ -160,8 +164,8 @@ func (d DynamicGasPrecompile) RunAndCalculateGas(evm *vm.EVM, caller common.Addr
160164
if err != nil {
161165
return nil, 0, err
162166
}
163-
ctx = ctx.WithGasMeter(sdk.NewGasMeterWithMultiplier(ctx, d.executor.EVMKeeper().GetCosmosGasLimitFromEVMGas(ctx, suppliedGas)))
164-
167+
gasLimit := d.executor.EVMKeeper().GetCosmosGasLimitFromEVMGas(ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx)), suppliedGas)
168+
ctx = ctx.WithGasMeter(sdk.NewGasMeterWithMultiplier(ctx, gasLimit))
165169
operation = method.Name
166170
em := ctx.EventManager()
167171
ctx = ctx.WithEventManager(sdk.NewEventManager())

precompiles/pointer/pointer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestAddNative(t *testing.T) {
5757
evm = vm.NewEVM(*blockCtx, vm.TxContext{}, statedb, cfg, vm.Config{})
5858
ret, g, err := p.RunAndCalculateGas(evm, caller, caller, append(p.GetExecutor().(*pointer.PrecompileExecutor).AddNativePointerID, args...), suppliedGas, nil, nil, false, false)
5959
require.Nil(t, err)
60-
require.Equal(t, uint64(8881534), g)
60+
require.Equal(t, uint64(8890698), g)
6161
outputs, err := m.Outputs.Unpack(ret)
6262
require.Nil(t, err)
6363
addr := outputs[0].(common.Address)

x/evm/keeper/evm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (k *Keeper) getEvmGasLimitFromCtx(ctx sdk.Context) uint64 {
189189
if ctx.GasMeter().Limit() <= 0 {
190190
return math.MaxUint64
191191
}
192-
evmGasBig := sdk.NewDecFromInt(sdk.NewIntFromUint64(seiGasRemaining)).Quo(k.GetPriorityNormalizer(ctx)).TruncateInt().BigInt()
192+
evmGasBig := sdk.NewDecFromInt(sdk.NewIntFromUint64(seiGasRemaining)).Quo(k.GetPriorityNormalizer(ctx.WithGasMeter(sdk.NewInfiniteGasMeterWithMultiplier(ctx)))).TruncateInt().BigInt()
193193
if evmGasBig.Cmp(MaxUint64BigInt) > 0 {
194194
evmGasBig = MaxUint64BigInt
195195
}

x/evm/state/statedb.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ func (s *DBImpl) WithCtx(ctx sdk.Context) {
208208
s.ctx = ctx
209209
}
210210

211+
func (s *DBImpl) EVMKeeper() EVMKeeper {
212+
return s.k
213+
}
214+
211215
// in-memory state that's generated by a specific
212216
// EVM snapshot in a single transaction
213217
type TemporaryState struct {

0 commit comments

Comments
 (0)