Skip to content

Commit

Permalink
Merge pull request #10389 from filecoin-project/asr/fix-eth-api-genesis
Browse files Browse the repository at this point in the history
fix: EthAPI: Correctly get parent hash
  • Loading branch information
arajasek authored Mar 6, 2023
2 parents 6c0a2fe + 920fdfd commit 12496e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
22 changes: 22 additions & 0 deletions itests/eth_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,25 @@ func TestFilecoinAddressToEthAddress(t *testing.T) {

require.ErrorContains(t, err, ethtypes.ErrInvalidAddress.Error())
}

func TestEthGetGenesis(t *testing.T) {
blockTime := 100 * time.Millisecond
client, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.ThroughRPC())
ens.InterconnectAll().BeginMining(blockTime)

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

ethBlk, err := client.EVM().EthGetBlockByNumber(ctx, "0x0", true)
require.NoError(t, err)

genesis, err := client.ChainGetGenesis(ctx)
require.NoError(t, err)

genesisCid, err := genesis.Key().Cid()
require.NoError(t, err)

genesisHash, err := ethtypes.EthHashFromCid(genesisCid)
require.NoError(t, err)
require.Equal(t, ethBlk.Hash, genesisHash)
}
6 changes: 1 addition & 5 deletions node/impl/full/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1763,11 +1763,7 @@ func (e *ethSubscription) stop() {
}

func newEthBlockFromFilecoinTipSet(ctx context.Context, ts *types.TipSet, fullTxInfo bool, cs *store.ChainStore, sa StateAPI) (ethtypes.EthBlock, error) {
parent, err := cs.LoadTipSet(ctx, ts.Parents())
if err != nil {
return ethtypes.EthBlock{}, err
}
parentKeyCid, err := parent.Key().Cid()
parentKeyCid, err := ts.Parents().Cid()
if err != nil {
return ethtypes.EthBlock{}, err
}
Expand Down

0 comments on commit 12496e5

Please sign in to comment.