Skip to content

Commit 68c41f3

Browse files
committed
test
1 parent dfe083b commit 68c41f3

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

evmrpc/simulate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ 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+
bNrOrHash := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
8990
defer func() {
9091
if err := recover(); err != nil {
92+
result = 0
9193
returnErr = fmt.Errorf("%s", err)
9294
}
9395
}()
94-
bNrOrHash := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
9596
if blockNrOrHash != nil {
9697
bNrOrHash = *blockNrOrHash
9798
}

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())

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)