From 6d58c0711a3caa299f84d824a1786ae13597c241 Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Mon, 23 Jan 2023 23:59:30 +0530 Subject: [PATCH] Revert "feat(evm)!: confirm general message destinate to cosmos chains (#1863)" (#1875) This reverts commit c06075c14d543fdb767bcd726b07d81b307928a9. --- docs/proto/proto-docs.md | 37 -- .../axelar/nexus/exported/v1beta1/types.proto | 20 - .../proto/google/protobuf/descriptor.proto | 24 - x/axelarnet/exported/params.go | 6 +- x/evm/abci.go | 119 +--- x/evm/abci_test.go | 72 +- x/evm/types/expected_keepers.go | 1 - x/evm/types/mock/expected_keepers.go | 50 -- x/evm/types/types.go | 22 +- x/nexus/exported/types.go | 48 -- x/nexus/exported/types.pb.go | 623 ++---------------- x/nexus/keeper/general_message.go | 73 -- x/nexus/keeper/general_message_test.go | 115 ---- x/nexus/keeper/keeper.go | 1 - x/nexus/keeper/keeper_test.go | 30 +- x/nexus/keeper/transfer_test.go | 1 - 16 files changed, 119 insertions(+), 1123 deletions(-) delete mode 100644 x/nexus/keeper/general_message.go delete mode 100644 x/nexus/keeper/general_message_test.go diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 1b3489128..aa8e1e114 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -48,10 +48,8 @@ - [CrossChainAddress](#axelar.nexus.exported.v1beta1.CrossChainAddress) - [CrossChainTransfer](#axelar.nexus.exported.v1beta1.CrossChainTransfer) - [FeeInfo](#axelar.nexus.exported.v1beta1.FeeInfo) - - [GeneralMessage](#axelar.nexus.exported.v1beta1.GeneralMessage) - [TransferFee](#axelar.nexus.exported.v1beta1.TransferFee) - - [GeneralMessage.Status](#axelar.nexus.exported.v1beta1.GeneralMessage.Status) - [TransferDirection](#axelar.nexus.exported.v1beta1.TransferDirection) - [TransferState](#axelar.nexus.exported.v1beta1.TransferState) @@ -1115,28 +1113,6 @@ registered blockchain - - -### GeneralMessage - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `id` | [string](#string) | | | -| `source_chain` | [string](#string) | | | -| `sender` | [string](#string) | | | -| `destination_chain` | [string](#string) | | | -| `receiver` | [string](#string) | | | -| `payload_hash` | [bytes](#bytes) | | | -| `status` | [GeneralMessage.Status](#axelar.nexus.exported.v1beta1.GeneralMessage.Status) | | | -| `asset` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | - - - - - - ### TransferFee @@ -1154,19 +1130,6 @@ TransferFee represents accumulated fees generated by the network - - -### GeneralMessage.Status - - -| Name | Number | Description | -| ---- | ------ | ----------- | -| STATUS_UNSPECIFIED | 0 | | -| STATUS_APPROVED | 1 | | -| STATUS_EXECUTED | 2 | | - - - ### TransferDirection diff --git a/proto/axelar/nexus/exported/v1beta1/types.proto b/proto/axelar/nexus/exported/v1beta1/types.proto index 0bc868280..8a59448bb 100644 --- a/proto/axelar/nexus/exported/v1beta1/types.proto +++ b/proto/axelar/nexus/exported/v1beta1/types.proto @@ -87,23 +87,3 @@ enum TransferDirection { TRANSFER_DIRECTION_OUTGOING = 2 [ (gogoproto.enumvalue_customname) = "Outgoing" ]; } - -message GeneralMessage { - enum Status { - option (gogoproto.goproto_enum_prefix) = false; - option (gogoproto.goproto_enum_stringer) = true; - - STATUS_UNSPECIFIED = 0 [ (gogoproto.enumvalue_customname) = "NonExistent" ]; - STATUS_APPROVED = 1 [ (gogoproto.enumvalue_customname) = "Approved" ]; - STATUS_EXECUTED = 2 [ (gogoproto.enumvalue_customname) = "Executed" ]; - } - - string id = 1 [ (gogoproto.customname) = "ID" ]; - string source_chain = 2 [ (gogoproto.casttype) = "ChainName" ]; - string sender = 3; - string destination_chain = 4 [ (gogoproto.casttype) = "ChainName" ]; - string receiver = 5; - bytes payload_hash = 6; - Status status = 7; - cosmos.base.v1beta1.Coin asset = 8; -} diff --git a/third_party/proto/google/protobuf/descriptor.proto b/third_party/proto/google/protobuf/descriptor.proto index da8225f4e..0636a87ab 100644 --- a/third_party/proto/google/protobuf/descriptor.proto +++ b/third_party/proto/google/protobuf/descriptor.proto @@ -518,18 +518,6 @@ message MessageOptions { reserved 8; // javalite_serializable reserved 9; // javanano_as_lite - // Enable the legacy handling of JSON field name conflicts. This lowercases - // and strips underscored from the fields before comparison in proto3 only. - // The new behavior takes `json_name` into account and applies to proto2 as - // well. - // - // This should only be used as a temporary measure against broken builds due - // to the change in behavior for JSON field name conflicts. - // - // TODO(b/261750190) This is legacy behavior we plan to remove once downstream - // teams have had time to migrate. - optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true]; - // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -627,10 +615,6 @@ message FieldOptions { // For Google-internal migration only. Do not use. optional bool weak = 10 [default = false]; - // Indicate that the field value should not be printed out when using debug - // formats, e.g. when the field contains sensitive credentials. - optional bool debug_redact = 16 [default = false]; - // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; @@ -662,14 +646,6 @@ message EnumOptions { reserved 5; // javanano_as_lite - // Enable the legacy handling of JSON field name conflicts. This lowercases - // and strips underscored from the fields before comparison in proto3 only. - // The new behavior takes `json_name` into account and applies to proto2 as - // well. - // TODO(b/261750190) Remove this legacy behavior once downstream teams have - // had time to migrate. - optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true]; - // The parser stores options it doesn't recognize here. See above. repeated UninterpretedOption uninterpreted_option = 999; diff --git a/x/axelarnet/exported/params.go b/x/axelarnet/exported/params.go index bca8c94be..c26ae8045 100644 --- a/x/axelarnet/exported/params.go +++ b/x/axelarnet/exported/params.go @@ -8,15 +8,11 @@ import ( var ( // NativeAsset is the native asset on Axelarnet NativeAsset = "uaxl" - - // ModuleName exposes axelarnet module name - ModuleName = "axelarnet" - // Axelarnet defines properties of the Axelar chain Axelarnet = exported.Chain{ Name: "Axelarnet", SupportsForeignAssets: true, KeyType: tss.None, - Module: ModuleName, + Module: "axelarnet", // cannot use constant due to import cycle } ) diff --git a/x/evm/abci.go b/x/evm/abci.go index d780b76ee..c11e1e82e 100644 --- a/x/evm/abci.go +++ b/x/evm/abci.go @@ -65,32 +65,17 @@ func handleTokenSent(ctx sdk.Context, event types.Event, bk types.BaseKeeper, n } func handleContractCall(ctx sdk.Context, event types.Event, bk types.BaseKeeper, n types.Nexus, multisig types.MultisigKeeper) error { - e := event.GetContractCall() + e := event.GetEvent().(*types.Event_ContractCall).ContractCall if e == nil { panic(fmt.Errorf("event is nil")) } destinationChain := funcs.MustOk(n.GetChain(ctx, e.DestinationChain)) - switch destinationChain.Module { - case types.ModuleName: - handleContractCallToEVM(ctx, bk, multisig, n, destinationChain.Name, event) - return nil - default: - // set as general message in nexus, so the dest module can handle the message - return setMessageToNexus(ctx, n, event, nil) - } -} + destinationCk := funcs.Must(bk.ForChain(ctx, destinationChain.Name)) -func handleContractCallToEVM(ctx sdk.Context, bk types.BaseKeeper, multisig types.MultisigKeeper, n types.Nexus, destinationChain nexus.ChainName, event types.Event) { - e := event.GetContractCall() - if e == nil { - panic(fmt.Errorf("event is nil")) - } - - destinationCk := funcs.Must(bk.ForChain(ctx, destinationChain)) cmd := types.NewApproveContractCallCommand( funcs.MustOk(destinationCk.GetChainID(ctx)), - funcs.MustOk(multisig.GetCurrentKeyID(ctx, destinationChain)), + funcs.MustOk(multisig.GetCurrentKeyID(ctx, destinationChain.Name)), funcs.MustOk(n.GetChain(ctx, event.Chain)).Name, event.TxID, event.Index, @@ -98,7 +83,7 @@ func handleContractCallToEVM(ctx sdk.Context, bk types.BaseKeeper, multisig type ) funcs.MustNoErr(destinationCk.EnqueueCommand(ctx, cmd)) bk.Logger(ctx).Debug(fmt.Sprintf("created %s command for event", cmd.Type), - "chain", destinationChain, + "chain", destinationChain.Name, "eventID", event.GetID(), "commandID", cmd.ID.Hex(), ) @@ -112,50 +97,27 @@ func handleContractCallToEVM(ctx sdk.Context, bk types.BaseKeeper, multisig type ContractAddress: e.ContractAddress, PayloadHash: e.PayloadHash, }) + + return nil } func handleContractCallWithToken(ctx sdk.Context, event types.Event, bk types.BaseKeeper, n types.Nexus, multisig types.MultisigKeeper) error { - e := event.GetContractCallWithToken() + e := event.GetEvent().(*types.Event_ContractCallWithToken).ContractCallWithToken if e == nil { panic(fmt.Errorf("event is nil")) } sourceChain := funcs.MustOk(n.GetChain(ctx, event.Chain)) destinationChain := funcs.MustOk(n.GetChain(ctx, e.DestinationChain)) - sourceCk := funcs.Must(bk.ForChain(ctx, sourceChain.Name)) + destinationCk := funcs.Must(bk.ForChain(ctx, destinationChain.Name)) + token := sourceCk.GetERC20TokenBySymbol(ctx, e.Symbol) if !token.Is(types.Confirmed) { return fmt.Errorf("token with symbol %s not confirmed on source chain", e.Symbol) } - asset := token.GetAsset() - - if err := n.RateLimitTransfer(ctx, sourceChain.Name, sdk.NewCoin(asset, sdk.Int(e.Amount)), nexus.Incoming); err != nil { - return err - } - - if err := n.RateLimitTransfer(ctx, destinationChain.Name, sdk.NewCoin(asset, sdk.Int(e.Amount)), nexus.Outgoing); err != nil { - return err - } - - switch destinationChain.Module { - case types.ModuleName: - return handleContractCallWithTokenToEVM(ctx, event, bk, multisig, sourceChain.Name, destinationChain.Name, asset) - default: - coin := sdk.NewCoin(asset, sdk.Int(e.Amount)) - // set as general message in nexus, so the dest module can handle the message - return setMessageToNexus(ctx, n, event, &coin) - } -} - -func handleContractCallWithTokenToEVM(ctx sdk.Context, event types.Event, bk types.BaseKeeper, multisig types.MultisigKeeper, sourceChain, destinationChain nexus.ChainName, asset string) error { - e := event.GetContractCallWithToken() - if e == nil { - panic(fmt.Errorf("event is nil")) - } - - destinationCk := funcs.Must(bk.ForChain(ctx, destinationChain)) + asset := token.GetAsset() destinationToken := destinationCk.GetERC20TokenByAsset(ctx, asset) if !destinationToken.Is(types.Confirmed) { return fmt.Errorf("token with asset %s not confirmed on destination chain", e.Symbol) @@ -165,10 +127,18 @@ func handleContractCallWithTokenToEVM(ctx sdk.Context, event types.Event, bk typ return fmt.Errorf("invalid contract address %s", e.ContractAddress) } + if err := n.RateLimitTransfer(ctx, sourceChain.Name, sdk.NewCoin(asset, sdk.Int(e.Amount)), nexus.Incoming); err != nil { + return err + } + + if err := n.RateLimitTransfer(ctx, destinationChain.Name, sdk.NewCoin(asset, sdk.Int(e.Amount)), nexus.Outgoing); err != nil { + return err + } + cmd := types.NewApproveContractCallWithMintCommand( funcs.MustOk(destinationCk.GetChainID(ctx)), - funcs.MustOk(multisig.GetCurrentKeyID(ctx, destinationChain)), - sourceChain, + funcs.MustOk(multisig.GetCurrentKeyID(ctx, destinationChain.Name)), + sourceChain.Name, event.TxID, event.Index, *e, @@ -177,7 +147,7 @@ func handleContractCallWithTokenToEVM(ctx sdk.Context, event types.Event, bk typ ) funcs.MustNoErr(destinationCk.EnqueueCommand(ctx, cmd)) bk.Logger(ctx).Debug(fmt.Sprintf("created %s command for event", cmd.Type), - "chain", destinationChain, + "chain", destinationChain.Name, "eventID", event.GetID(), "commandID", cmd.ID.Hex(), ) @@ -196,42 +166,6 @@ func handleContractCallWithTokenToEVM(ctx sdk.Context, event types.Event, bk typ return nil } -func setMessageToNexus(ctx sdk.Context, n types.Nexus, event types.Event, asset *sdk.Coin) error { - var message nexus.GeneralMessage - switch e := event.GetEvent().(type) { - case *types.Event_ContractCall: - message = nexus.NewGeneralMessage( - string(event.GetID()), - event.Chain, - e.ContractCall.Sender.Hex(), - e.ContractCall.DestinationChain, - e.ContractCall.ContractAddress, - e.ContractCall.PayloadHash.Bytes(), - nexus.Approved, - nil, - ) - - case *types.Event_ContractCallWithToken: - if asset == nil { - return fmt.Errorf("expect asset for ContractCallWithToken") - } - message = nexus.NewGeneralMessage( - string(event.GetID()), - event.Chain, - e.ContractCallWithToken.Sender.Hex(), - e.ContractCallWithToken.DestinationChain, - e.ContractCallWithToken.ContractAddress, - e.ContractCallWithToken.PayloadHash.Bytes(), - nexus.Approved, - asset, - ) - default: - return fmt.Errorf("unsupported event type %T", event) - } - - return n.SetNewMessage(ctx, message) -} - func handleConfirmDeposit(ctx sdk.Context, event types.Event, bk types.BaseKeeper, n types.Nexus) error { e := event.GetEvent().(*types.Event_Transfer).Transfer if e == nil { @@ -423,14 +357,11 @@ func handleMultisigTransferKey(ctx sdk.Context, event types.Event, bk types.Base func validateEvent(ctx sdk.Context, event types.Event, bk types.BaseKeeper, n types.Nexus) error { var destinationChainName nexus.ChainName - var contractAddress string switch event := event.GetEvent().(type) { case *types.Event_ContractCall: destinationChainName = event.ContractCall.DestinationChain - contractAddress = event.ContractCall.ContractAddress case *types.Event_ContractCallWithToken: destinationChainName = event.ContractCallWithToken.DestinationChain - contractAddress = event.ContractCallWithToken.ContractAddress case *types.Event_TokenSent: destinationChainName = event.TokenSent.DestinationChain case *types.Event_Transfer, *types.Event_TokenDeployed, @@ -452,15 +383,11 @@ func validateEvent(ctx sdk.Context, event types.Event, bk types.BaseKeeper, n ty return fmt.Errorf("destination chain de-activated") } - // skip further destination chain keeper checks if it is not an evm chain - if !destinationChain.IsFrom(types.ModuleName) { + if event.GetTokenSent() != nil && !types.IsEVMChain(destinationChain) { return nil } - if len(contractAddress) != 0 && !common.IsHexAddress(contractAddress) { - return fmt.Errorf("invalid contract address") - } - + // skip further checks and handle event if destination is not an evm chain destinationCk, err := bk.ForChain(ctx, destinationChainName) if err != nil { return fmt.Errorf("destination chain not EVM-compatible") diff --git a/x/evm/abci_test.go b/x/evm/abci_test.go index 7187229fe..daf19ef85 100644 --- a/x/evm/abci_test.go +++ b/x/evm/abci_test.go @@ -19,7 +19,6 @@ import ( "github.com/axelarnetwork/axelar-core/testutils/rand" "github.com/axelarnetwork/axelar-core/utils" utilsMock "github.com/axelarnetwork/axelar-core/utils/mock" - axelarnet "github.com/axelarnetwork/axelar-core/x/axelarnet/exported" "github.com/axelarnetwork/axelar-core/x/evm/types" "github.com/axelarnetwork/axelar-core/x/evm/types/mock" evmTestUtils "github.com/axelarnetwork/axelar-core/x/evm/types/testutils" @@ -98,7 +97,7 @@ func TestHandleContractCall(t *testing.T) { n.GetChainFunc = func(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) { switch chain { case sourceChainName, destinationChainName: - return nexus.Chain{Name: chain, Module: types.ModuleName}, true + return nexus.Chain{Name: chain}, true default: return nexus.Chain{}, false } @@ -113,31 +112,12 @@ func TestHandleContractCall(t *testing.T) { } } - errorWith := func(msg string) func(t *testing.T) { - return func(t *testing.T) { - assert.ErrorContains(t, handleContractCall(ctx, event, bk, n, multisigKeeper), msg) - } - } - isDestinationChainEvm := func(_isEvm bool) func() { return func() { isEvm = _isEvm } } - destinationChainIsCosmos := func() func() { - return func() { - n.GetChainFunc = func(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) { - switch chain { - case destinationChainName: - return nexus.Chain{Name: chain, Module: axelarnet.ModuleName}, true - default: - return nexus.Chain{}, false - } - } - } - } - isDestinationChainIDSet := func(isSet bool) func() { return func() { destinationCk.GetChainIDFunc = func(ctx sdk.Context) (sdk.Int, bool) { return sdk.ZeroInt(), isSet } @@ -168,18 +148,6 @@ func TestHandleContractCall(t *testing.T) { } } - setGeneralMessageSucceed := func(isSuccessful bool) func() { - return func() { - n.SetNewMessageFunc = func(sdk.Context, nexus.GeneralMessage) error { - if !isSuccessful { - return fmt.Errorf("set general message error") - } - - return nil - } - } - } - givenContractCallEvent. When("the destination chain is not registered", func() { n.GetChainFunc = func(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) { @@ -226,22 +194,6 @@ func TestHandleContractCall(t *testing.T) { assert.Len(t, destinationCk.EnqueueCommandCalls(), 1) }). Run(t) - - whenChainsAreRegistered. - When("destination chain is a cosmos chain", destinationChainIsCosmos()). - When("set general message fails", setGeneralMessageSucceed(false)). - Then("should fail", errorWith("set general message error")). - Run(t) - - whenChainsAreRegistered. - When("destination chain is a cosmos chain", destinationChainIsCosmos()). - When("set general message succeeds", setGeneralMessageSucceed(true)). - Then("should succeed", func(t *testing.T) { - err := handleContractCall(ctx, event, bk, n, multisigKeeper) - assert.NoError(t, err) - assert.Len(t, n.SetNewMessageCalls(), 1) - }). - Run(t) } func TestHandleTokenSent(t *testing.T) { @@ -506,7 +458,7 @@ func TestHandleContractCallWithToken(t *testing.T) { n.GetChainFunc = func(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) { switch chain { case sourceChainName, destinationChainName: - return nexus.Chain{Name: chain, Module: types.ModuleName}, true + return nexus.Chain{Name: chain}, true default: return nexus.Chain{}, false } @@ -537,14 +489,13 @@ func TestHandleContractCallWithToken(t *testing.T) { n.GetChainFunc = func(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) { switch chain { case sourceChainName, destinationChainName: - return nexus.Chain{Name: chain, Module: types.ModuleName}, true + return nexus.Chain{Name: chain}, true default: return nexus.Chain{}, false } } n.IsChainActivatedFunc = func(ctx sdk.Context, chain nexus.Chain) bool { return true } - n.RateLimitTransferFunc = func(sdk.Context, nexus.ChainName, sdk.Coin, nexus.TransferDirection) error { return nil } sourceCk.GetERC20TokenBySymbolFunc = func(ctx sdk.Context, symbol string) types.ERC20Token { if symbol == event.GetContractCallWithToken().Symbol { return types.CreateERC20Token(func(meta types.ERC20TokenMetadata) {}, types.ERC20TokenMetadata{Status: types.Confirmed, Asset: symbol}) @@ -575,14 +526,13 @@ func TestHandleContractCallWithToken(t *testing.T) { n.GetChainFunc = func(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) { switch chain { case sourceChainName, destinationChainName: - return nexus.Chain{Name: chain, Module: types.ModuleName}, true + return nexus.Chain{Name: chain}, true default: return nexus.Chain{}, false } } n.IsChainActivatedFunc = func(ctx sdk.Context, chain nexus.Chain) bool { return true } - n.RateLimitTransferFunc = func(sdk.Context, nexus.ChainName, sdk.Coin, nexus.TransferDirection) error { return nil } sourceCk.GetERC20TokenBySymbolFunc = func(ctx sdk.Context, symbol string) types.ERC20Token { if symbol == event.GetContractCallWithToken().Symbol { return types.CreateERC20Token(func(meta types.ERC20TokenMetadata) {}, types.ERC20TokenMetadata{Status: types.Confirmed, Asset: symbol}) @@ -620,7 +570,7 @@ func TestHandleContractCallWithToken(t *testing.T) { n.GetChainFunc = func(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) { switch chain { case sourceChainName, destinationChainName: - return nexus.Chain{Name: chain, Module: types.ModuleName}, true + return nexus.Chain{Name: chain}, true default: return nexus.Chain{}, false } @@ -669,7 +619,7 @@ func TestHandleContractCallWithToken(t *testing.T) { n.GetChainFunc = func(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) { switch chain { case sourceChainName, destinationChainName: - return nexus.Chain{Name: chain, Module: types.ModuleName}, true + return nexus.Chain{Name: chain}, true default: return nexus.Chain{}, false } @@ -721,7 +671,7 @@ func TestHandleContractCallWithToken(t *testing.T) { n.GetChainFunc = func(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) { switch chain { case sourceChainName, destinationChainName: - return nexus.Chain{Name: chain, Module: types.ModuleName}, true + return nexus.Chain{Name: chain}, true default: return nexus.Chain{}, false } @@ -767,7 +717,7 @@ func TestHandleContractCallWithToken(t *testing.T) { n.GetChainFunc = func(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) { switch chain { case sourceChainName, destinationChainName: - return nexus.Chain{Name: chain, Module: types.ModuleName}, true + return nexus.Chain{Name: chain}, true default: return nexus.Chain{}, false } @@ -1171,7 +1121,7 @@ func TestHandleConfirmedEvent(t *testing.T) { n.GetChainFunc = func(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) { switch chain { case sourceChainName, destinationChainName: - return nexus.Chain{Name: chain, Module: types.ModuleName}, true + return nexus.Chain{Name: chain}, true default: return nexus.Chain{}, true } @@ -1194,9 +1144,6 @@ func TestHandleConfirmedEvent(t *testing.T) { return "", false } - sourceCk.GetERC20TokenBySymbolFunc = func(ctx sdk.Context, symbol string) types.ERC20Token { - return types.CreateERC20Token(func(meta types.ERC20TokenMetadata) {}, types.ERC20TokenMetadata{Status: types.Confirmed, Asset: symbol}) - } sourceCk.SetEventCompletedFunc = func(ctx sdk.Context, eventID types.EventID) error { return nil } sourceCk.GetConfirmedEventQueueFunc = func(sdk.Context) utils.KVQueue { return confirmedEventQueue @@ -1252,7 +1199,6 @@ func TestHandleConfirmedEvent(t *testing.T) { count++ event := evmTestUtils.RandomGatewayEvent(types.EventConfirmed) - event.Chain = sourceChainName switch event.GetEvent().(type) { case *types.Event_ContractCall: e := event.GetEvent().(*types.Event_ContractCall) diff --git a/x/evm/types/expected_keepers.go b/x/evm/types/expected_keepers.go index 0e90ffd94..be778a4a5 100644 --- a/x/evm/types/expected_keepers.go +++ b/x/evm/types/expected_keepers.go @@ -114,7 +114,6 @@ type Nexus interface { GetChainMaintainerState(ctx sdk.Context, chain nexus.Chain, address sdk.ValAddress) (nexus.MaintainerState, bool) SetChainMaintainerState(ctx sdk.Context, maintainerState nexus.MaintainerState) error RateLimitTransfer(ctx sdk.Context, chain nexus.ChainName, asset sdk.Coin, direction nexus.TransferDirection) error - SetNewMessage(ctx sdk.Context, m nexus.GeneralMessage) error } // InitPoller is a minimal interface to start a poll. This must be a type alias instead of a type definition, diff --git a/x/evm/types/mock/expected_keepers.go b/x/evm/types/mock/expected_keepers.go index 64cf377d9..46241c4b0 100644 --- a/x/evm/types/mock/expected_keepers.go +++ b/x/evm/types/mock/expected_keepers.go @@ -158,9 +158,6 @@ var _ types.Nexus = &NexusMock{} // SetChainMaintainerStateFunc: func(ctx github_com_cosmos_cosmos_sdk_types.Context, maintainerState github_com_axelarnetwork_axelar_core_x_nexus_exported.MaintainerState) error { // panic("mock out the SetChainMaintainerState method") // }, -// SetNewMessageFunc: func(ctx github_com_cosmos_cosmos_sdk_types.Context, m github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage) error { -// panic("mock out the SetNewMessage method") -// }, // } // // // use mockedNexus in code that requires types.Nexus @@ -225,9 +222,6 @@ type NexusMock struct { // SetChainMaintainerStateFunc mocks the SetChainMaintainerState method. SetChainMaintainerStateFunc func(ctx github_com_cosmos_cosmos_sdk_types.Context, maintainerState github_com_axelarnetwork_axelar_core_x_nexus_exported.MaintainerState) error - // SetNewMessageFunc mocks the SetNewMessage method. - SetNewMessageFunc func(ctx github_com_cosmos_cosmos_sdk_types.Context, m github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage) error - // calls tracks calls to the methods. calls struct { // AddTransferFee holds details about calls to the AddTransferFee method. @@ -391,13 +385,6 @@ type NexusMock struct { // MaintainerState is the maintainerState argument value. MaintainerState github_com_axelarnetwork_axelar_core_x_nexus_exported.MaintainerState } - // SetNewMessage holds details about calls to the SetNewMessage method. - SetNewMessage []struct { - // Ctx is the ctx argument value. - Ctx github_com_cosmos_cosmos_sdk_types.Context - // M is the m argument value. - M github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage - } } lockAddTransferFee sync.RWMutex lockArchivePendingTransfer sync.RWMutex @@ -418,7 +405,6 @@ type NexusMock struct { lockRegisterAsset sync.RWMutex lockSetChain sync.RWMutex lockSetChainMaintainerState sync.RWMutex - lockSetNewMessage sync.RWMutex } // AddTransferFee calls AddTransferFeeFunc. @@ -1161,42 +1147,6 @@ func (mock *NexusMock) SetChainMaintainerStateCalls() []struct { return calls } -// SetNewMessage calls SetNewMessageFunc. -func (mock *NexusMock) SetNewMessage(ctx github_com_cosmos_cosmos_sdk_types.Context, m github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage) error { - if mock.SetNewMessageFunc == nil { - panic("NexusMock.SetNewMessageFunc: method is nil but Nexus.SetNewMessage was just called") - } - callInfo := struct { - Ctx github_com_cosmos_cosmos_sdk_types.Context - M github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage - }{ - Ctx: ctx, - M: m, - } - mock.lockSetNewMessage.Lock() - mock.calls.SetNewMessage = append(mock.calls.SetNewMessage, callInfo) - mock.lockSetNewMessage.Unlock() - return mock.SetNewMessageFunc(ctx, m) -} - -// SetNewMessageCalls gets all the calls that were made to SetNewMessage. -// Check the length with: -// -// len(mockedNexus.SetNewMessageCalls()) -func (mock *NexusMock) SetNewMessageCalls() []struct { - Ctx github_com_cosmos_cosmos_sdk_types.Context - M github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage -} { - var calls []struct { - Ctx github_com_cosmos_cosmos_sdk_types.Context - M github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage - } - mock.lockSetNewMessage.RLock() - calls = mock.calls.SetNewMessage - mock.lockSetNewMessage.RUnlock() - return calls -} - // Ensure, that SnapshotterMock does implement types.Snapshotter. // If this is not the case, regenerate this file with moq. var _ types.Snapshotter = &SnapshotterMock{} diff --git a/x/evm/types/types.go b/x/evm/types/types.go index d349ee40c..4d4c194fe 100644 --- a/x/evm/types/types.go +++ b/x/evm/types/types.go @@ -965,8 +965,6 @@ func (m Event) GetEventType() string { return getType(m.GetEvent()) } -const maxReceiverLength = 128 - // ValidateBasic returns an error if the event token sent is invalid func (m EventTokenSent) ValidateBasic() error { if m.Sender.IsZeroAddress() { @@ -981,10 +979,6 @@ func (m EventTokenSent) ValidateBasic() error { return sdkerrors.Wrap(err, "invalid destination address") } - if len(m.DestinationAddress) > maxReceiverLength { - return fmt.Errorf("receiver length %d is greater than %d", len(m.DestinationAddress), maxReceiverLength) - } - if err := utils.ValidateString(m.Symbol); err != nil { return sdkerrors.Wrap(err, "invalid symbol") } @@ -1006,12 +1000,8 @@ func (m EventContractCall) ValidateBasic() error { return sdkerrors.Wrap(err, "invalid destination chain") } - if err := utils.ValidateString(m.ContractAddress); err != nil { - return sdkerrors.Wrap(err, "invalid destination address") - } - - if len(m.ContractAddress) > maxReceiverLength { - return fmt.Errorf("receiver length %d is greater than %d", len(m.ContractAddress), maxReceiverLength) + if !common.IsHexAddress(m.ContractAddress) { + return fmt.Errorf("invalid contract address") } if m.PayloadHash.IsZero() { @@ -1031,12 +1021,8 @@ func (m EventContractCallWithToken) ValidateBasic() error { return sdkerrors.Wrap(err, "invalid destination chain") } - if err := utils.ValidateString(m.ContractAddress); err != nil { - return sdkerrors.Wrap(err, "invalid destination address") - } - - if len(m.ContractAddress) > maxReceiverLength { - return fmt.Errorf("receiver length %d is greater than %d", len(m.ContractAddress), maxReceiverLength) + if !common.IsHexAddress(m.ContractAddress) { + return fmt.Errorf("invalid contract address") } if m.PayloadHash.IsZero() { diff --git a/x/nexus/exported/types.go b/x/nexus/exported/types.go index c3eee4ea7..788406bd5 100644 --- a/x/nexus/exported/types.go +++ b/x/nexus/exported/types.go @@ -126,11 +126,6 @@ func (m Chain) GetName() ChainName { return m.Name } -// IsFrom returns true if the chain registered under the module -func (m Chain) IsFrom(module string) bool { - return m.Module == module -} - // NewAsset returns an asset struct func NewAsset(denom string, isNative bool) Asset { return Asset{Denom: utils.NormalizeString(denom), IsNativeAsset: isNative} @@ -237,46 +232,3 @@ func (m TransferDirection) ValidateBasic() error { return fmt.Errorf("invalid transfer direction %s", m) } } - -// NewGeneralMessage returns a GeneralMessage struct -func NewGeneralMessage(id string, sourceChain ChainName, sender string, destChain ChainName, receiver string, payloadHash []byte, status GeneralMessage_Status, asset *sdk.Coin) GeneralMessage { - return GeneralMessage{ - ID: id, - SourceChain: sourceChain, - Sender: sender, - DestinationChain: destChain, - Receiver: receiver, - PayloadHash: payloadHash, - Status: status, - Asset: asset, - } -} - -// ValidateBasic validates the general message -func (m GeneralMessage) ValidateBasic() error { - if err := utils.ValidateString(m.ID); err != nil { - return sdkerrors.Wrap(err, "invalid id") - } - - if err := m.SourceChain.Validate(); err != nil { - return sdkerrors.Wrap(err, "invalid source chain") - } - - if err := utils.ValidateString(m.Sender); err != nil { - return sdkerrors.Wrap(err, "invalid sender") - } - - if err := m.DestinationChain.Validate(); err != nil { - return sdkerrors.Wrap(err, "invalid destination chain") - } - - if err := utils.ValidateString(m.Receiver); err != nil { - return sdkerrors.Wrap(err, "invalid receiver") - } - - if m.Asset != nil { - return m.Asset.Validate() - } - - return nil -} diff --git a/x/nexus/exported/types.pb.go b/x/nexus/exported/types.pb.go index 0b2eccfbb..8ff1981b7 100644 --- a/x/nexus/exported/types.pb.go +++ b/x/nexus/exported/types.pb.go @@ -85,34 +85,6 @@ func (TransferDirection) EnumDescriptor() ([]byte, []int) { return fileDescriptor_82a7a8692925fe67, []int{1} } -type GeneralMessage_Status int32 - -const ( - NonExistent GeneralMessage_Status = 0 - Approved GeneralMessage_Status = 1 - Executed GeneralMessage_Status = 2 -) - -var GeneralMessage_Status_name = map[int32]string{ - 0: "STATUS_UNSPECIFIED", - 1: "STATUS_APPROVED", - 2: "STATUS_EXECUTED", -} - -var GeneralMessage_Status_value = map[string]int32{ - "STATUS_UNSPECIFIED": 0, - "STATUS_APPROVED": 1, - "STATUS_EXECUTED": 2, -} - -func (x GeneralMessage_Status) String() string { - return proto.EnumName(GeneralMessage_Status_name, int32(x)) -} - -func (GeneralMessage_Status) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_82a7a8692925fe67, []int{6, 0} -} - // Chain represents the properties of a registered blockchain type Chain struct { Name ChainName `protobuf:"bytes,1,opt,name=name,proto3,casttype=ChainName" json:"name,omitempty"` @@ -352,61 +324,15 @@ func (m *Asset) XXX_DiscardUnknown() { var xxx_messageInfo_Asset proto.InternalMessageInfo -type GeneralMessage struct { - ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - SourceChain ChainName `protobuf:"bytes,2,opt,name=source_chain,json=sourceChain,proto3,casttype=ChainName" json:"source_chain,omitempty"` - Sender string `protobuf:"bytes,3,opt,name=sender,proto3" json:"sender,omitempty"` - DestinationChain ChainName `protobuf:"bytes,4,opt,name=destination_chain,json=destinationChain,proto3,casttype=ChainName" json:"destination_chain,omitempty"` - Receiver string `protobuf:"bytes,5,opt,name=receiver,proto3" json:"receiver,omitempty"` - PayloadHash []byte `protobuf:"bytes,6,opt,name=payload_hash,json=payloadHash,proto3" json:"payload_hash,omitempty"` - Status GeneralMessage_Status `protobuf:"varint,7,opt,name=status,proto3,enum=axelar.nexus.exported.v1beta1.GeneralMessage_Status" json:"status,omitempty"` - Asset *types.Coin `protobuf:"bytes,8,opt,name=asset,proto3" json:"asset,omitempty"` -} - -func (m *GeneralMessage) Reset() { *m = GeneralMessage{} } -func (m *GeneralMessage) String() string { return proto.CompactTextString(m) } -func (*GeneralMessage) ProtoMessage() {} -func (*GeneralMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_82a7a8692925fe67, []int{6} -} -func (m *GeneralMessage) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GeneralMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GeneralMessage.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *GeneralMessage) XXX_Merge(src proto.Message) { - xxx_messageInfo_GeneralMessage.Merge(m, src) -} -func (m *GeneralMessage) XXX_Size() int { - return m.Size() -} -func (m *GeneralMessage) XXX_DiscardUnknown() { - xxx_messageInfo_GeneralMessage.DiscardUnknown(m) -} - -var xxx_messageInfo_GeneralMessage proto.InternalMessageInfo - func init() { proto.RegisterEnum("axelar.nexus.exported.v1beta1.TransferState", TransferState_name, TransferState_value) proto.RegisterEnum("axelar.nexus.exported.v1beta1.TransferDirection", TransferDirection_name, TransferDirection_value) - proto.RegisterEnum("axelar.nexus.exported.v1beta1.GeneralMessage_Status", GeneralMessage_Status_name, GeneralMessage_Status_value) proto.RegisterType((*Chain)(nil), "axelar.nexus.exported.v1beta1.Chain") proto.RegisterType((*CrossChainAddress)(nil), "axelar.nexus.exported.v1beta1.CrossChainAddress") proto.RegisterType((*CrossChainTransfer)(nil), "axelar.nexus.exported.v1beta1.CrossChainTransfer") proto.RegisterType((*TransferFee)(nil), "axelar.nexus.exported.v1beta1.TransferFee") proto.RegisterType((*FeeInfo)(nil), "axelar.nexus.exported.v1beta1.FeeInfo") proto.RegisterType((*Asset)(nil), "axelar.nexus.exported.v1beta1.Asset") - proto.RegisterType((*GeneralMessage)(nil), "axelar.nexus.exported.v1beta1.GeneralMessage") } func init() { @@ -414,76 +340,64 @@ func init() { } var fileDescriptor_82a7a8692925fe67 = []byte{ - // 1104 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xf6, 0x3a, 0xfe, 0xca, 0x38, 0x6d, 0x9d, 0x51, 0x48, 0x8d, 0x11, 0x6b, 0xc7, 0x54, 0x4d, - 0x8a, 0xc8, 0x3a, 0x6d, 0x29, 0x07, 0x0e, 0x80, 0x3f, 0xd6, 0xe9, 0x52, 0xb2, 0x8e, 0xd6, 0x76, - 0x85, 0xb8, 0x58, 0x9b, 0xdd, 0xd7, 0xf6, 0x2a, 0xf1, 0x8c, 0xb5, 0xb3, 0x0e, 0xce, 0x91, 0x1b, - 0x0a, 0x17, 0xfe, 0x40, 0x0e, 0x08, 0x0e, 0x08, 0xf1, 0x27, 0xb8, 0xe5, 0x82, 0xd4, 0x23, 0xe2, - 0x10, 0x20, 0xf9, 0x03, 0x9c, 0x7b, 0x42, 0x33, 0xb3, 0x8e, 0x9d, 0xd4, 0x6a, 0x80, 0x53, 0x76, - 0xe6, 0x7d, 0xde, 0xe7, 0x7d, 0xde, 0xaf, 0x89, 0xd1, 0x03, 0x7b, 0x0c, 0x07, 0xb6, 0x5f, 0x22, - 0x30, 0x1e, 0xb1, 0x12, 0x8c, 0x87, 0xd4, 0x0f, 0xc0, 0x2d, 0x1d, 0x3e, 0xdc, 0x83, 0xc0, 0x7e, - 0x58, 0x0a, 0x8e, 0x86, 0xc0, 0xb4, 0xa1, 0x4f, 0x03, 0x8a, 0xdf, 0x96, 0x50, 0x4d, 0x40, 0xb5, - 0x09, 0x54, 0x0b, 0xa1, 0xb9, 0x95, 0x1e, 0xed, 0x51, 0x81, 0x2c, 0xf1, 0x2f, 0xe9, 0x94, 0x53, - 0x1d, 0xca, 0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x92, - 0xfa, 0xfb, 0xe1, 0x69, 0xd3, 0xa1, 0x3e, 0x94, 0xc6, 0xd7, 0x7e, 0x7e, 0xec, 0x25, 0xc4, 0xff, - 0xfc, 0xc7, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0xf3, 0x50, 0x8e, 0x95, 0x9e, 0x08, 0x00, 0x00, + // 898 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xf7, 0x3a, 0x76, 0xec, 0x8c, 0x1b, 0xea, 0x8e, 0x42, 0x6a, 0x8c, 0x58, 0x1b, 0x53, 0xb5, + 0x69, 0x45, 0xd6, 0xfd, 0xa3, 0x72, 0x04, 0xfc, 0x37, 0x2c, 0x55, 0xd7, 0xd1, 0x7a, 0xcd, 0x81, + 0x8b, 0xb5, 0xd9, 0x7d, 0x76, 0x46, 0xe9, 0xce, 0x58, 0x3b, 0xe3, 0xe0, 0x7c, 0x03, 0x14, 0x2e, + 0x7c, 0x81, 0x1c, 0x10, 0x1c, 0x10, 0xe2, 0x4b, 0x70, 0xcb, 0x05, 0xa9, 0x47, 0xc4, 0xc1, 0x40, + 0xf2, 0x2d, 0x7a, 0x42, 0x33, 0xbb, 0x5b, 0xa7, 0x6e, 0xd4, 0x40, 0x4f, 0xbb, 0xb3, 0xef, 0xf7, + 0x7e, 0xef, 0xf7, 0x7b, 0x6f, 0x9e, 0x16, 0xdd, 0x75, 0x67, 0xf0, 0xcc, 0x0d, 0xeb, 0x14, 0x66, + 0x53, 0x5e, 0x87, 0xd9, 0x84, 0x85, 0x02, 0xfc, 0xfa, 0xe1, 0x83, 0x3d, 0x10, 0xee, 0x83, 0xba, + 0x38, 0x9a, 0x00, 0x37, 0x26, 0x21, 0x13, 0x0c, 0x7f, 0x10, 0x41, 0x0d, 0x05, 0x35, 0x12, 0xa8, + 0x11, 0x43, 0xc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8, 0xcf, 0x96, 0xfe, 0x45, 0x7b, 0xab, + 0xea, 0x07, 0xf0, 0xe8, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfa, 0xce, 0x49, 0xf2, 0xab, 0x06, + 0x00, 0x00, } func (m *Chain) Marshal() (dAtA []byte, err error) { @@ -775,88 +689,6 @@ func (m *Asset) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *GeneralMessage) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GeneralMessage) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GeneralMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Asset != nil { - { - size, err := m.Asset.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - } - if m.Status != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x38 - } - if len(m.PayloadHash) > 0 { - i -= len(m.PayloadHash) - copy(dAtA[i:], m.PayloadHash) - i = encodeVarintTypes(dAtA, i, uint64(len(m.PayloadHash))) - i-- - dAtA[i] = 0x32 - } - if len(m.Receiver) > 0 { - i -= len(m.Receiver) - copy(dAtA[i:], m.Receiver) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Receiver))) - i-- - dAtA[i] = 0x2a - } - if len(m.DestinationChain) > 0 { - i -= len(m.DestinationChain) - copy(dAtA[i:], m.DestinationChain) - i = encodeVarintTypes(dAtA, i, uint64(len(m.DestinationChain))) - i-- - dAtA[i] = 0x22 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0x1a - } - if len(m.SourceChain) > 0 { - i -= len(m.SourceChain) - copy(dAtA[i:], m.SourceChain) - i = encodeVarintTypes(dAtA, i, uint64(len(m.SourceChain))) - i-- - dAtA[i] = 0x12 - } - if len(m.ID) > 0 { - i -= len(m.ID) - copy(dAtA[i:], m.ID) - i = encodeVarintTypes(dAtA, i, uint64(len(m.ID))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { offset -= sovTypes(v) base := offset @@ -979,46 +811,6 @@ func (m *Asset) Size() (n int) { return n } -func (m *GeneralMessage) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ID) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.SourceChain) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.DestinationChain) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.Receiver) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.PayloadHash) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if m.Status != 0 { - n += 1 + sovTypes(uint64(m.Status)) - } - if m.Asset != nil { - l = m.Asset.Size() - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1846,305 +1638,6 @@ func (m *Asset) Unmarshal(dAtA []byte) error { } return nil } -func (m *GeneralMessage) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GeneralMessage: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GeneralMessage: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SourceChain", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SourceChain = ChainName(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DestinationChain", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DestinationChain = ChainName(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Receiver", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Receiver = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PayloadHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PayloadHash = append(m.PayloadHash[:0], dAtA[iNdEx:postIndex]...) - if m.PayloadHash == nil { - m.PayloadHash = []byte{} - } - iNdEx = postIndex - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= GeneralMessage_Status(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Asset", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Asset == nil { - m.Asset = &types.Coin{} - } - if err := m.Asset.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/nexus/keeper/general_message.go b/x/nexus/keeper/general_message.go deleted file mode 100644 index 1fd495fa5..000000000 --- a/x/nexus/keeper/general_message.go +++ /dev/null @@ -1,73 +0,0 @@ -package keeper - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/axelarnetwork/axelar-core/utils" - "github.com/axelarnetwork/axelar-core/utils/key" - "github.com/axelarnetwork/axelar-core/x/nexus/exported" -) - -func getMessageKey(chain exported.ChainName, id string) key.Key { - return generalMessagePrefix. - Append(key.From(chain)). - Append(key.FromStr(id)) -} - -// SetNewMessage sets the given general message -func (k Keeper) SetNewMessage(ctx sdk.Context, m exported.GeneralMessage) error { - sourceChain, ok := k.GetChain(ctx, m.SourceChain) - if !ok { - return fmt.Errorf("source chain %s is not a registered chain", m.SourceChain) - } - - destChain, ok := k.GetChain(ctx, m.DestinationChain) - if !ok { - return fmt.Errorf("destination chain %s is not a registered chain", m.DestinationChain) - } - - validator := k.GetRouter().GetAddressValidator(destChain.Module) - if err := validator(ctx, exported.CrossChainAddress{Chain: destChain, Address: m.Receiver}); err != nil { - return err - } - - if m.Asset != nil { - if err := k.validateTransferAsset(ctx, sourceChain, m.Asset.Denom); err != nil { - return err - } - - if err := k.validateTransferAsset(ctx, destChain, m.Asset.Denom); err != nil { - return err - } - } - - if _, found := k.getMessage(ctx, m.DestinationChain, m.ID); found { - return fmt.Errorf("general message %s for chain %s already exists", m.ID, m.DestinationChain.String()) - } - - return k.setMessage(ctx, m) -} - -func (k Keeper) getMessage(ctx sdk.Context, chain exported.ChainName, id string) (m exported.GeneralMessage, found bool) { - return m, k.getStore(ctx).GetNew(getMessageKey(chain, id), &m) -} - -func (k Keeper) setMessage(ctx sdk.Context, m exported.GeneralMessage) error { - return k.getStore(ctx).SetNewValidated(getMessageKey(m.DestinationChain, m.ID), &m) -} - -func (k Keeper) getMessages(ctx sdk.Context) (generalMessages []exported.GeneralMessage) { - iter := k.getStore(ctx).IteratorNew(generalMessagePrefix) - defer utils.CloseLogError(iter, k.Logger(ctx)) - - for ; iter.Valid(); iter.Next() { - var generalMessage exported.GeneralMessage - iter.UnmarshalValue(&generalMessage) - - generalMessages = append(generalMessages, generalMessage) - } - - return generalMessages -} diff --git a/x/nexus/keeper/general_message_test.go b/x/nexus/keeper/general_message_test.go deleted file mode 100644 index 8c6f85fa5..000000000 --- a/x/nexus/keeper/general_message_test.go +++ /dev/null @@ -1,115 +0,0 @@ -package keeper_test - -import ( - "fmt" - "testing" - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/stretchr/testify/assert" - - "github.com/axelarnetwork/axelar-core/app" - "github.com/axelarnetwork/axelar-core/testutils/rand" - "github.com/axelarnetwork/axelar-core/utils" - axelarnet "github.com/axelarnetwork/axelar-core/x/axelarnet/exported" - evmtestutils "github.com/axelarnetwork/axelar-core/x/evm/types/testutils" - "github.com/axelarnetwork/axelar-core/x/nexus/exported" - nexus "github.com/axelarnetwork/axelar-core/x/nexus/keeper" - "github.com/axelarnetwork/utils/funcs" - . "github.com/axelarnetwork/utils/test" -) - -func TestSetNewGeneralMessage(t *testing.T) { - var ( - generalMessage exported.GeneralMessage - ctx sdk.Context - k nexus.Keeper - ) - cfg := app.MakeEncodingConfig() - sourceChainName := exported.ChainName(rand.Str(5)) - destinationChainName := exported.ChainName(rand.Str(5)) - asset := rand.Coin() - - givenContractCallEvent := Given("a general message with token", func() { - generalMessage = exported.GeneralMessage{ - ID: fmt.Sprintf("%s-%d", evmtestutils.RandomHash().Hex(), rand.PosI64()), - SourceChain: sourceChainName, - Sender: evmtestutils.RandomAddress().Hex(), - DestinationChain: destinationChainName, - Receiver: genCosmosAddr(destinationChainName.String()), - Status: exported.Approved, - PayloadHash: crypto.Keccak256Hash(rand.Bytes(int(rand.I64Between(1, 100)))).Bytes(), - Asset: &asset, - } - - k, ctx = setup(cfg) - }) - - whenChainsAreRegistered := givenContractCallEvent. - When("the source and destination chains are registered", func() { - k.SetChain(ctx, exported.Chain{Name: sourceChainName, SupportsForeignAssets: true}) - k.SetChain(ctx, exported.Chain{Name: destinationChainName, SupportsForeignAssets: true}) - }) - - errorWith := func(msg string) func(t *testing.T) { - return func(t *testing.T) { - assert.ErrorContains(t, k.SetNewMessage(ctx, generalMessage), msg) - } - } - - isCosmosChain := func(isCosmosChain bool) func() { - return func() { - if isCosmosChain { - destChain := funcs.MustOk(k.GetChain(ctx, destinationChainName)) - destChain.Module = axelarnet.ModuleName - k.SetChain(ctx, destChain) - } - } - } - - isAssetRegistered := func(isRegistered bool) func() { - return func() { - if isRegistered { - srcChain := funcs.MustOk(k.GetChain(ctx, sourceChainName)) - destChain := funcs.MustOk(k.GetChain(ctx, destinationChainName)) - funcs.MustNoErr(k.RegisterAsset(ctx, srcChain, exported.Asset{Denom: asset.Denom, IsNativeAsset: false}, utils.MaxUint, time.Hour)) - funcs.MustNoErr(k.RegisterAsset(ctx, destChain, exported.Asset{Denom: asset.Denom, IsNativeAsset: false}, utils.MaxUint, time.Hour)) - } - } - } - - givenContractCallEvent. - When("the source chain is not registered", func() {}). - Then("should return error", errorWith(fmt.Sprintf("source chain %s is not a registered chain", sourceChainName))). - Run(t) - - givenContractCallEvent. - When("the destination chain is not registered", func() { - k.SetChain(ctx, exported.Chain{Name: sourceChainName}) - }). - Then("should return error", errorWith(fmt.Sprintf("destination chain %s is not a registered chain", destinationChainName))). - Run(t) - - whenChainsAreRegistered. - When("address validator for destination chain is set", isCosmosChain(true)). - When("destination address is invalid", func() { - generalMessage.Receiver = rand.Str(20) - }). - Then("should return error", errorWith("decoding bech32 failed")). - Run(t) - - whenChainsAreRegistered. - When("address validator for destination chain is set", isCosmosChain(true)). - When("asset is not registered", isAssetRegistered(false)). - Then("should return error", errorWith("does not support foreign asset")). - Run(t) - - whenChainsAreRegistered. - When("address validator for destination chain is set", isCosmosChain(true)). - When("asset is registered", isAssetRegistered(true)). - Then("should succeed", func(t *testing.T) { - assert.NoError(t, k.SetNewMessage(ctx, generalMessage)) - }). - Run(t) -} diff --git a/x/nexus/keeper/keeper.go b/x/nexus/keeper/keeper.go index 580f6f02c..5f1fa5bf1 100644 --- a/x/nexus/keeper/keeper.go +++ b/x/nexus/keeper/keeper.go @@ -27,7 +27,6 @@ var ( chainMaintainerStatePrefix = key.RegisterStaticKey(types.ModuleName, 1) rateLimitPrefix = key.RegisterStaticKey(types.ModuleName, 2) transferEpochPrefix = key.RegisterStaticKey(types.ModuleName, 3) - generalMessagePrefix = key.RegisterStaticKey(types.ModuleName, 4) // temporary // TODO: add description about what temporary means diff --git a/x/nexus/keeper/keeper_test.go b/x/nexus/keeper/keeper_test.go index 72932a2c3..d27370b85 100644 --- a/x/nexus/keeper/keeper_test.go +++ b/x/nexus/keeper/keeper_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "strings" "testing" + "time" sdk "github.com/cosmos/cosmos-sdk/types" params "github.com/cosmos/cosmos-sdk/x/params/types" @@ -15,6 +16,7 @@ import ( "github.com/axelarnetwork/axelar-core/testutils" "github.com/axelarnetwork/axelar-core/testutils/fake" "github.com/axelarnetwork/axelar-core/testutils/rand" + "github.com/axelarnetwork/axelar-core/utils" axelarnet "github.com/axelarnetwork/axelar-core/x/axelarnet/exported" axelarnetkeeper "github.com/axelarnetwork/axelar-core/x/axelarnet/keeper" axelarnetTypes "github.com/axelarnetwork/axelar-core/x/axelarnet/types" @@ -26,6 +28,7 @@ import ( nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported" nexusKeeper "github.com/axelarnetwork/axelar-core/x/nexus/keeper" "github.com/axelarnetwork/axelar-core/x/nexus/types" + "github.com/axelarnetwork/utils/funcs" ) const maxAmount int64 = 100000000000 @@ -71,14 +74,26 @@ func TestLinkAddress(t *testing.T) { repeats := 20 var ctx sdk.Context - cfg := app.MakeEncodingConfig() - keeper, ctx = setup(cfg) - terra := nexus.Chain{Name: nexus.ChainName("terra"), Module: axelarnetTypes.ModuleName, SupportsForeignAssets: true} evmAddr := exported.CrossChainAddress{Chain: evm.Ethereum, Address: "0x68B93045fe7D8794a7cAF327e7f855CD6Cd03BB8"} axelarAddr := exported.CrossChainAddress{Chain: axelarnet.Axelarnet, Address: "axelar1t66w8cazua870wu7t2hsffndmy2qy2v556ymndnczs83qpz2h45sq6lq9w"} + setup := func() { + ctx = sdk.NewContext(fake.NewMultiStore(), tmproto.Header{}, false, log.TestingLogger()) + keeper.SetParams(ctx, types.DefaultParams()) + + // set chain + for _, chain := range []exported.Chain{evm.Ethereum, axelarnet.Axelarnet, terra} { + keeper.SetChain(ctx, chain) + keeper.ActivateChain(ctx, chain) + funcs.MustNoErr(keeper.RegisterAsset(ctx, chain, exported.NewAsset(axelarnet.NativeAsset, false), utils.MaxUint, time.Hour)) + } + + bankK.BlockedAddrFunc = func(addr sdk.AccAddress) bool { return false } + } + t.Run("should pass address validation", testutils.Func(func(t *testing.T) { + setup() err := keeper.LinkAddresses(ctx, evmAddr, exported.CrossChainAddress{Chain: axelarnet.Axelarnet, Address: "axelar1t66w8cazua870wu7t2hsffndmy2qy2v556ymndnczs83qpz2h45sq6lq9w"}, @@ -99,6 +114,8 @@ func TestLinkAddress(t *testing.T) { })) t.Run("should return error when linking invalid addresses", testutils.Func(func(t *testing.T) { + setup() + err := keeper.LinkAddresses(ctx, exported.CrossChainAddress{Chain: evm.Ethereum, Address: "0xZ8B93045fe7D8794a7cAF327e7f855CD6Cd03BB8"}, axelarAddr, @@ -113,6 +130,7 @@ func TestLinkAddress(t *testing.T) { })) t.Run("should return error for blocked addresses", testutils.Func(func(t *testing.T) { + setup() blockedAddr := rand.AccAddr() bankK.BlockedAddrFunc = func(addr sdk.AccAddress) bool { return addr.Equals(blockedAddr) } @@ -142,6 +160,7 @@ func TestLinkAddress(t *testing.T) { })) t.Run("should return error when link chain does not support foreign asset", testutils.Func(func(t *testing.T) { + setup() fromChain := nexus.Chain{ Name: nexus.ChainName(rand.Str(5)), SupportsForeignAssets: false, @@ -157,6 +176,7 @@ func TestLinkAddress(t *testing.T) { }).Repeat(repeats)) t.Run("successfully link", testutils.Func(func(t *testing.T) { + setup() sender, recipient := makeRandAddressesForChain(axelarnet.Axelarnet, evm.Ethereum) err := keeper.LinkAddresses(ctx, sender, recipient) assert.NoError(t, err) @@ -288,8 +308,6 @@ func genEvmAddr() string { } func genCosmosAddr(chain string) string { - defer sdk.GetConfig().SetBech32PrefixForAccount("axelar", "axelar") - prefix := "" switch strings.ToLower(chain) { case "axelarnet": @@ -297,7 +315,7 @@ func genCosmosAddr(chain string) string { case "terra", "terra-2": prefix = "terra" default: - prefix = chain + prefix = "" } sdk.GetConfig().SetBech32PrefixForAccount(prefix, prefix) diff --git a/x/nexus/keeper/transfer_test.go b/x/nexus/keeper/transfer_test.go index abfff5fd1..5bc3358d5 100644 --- a/x/nexus/keeper/transfer_test.go +++ b/x/nexus/keeper/transfer_test.go @@ -471,7 +471,6 @@ func TestTransfer(t *testing.T) { } func setup(cfg params.EncodingConfig) (nexusKeeper.Keeper, sdk.Context) { - sdk.GetConfig().SetBech32PrefixForAccount("axelar", "axelar") subspace := paramstypes.NewSubspace(cfg.Codec, cfg.Amino, sdk.NewKVStoreKey("nexusKey"), sdk.NewKVStoreKey("tNexusKey"), "nexus") k := nexusKeeper.NewKeeper(cfg.Codec, sdk.NewKVStoreKey(types.StoreKey), subspace) ctx := sdk.NewContext(fake.NewMultiStore(), tmproto.Header{}, false, log.TestingLogger())