Skip to content

Commit

Permalink
Merge PR :fix failed to get block height via the keywrod block.number (
Browse files Browse the repository at this point in the history
  • Loading branch information
KamiD authored May 22, 2021
1 parent 3efe19f commit df1f078
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/rpc/namespaces/eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ func NewAPI(
gasPrice: ParseGasPrice(),
wrappedBackend: watcher.NewQuerier(),
watcherBackend: watcher.NewWatcher(),
evmFactory: simulation.EvmFactory{ChainId: clientCtx.ChainID},
}
api.evmFactory = simulation.NewEvmFactory(clientCtx.ChainID, api.wrappedBackend)

if err := api.GetKeyringInfo(); err != nil {
api.logger.Error("failed to get keybase info", "error", err)
Expand Down
10 changes: 8 additions & 2 deletions app/rpc/namespaces/eth/simulation/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import (
)

type EvmFactory struct {
ChainId string
ChainId string
WrappedQuerier *watcher.Querier
}

func NewEvmFactory(chainId string, q *watcher.Querier) EvmFactory {
return EvmFactory{ChainId: chainId, WrappedQuerier: q}
}

func (ef EvmFactory) BuildSimulator(qoc QueryOnChainProxy) *EvmSimulator {
Expand Down Expand Up @@ -67,6 +72,7 @@ func (ef EvmFactory) makeContext(k *evm.Keeper) sdk.Context {
cms.MountStoreWithDB(paramsTKey, sdk.StoreTypeTransient, db)

cms.LoadLatestVersion()
ctx := sdk.NewContext(cms, abci.Header{ChainID: ef.ChainId}, true, tmlog.NewNopLogger()).WithGasMeter(sdk.NewGasMeter(evmtypes.DefaultMaxGasLimitPerTx))
latest, _ := ef.WrappedQuerier.GetLatestBlockNumber()
ctx := sdk.NewContext(cms, abci.Header{ChainID: ef.ChainId, Height: int64(latest)}, true, tmlog.NewNopLogger()).WithGasMeter(sdk.NewGasMeter(evmtypes.DefaultMaxGasLimitPerTx))
return ctx
}

0 comments on commit df1f078

Please sign in to comment.