From f656c186157888ea30b596c3ee515d0a3a02e178 Mon Sep 17 00:00:00 2001 From: raulk Date: Mon, 13 Mar 2023 11:25:19 +0000 Subject: [PATCH] Merge pull request #10456 from filecoin-project/raulk/fix-eth-net_version --- itests/eth_api_test.go | 15 +++++++++++++++ node/impl/full/eth.go | 9 ++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/itests/eth_api_test.go b/itests/eth_api_test.go index c24b32416..43b4b5266 100644 --- a/itests/eth_api_test.go +++ b/itests/eth_api_test.go @@ -2,6 +2,7 @@ package itests import ( "context" + "strconv" "testing" "time" @@ -9,6 +10,7 @@ import ( "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types/ethtypes" "github.com/filecoin-project/lotus/chain/wallet/key" @@ -109,3 +111,16 @@ func TestEthGetGenesis(t *testing.T) { require.NoError(t, err) require.Equal(t, ethBlk.Hash, genesisHash) } + +func TestNetVersion(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() + + version, err := client.NetVersion(ctx) + require.NoError(t, err) + require.Equal(t, strconv.Itoa(build.Eip155ChainId), version) +} diff --git a/node/impl/full/eth.go b/node/impl/full/eth.go index 17a43d21e..b5d66bd69 100644 --- a/node/impl/full/eth.go +++ b/node/impl/full/eth.go @@ -755,13 +755,8 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (eth return ret, nil } -func (a *EthModule) NetVersion(ctx context.Context) (string, error) { - // Note that networkId is not encoded in hex - nv, err := a.StateNetworkVersion(ctx, types.EmptyTSK) - if err != nil { - return "", err - } - return strconv.FormatUint(uint64(nv), 10), nil +func (a *EthModule) NetVersion(_ context.Context) (string, error) { + return strconv.FormatInt(build.Eip155ChainId, 10), nil } func (a *EthModule) NetListening(ctx context.Context) (bool, error) {