diff --git a/chains/ethereum/chain.go b/chains/ethereum/chain.go index 3ec70258a..e718d0aec 100644 --- a/chains/ethereum/chain.go +++ b/chains/ethereum/chain.go @@ -21,6 +21,7 @@ The writer recieves the message and creates a proposals on-chain. Once a proposa package ethereum import ( + "fmt" "math/big" bridge "github.com/ChainSafe/ChainBridge/bindings/Bridge" @@ -111,7 +112,6 @@ func InitializeChain(chainCfg *core.ChainConfig, logger log15.Logger, sysErr cha if err != nil { return nil, err } - err = conn.EnsureHasBytecode(cfg.bridgeContract) if err != nil { return nil, err @@ -130,6 +130,15 @@ func InitializeChain(chainCfg *core.ChainConfig, logger log15.Logger, sysErr cha return nil, err } + chainId, err := bridgeContract.ChainID(conn.CallOpts()) + if err != nil { + return nil, err + } + + if chainId != uint8(chainCfg.Id) { + return nil, fmt.Errorf("chainId (%d) and configuration chainId (%d) do not match", chainId, chainCfg.Id) + } + erc20HandlerContract, err := erc20Handler.NewERC20Handler(cfg.erc20HandlerContract, conn.Client()) if err != nil { return nil, err diff --git a/chains/ethereum/chain_test.go b/chains/ethereum/chain_test.go index cb6e05983..e05c412b4 100644 --- a/chains/ethereum/chain_test.go +++ b/chains/ethereum/chain_test.go @@ -21,7 +21,7 @@ func TestChain_ListenerShutdownOnFailure(t *testing.T) { client := ethtest.NewClient(t, TestEndpoint, AliceKp) contracts := deployTestContracts(t, client, msg.ChainId(1)) cfg := &core.ChainConfig{ - Id: msg.ChainId(0), + Id: msg.ChainId(1), Name: "alice", Endpoint: TestEndpoint, From: keystore.AliceKey,