diff --git a/pkg/chains/chain.go b/pkg/chains/chain.go index cc1999a4ca..46ead5f9f2 100644 --- a/pkg/chains/chain.go +++ b/pkg/chains/chain.go @@ -126,18 +126,6 @@ func IsZetaChain(chainID int64, additionalChains []Chain) bool { return ChainIDInChainList(chainID, ChainListByNetwork(Network_zeta, additionalChains)) } -// IsHeaderSupportedChain returns true if the chain's consensus supports block header-based verification -// additionalChains is a list of additional chains to search from -// in practice, it is used in the protocol to dynamically support new chains without doing an upgrade -func IsHeaderSupportedChain(chainID int64, additionalChains []Chain) bool { - return ChainIDInChainList(chainID, ChainListForHeaderSupport(additionalChains)) -} - -// SupportMerkleProof returns true if the chain supports block header-based verification -func (chain Chain) SupportMerkleProof(additionalChains []Chain) bool { - return IsEVMChain(chain.ChainId, additionalChains) || IsBitcoinChain(chain.ChainId, additionalChains) -} - // IsEmpty is to determinate whether the chain is empty func (chain Chain) IsEmpty() bool { return strings.TrimSpace(chain.String()) == "" diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index 44b6abc2c7..f495ba0c85 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -335,49 +335,6 @@ func TestIsEVMChain(t *testing.T) { } } -func TestIsHeaderSupportedChain(t *testing.T) { - tests := []struct { - name string - chainID int64 - want bool - }{ - {"Ethereum Mainnet", chains.Ethereum.ChainId, true}, - {"Goerli Testnet", chains.Goerli.ChainId, true}, - {"Goerli Localnet", chains.GoerliLocalnet.ChainId, true}, - {"Sepolia Testnet", chains.Sepolia.ChainId, true}, - {"BSC Testnet", chains.BscTestnet.ChainId, true}, - {"BSC Mainnet", chains.BscMainnet.ChainId, true}, - {"BTC", chains.BitcoinMainnet.ChainId, true}, - {"Zeta Mainnet", chains.ZetaChainMainnet.ChainId, false}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.want, chains.IsHeaderSupportedChain(tt.chainID, []chains.Chain{})) - }) - } -} - -func TestSupportMerkleProof(t *testing.T) { - tests := []struct { - name string - chain chains.Chain - want bool - }{ - {"Ethereum Mainnet", chains.Ethereum, true}, - {"BSC Testnet", chains.BscTestnet, true}, - {"BSC Mainnet", chains.BscMainnet, true}, - {"Non-EVM", chains.BitcoinMainnet, true}, - {"Zeta Mainnet", chains.ZetaChainMainnet, false}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.want, tt.chain.SupportMerkleProof([]chains.Chain{})) - }) - } -} - func TestIsBitcoinChain(t *testing.T) { tests := []struct { name string diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index c4a4ecc1fb..333aa22001 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -388,13 +388,11 @@ func CombineDefaultChainsList(chains []Chain) []Chain { // CombineChainList combines a list of chains with a list of chains // duplicated chain ID are overwritten by the second list -// TODO: remove pointers -// https://github.com/zeta-chain/node/issues/2080 func CombineChainList(base []Chain, additional []Chain) []Chain { combined := make([]Chain, 0, len(base)+len(additional)) combined = append(combined, base...) - // map chain ID in chains1 to index in the list + // map chain ID in combined to index in the list chainIDIndexMap := make(map[int64]int) for i, chain := range combined { chainIDIndexMap[chain.ChainId] = i diff --git a/x/crosschain/types/message_add_inbound_tracker.go b/x/crosschain/types/message_add_inbound_tracker.go index 40340fa36f..1c4a0691e7 100644 --- a/x/crosschain/types/message_add_inbound_tracker.go +++ b/x/crosschain/types/message_add_inbound_tracker.go @@ -50,7 +50,7 @@ func (msg *MsgAddInboundTracker) ValidateBasic() error { _, ok := coin.CoinType_value[msg.CoinType.String()] if !ok { - return errorsmod.Wrapf(ErrProofVerificationFail, "coin-type not supported") + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "coin-type not supported") } return nil } diff --git a/x/crosschain/types/message_add_inbound_tracker_test.go b/x/crosschain/types/message_add_inbound_tracker_test.go index 8d18e560ec..503c020c1d 100644 --- a/x/crosschain/types/message_add_inbound_tracker_test.go +++ b/x/crosschain/types/message_add_inbound_tracker_test.go @@ -37,7 +37,7 @@ func TestMsgAddInboundTracker_ValidateBasic(t *testing.T) { ChainId: chains.ZetaChainTestnet.ChainId, CoinType: 5, }, - err: errorsmod.Wrapf(types.ErrProofVerificationFail, "coin-type not supported"), + err: errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "coin-type not supported"), }, { name: "valid", diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index c383e23c44..665be3de98 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -55,6 +55,10 @@ func ValidateChainParams(params *ChainParams) error { if params == nil { return fmt.Errorf("chain params cannot be nil") } + + // TODO: ZetaChain chain params should be completely removed + // Once removed, this check is no longer necessary as all chasin params would need the same checks + // https://github.com/zeta-chain/node/issues/2419 _, err := chains.ZetaChainFromChainID(params.ChainId) if err == nil { // zeta chain skips the rest of the checks for now