Skip to content

Commit

Permalink
Problem: no header hash from fallback historicalInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Oct 7, 2024
1 parent 580ce6e commit d0aa6db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (rpc) [#516](https://github.com/crypto-org-chain/ethermint/pull/516) Avoid method eth_chainId crashed due to nil pointer on IsEIP155 check.
* (cli) [#524](https://github.com/crypto-org-chain/ethermint/pull/524) Allow tx evm raw run for generate only when offline with evm-denom flag.
* (rpc) [#527](https://github.com/crypto-org-chain/ethermint/pull/527) Fix balance consistency between trace-block and state machine.
* (rpc) [#534](https://github.com/crypto-org-chain/ethermint/pull/534) Fix opBlockhash when no block header in abci request.
* (rpc) [#534](https://github.com/crypto-org-chain/ethermint/pull/534), [#540](https://github.com/crypto-org-chain/ethermint/pull/540) Fix opBlockhash when no block header in abci request.
* (rpc) [#536](https://github.com/crypto-org-chain/ethermint/pull/536) Fix validate basic after transaction conversion with raw field.
* (cli) [#537](https://github.com/crypto-org-chain/ethermint/pull/537) Fix unsuppored sign mode SIGN_MODE_TEXTUAL for bank transfer.

Expand Down
17 changes: 16 additions & 1 deletion x/evm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/evmos/ethermint/x/evm/statedb"
"github.com/evmos/ethermint/x/evm/types"

cmttypes "github.com/cometbft/cometbft/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
ethtypes "github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -109,7 +110,21 @@ func (k Keeper) GetHashFn(ctx sdk.Context) vm.GetHashFunc {
return common.BytesToHash(headerHash)
}
}
return common.BytesToHash(k.GetHeaderHash(ctx, height))
hash := k.GetHeaderHash(ctx, height)
if !bytes.Equal(hash, []byte{}) {
return common.BytesToHash(hash)

Check warning on line 115 in x/evm/keeper/state_transition.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/state_transition.go#L113-L115

Added lines #L113 - L115 were not covered by tests
}
histInfo, err := k.stakingKeeper.GetHistoricalInfo(ctx, h)
if err != nil {
k.Logger(ctx).Debug("historical info not found", "height", h, "err", err.Error())
return common.Hash{}

Check warning on line 120 in x/evm/keeper/state_transition.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/state_transition.go#L117-L120

Added lines #L117 - L120 were not covered by tests
}
header, err := cmttypes.HeaderFromProto(&histInfo.Header)
if err != nil {
k.Logger(ctx).Error("failed to cast tendermint header from proto", "error", err)
return common.Hash{}

Check warning on line 125 in x/evm/keeper/state_transition.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/state_transition.go#L122-L125

Added lines #L122 - L125 were not covered by tests
}
return common.BytesToHash(header.Hash())

Check warning on line 127 in x/evm/keeper/state_transition.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/state_transition.go#L127

Added line #L127 was not covered by tests
}
}

Expand Down

0 comments on commit d0aa6db

Please sign in to comment.