Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

fix: set correct nonce in EthCall/EstimateGas #871

Merged
merged 3 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (evm) [tharsis#838](https://github.com/tharsis/ethermint/pull/838) Fix splitting of trace.Memory into 32 chunks.
* (rpc) [tharsis#860](https://github.com/tharsis/ethermint/pull/860) Fix `eth_getLogs` when specify blockHash without address/topics, and limit the response size.
* (rpc) [tharsis#865](https://github.com/tharsis/ethermint/pull/865) Fix RPC Filter parameters being ignored
* (evm) [tharsis#]() Set correct nonce in `EthCall` and `EstimateGas` grpc query.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing link 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

yihuang marked this conversation as resolved.
Show resolved Hide resolved

## [v0.9.0] - 2021-12-01

Expand Down
8 changes: 8 additions & 0 deletions x/evm/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ func (k Keeper) EthCall(c context.Context, req *types.EthCallRequest) (*types.Ms
return nil, status.Error(codes.Internal, err.Error())
}

// ApplyMessageWithConfig expect correct nonce set in msg
nonce := k.GetNonce(args.GetFrom())
args.Nonce = (*hexutil.Uint64)(&nonce)

msg, err := args.ToMessage(req.GasCap, cfg.BaseFee)
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
Expand Down Expand Up @@ -290,6 +294,10 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type
return nil, status.Error(codes.Internal, "failed to load evm config")
}

// ApplyMessageWithConfig expect correct nonce set in msg
nonce := k.GetNonce(args.GetFrom())
args.Nonce = (*hexutil.Uint64)(&nonce)

// Create a helper to check if a gas allowance results in an executable transaction
executable := func(gas uint64) (vmerror bool, rsp *types.MsgEthereumTxResponse, err error) {
args.Gas = (*hexutil.Uint64)(&gas)
Expand Down