From cfbe214e97a4d114016ee47ab77a0db8e587bafa Mon Sep 17 00:00:00 2001 From: John Letey Date: Tue, 17 Oct 2023 19:11:21 +0200 Subject: [PATCH] chore: remove router (#248) --- app/app.go | 27 +--- app/upgrades/argon/store.go | 3 +- app/upgrades/argon/upgrade.go | 6 - go.mod | 5 +- go.sum | 6 +- interchaintest/cctp_receive_message_test.go | 133 +----------------- .../cctp_receive_message_with_caller_test.go | 133 +----------------- .../cctp_replace_deposit_for_burn_test.go | 4 +- interchaintest/genesis_test.go | 12 -- interchaintest/go.mod | 3 +- interchaintest/go.sum | 6 +- testutil/network/network.go | 5 - 12 files changed, 16 insertions(+), 327 deletions(-) diff --git a/app/app.go b/app/app.go index 3b889f21..1dbe1213 100644 --- a/app/app.go +++ b/app/app.go @@ -112,9 +112,6 @@ import ( cctp "github.com/circlefin/noble-cctp/x/cctp" cctpkeeper "github.com/circlefin/noble-cctp/x/cctp/keeper" cctptypes "github.com/circlefin/noble-cctp/x/cctp/types" - router "github.com/strangelove-ventures/noble-router/x/router" - routerkeeper "github.com/strangelove-ventures/noble-router/x/router/keeper" - routertypes "github.com/strangelove-ventures/noble-router/x/router/types" ) const ( @@ -156,7 +153,6 @@ var ( globalfee.AppModuleBasic{}, tariff.AppModuleBasic{}, cctp.AppModuleBasic{}, - router.AppModuleBasic{}, paramauthorityibc.AppModuleBasic{}, ) @@ -234,7 +230,6 @@ type App struct { FiatTokenFactoryKeeper *fiattokenfactorymodulekeeper.Keeper TariffKeeper tariffkeeper.Keeper CCTPKeeper *cctpkeeper.Keeper - RouterKeeper *routerkeeper.Keeper // this line is used by starport scaffolding # stargate/app/keeperDeclaration @@ -273,7 +268,7 @@ func New( paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey, capabilitytypes.StoreKey, tokenfactorymoduletypes.StoreKey, fiattokenfactorymoduletypes.StoreKey, packetforwardtypes.StoreKey, stakingtypes.StoreKey, - cctptypes.StoreKey, routertypes.StoreKey, + cctptypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -474,25 +469,14 @@ func New( ) fiattokenfactorymodule := fiattokenfactorymodule.NewAppModule(appCodec, app.FiatTokenFactoryKeeper, app.AccountKeeper, app.BankKeeper) - app.RouterKeeper = routerkeeper.NewKeeper( - appCodec, - keys[routertypes.StoreKey], - app.GetSubspace(routertypes.ModuleName), - app.CCTPKeeper, - app.TransferKeeper, - ) - app.CCTPKeeper = cctpkeeper.NewKeeper( appCodec, keys[cctptypes.StoreKey], app.GetSubspace(cctptypes.ModuleName), app.BankKeeper, app.FiatTokenFactoryKeeper, - app.RouterKeeper, ) - app.RouterKeeper.SetCctpKeeper(app.CCTPKeeper) - var transferStack ibcporttypes.IBCModule transferStack = transfer.NewIBCModule(app.TransferKeeper) transferStack = packetforward.NewIBCMiddleware( @@ -502,7 +486,6 @@ func New( packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp, packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp, ) - transferStack = router.NewIBCMiddleware(transferStack, app.RouterKeeper) transferStack = blockibc.NewIBCMiddleware(transferStack, app.TokenFactoryKeeper, app.FiatTokenFactoryKeeper) // Create static IBC router, add transfer route, then set and seal it @@ -548,8 +531,7 @@ func New( staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), globalfee.NewAppModule(app.GetSubspace(globalfee.ModuleName)), tariff.NewAppModule(appCodec, app.TariffKeeper, app.AccountKeeper, app.BankKeeper), - cctp.NewAppModule(appCodec, app.CCTPKeeper), - router.NewAppModule(appCodec, app.RouterKeeper), + cctp.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.CCTPKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -581,7 +563,6 @@ func New( fiattokenfactorymoduletypes.ModuleName, globalfee.ModuleName, cctptypes.ModuleName, - routertypes.ModuleName, ) app.mm.SetOrderEndBlockers( @@ -608,7 +589,6 @@ func New( globalfee.ModuleName, tarifftypes.ModuleName, cctptypes.ModuleName, - routertypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -640,7 +620,6 @@ func New( fiattokenfactorymoduletypes.ModuleName, globalfee.ModuleName, cctptypes.ModuleName, - routertypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis ) @@ -881,7 +860,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(upgradetypes.ModuleName) paramsKeeper.Subspace(globalfee.ModuleName) paramsKeeper.Subspace(cctptypes.ModuleName) - paramsKeeper.Subspace(routertypes.ModuleName) // this line is used by starport scaffolding # stargate/app/paramSubspace return paramsKeeper @@ -925,7 +903,6 @@ func (app *App) setupUpgradeHandlers() { app.FiatTokenFactoryKeeper, app.ParamsKeeper, app.CCTPKeeper, - app.RouterKeeper, ), ) diff --git a/app/upgrades/argon/store.go b/app/upgrades/argon/store.go index 3ec3dc77..ded691c6 100644 --- a/app/upgrades/argon/store.go +++ b/app/upgrades/argon/store.go @@ -5,13 +5,12 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" storeTypes "github.com/cosmos/cosmos-sdk/store/types" upgradeTypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - routertypes "github.com/strangelove-ventures/noble-router/x/router/types" ) func CreateStoreLoader(upgradeHeight int64) baseapp.StoreLoader { storeUpgrades := storeTypes.StoreUpgrades{ Added: []string{ - cctptypes.ModuleName, routertypes.ModuleName, + cctptypes.ModuleName, }, } diff --git a/app/upgrades/argon/upgrade.go b/app/upgrades/argon/upgrade.go index 0b55f5c3..8c755641 100644 --- a/app/upgrades/argon/upgrade.go +++ b/app/upgrades/argon/upgrade.go @@ -9,8 +9,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradeTypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - routerkeeper "github.com/strangelove-ventures/noble-router/x/router/keeper" - routertypes "github.com/strangelove-ventures/noble-router/x/router/types" fiattokenfactorykeeper "github.com/strangelove-ventures/noble/x/fiattokenfactory/keeper" paramauthoritykeeper "github.com/strangelove-ventures/paramauthority/x/params/keeper" ) @@ -21,7 +19,6 @@ func CreateUpgradeHandler( fiatTFKeeper *fiattokenfactorykeeper.Keeper, paramauthoritykeeper paramauthoritykeeper.Keeper, cctpKeeper *cctpkeeper.Keeper, - routerKeeper *routerkeeper.Keeper, ) upgradeTypes.UpgradeHandler { return func(ctx sdk.Context, _ upgradeTypes.Plan, vm module.VersionMap) (module.VersionMap, error) { var cctpAuthority string @@ -49,9 +46,6 @@ func CreateUpgradeHandler( cctpKeeper.SetMaxMessageBodySize(ctx, cctptypes.MaxMessageBodySize{Amount: 8000}) cctpKeeper.SetSignatureThreshold(ctx, cctptypes.SignatureThreshold{Amount: 2}) - routerKeeper.SetOwner(ctx, paramAuthority) - routerKeeper.SetParams(ctx, routertypes.DefaultParams()) - return mm.RunMigrations(ctx, configurator, vm) } } diff --git a/go.mod b/go.mod index 6b046a91..c74fbf06 100644 --- a/go.mod +++ b/go.mod @@ -2,12 +2,12 @@ module github.com/strangelove-ventures/noble go 1.21 -toolchain go1.21.1 +toolchain go1.21.3 require ( cosmossdk.io/errors v1.0.0 cosmossdk.io/math v1.0.1 - github.com/circlefin/noble-cctp v0.0.0-20230925203250-4d2482bd0d7c + github.com/circlefin/noble-cctp v0.0.0-20231013164358-dc81b3e0d566 github.com/cosmos/cosmos-sdk v0.45.16 github.com/cosmos/ibc-go/v3 v3.4.0 github.com/gogo/protobuf v1.3.3 @@ -17,7 +17,6 @@ require ( github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 - github.com/strangelove-ventures/noble-router v1.0.0 github.com/strangelove-ventures/packet-forward-middleware/v3 v3.1.5 github.com/strangelove-ventures/paramauthority v1.0.0 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index dc6be6f6..de7b7e2a 100644 --- a/go.sum +++ b/go.sum @@ -183,8 +183,8 @@ github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/circlefin/noble-cctp v0.0.0-20230925203250-4d2482bd0d7c h1:RwSIc6O1bcBkfpOMrBF08xpctcwkVDxAQCIRlOHyg0U= -github.com/circlefin/noble-cctp v0.0.0-20230925203250-4d2482bd0d7c/go.mod h1:kTaX51dOT10LBoERZYT1ahuove3dL/+q5IagWQUABd0= +github.com/circlefin/noble-cctp v0.0.0-20231013164358-dc81b3e0d566 h1:PUo/InK7onrx6gt1aMfng5nBRIqKf523coNYhFvexmc= +github.com/circlefin/noble-cctp v0.0.0-20231013164358-dc81b3e0d566/go.mod h1:kTaX51dOT10LBoERZYT1ahuove3dL/+q5IagWQUABd0= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= @@ -950,8 +950,6 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.14.0 h1:Rg7d3Lo706X9tHsJMUjdiwMpHB7W8WnSVOssIY+JElU= github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= -github.com/strangelove-ventures/noble-router v1.0.0 h1:YvBivqz/qpXLom8MpghbjYoRCYavnCmhwQDDmg2V6Po= -github.com/strangelove-ventures/noble-router v1.0.0/go.mod h1:zYp/EROBOZh//YJiAVTeiWEmjwsSWdp0iGvksSI93YY= github.com/strangelove-ventures/packet-forward-middleware/v3 v3.1.5 h1:iXXjziCSAebzuRUPFSnqD7epSDB8LEPgkh9zhbj7ha4= github.com/strangelove-ventures/packet-forward-middleware/v3 v3.1.5/go.mod h1:ncgsf5rykh36HkM16BNcKKx1XzVRdWXt+4pph1syDHE= github.com/strangelove-ventures/paramauthority v1.0.0 h1:kgWsSfkiBh25ZZyt/ZQUwXEVdFknX9YIdEWDm1X7AWg= diff --git a/interchaintest/cctp_receive_message_test.go b/interchaintest/cctp_receive_message_test.go index 329d9bfb..9cb1aa7c 100644 --- a/interchaintest/cctp_receive_message_test.go +++ b/interchaintest/cctp_receive_message_test.go @@ -17,15 +17,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/bech32" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/strangelove-ventures/interchaintest/v3" "github.com/strangelove-ventures/interchaintest/v3/chain/cosmos" - "github.com/strangelove-ventures/interchaintest/v3/ibc" "github.com/strangelove-ventures/interchaintest/v3/testreporter" - "github.com/strangelove-ventures/interchaintest/v3/testutil" - routertypes "github.com/strangelove-ventures/noble-router/x/router/types" "github.com/strangelove-ventures/noble/cmd" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" @@ -53,12 +49,6 @@ func TestCCTP_ReceiveMessage(t *testing.T) { cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ nobleChainSpec(ctx, &gw, "noble-1", nv, nf, true, false, true, false), - { - Name: "gaia", - Version: "v10.0.2", - NumValidators: &nv, - NumFullNodes: &nf, - }, }) chains, err := cf.Chains(t.Name()) @@ -66,26 +56,8 @@ func TestCCTP_ReceiveMessage(t *testing.T) { gw.chain = chains[0].(*cosmos.CosmosChain) noble := gw.chain - gaia := chains[1].(*cosmos.CosmosChain) - - r := interchaintest.NewBuiltinRelayerFactory( - ibc.CosmosRly, - zaptest.NewLogger(t), - relayerImage, - ).Build(t, client, network) - - pathName := "noble-gaia" - - ic := interchaintest.NewInterchain(). - AddChain(noble). - AddChain(gaia). - AddRelayer(r, "r"). - AddLink(interchaintest.InterchainLink{ - Chain1: noble, - Chain2: gaia, - Relayer: r, - Path: pathName, - }) + + ic := interchaintest.NewInterchain().AddChain(noble) require.NoError(t, ic.Build(ctx, eRep, interchaintest.InterchainBuildOptions{ TestName: t.Name(), @@ -100,7 +72,6 @@ func TestCCTP_ReceiveMessage(t *testing.T) { }) nobleChainCfg := noble.Config() - gaiaChainCfg := gaia.Config() cmd.SetPrefixes(nobleChainCfg.Bech32Prefix) @@ -157,24 +128,9 @@ func TestCCTP_ReceiveMessage(t *testing.T) { t.Logf("Submitted add public keys tx: %s", tx.TxHash) - var senderForward = []byte("12345678901234567890123456789015") - bCtx, bCancel = context.WithTimeout(ctx, 20*time.Second) defer bCancel() - tx, err = cosmos.BroadcastTx( - bCtx, - broadcaster, - gw.paramAuthority, - &routertypes.MsgAddAllowedSourceDomainSender{ - From: gw.paramAuthority.FormattedAddress(), - DomainId: 0, - Address: senderForward, - }, - ) - require.NoError(t, err, "error submitting add allowed source domain sender tx") - require.Zero(t, tx.Code, "cctp add allowed source domain sender transaction failed: %s - %s - %s", tx.Codespace, tx.RawLog, tx.Data) - nobleValidator := noble.Validators[0] cctpModuleAccount := authtypes.NewModuleAddress(cctptypes.ModuleName).String() @@ -197,9 +153,6 @@ func TestCCTP_ReceiveMessage(t *testing.T) { nobleReceiver, err := bech32.ConvertAndEncode(nobleChainCfg.Bech32Prefix, receiverBz) require.NoError(t, err) - gaiaReceiver, err := bech32.ConvertAndEncode(gaiaChainCfg.Bech32Prefix, receiverBz) - require.NoError(t, err) - burnRecipientPadded := append([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, receiverBz...) // someone burned USDC on Ethereum -> Mint on Noble @@ -231,35 +184,9 @@ func TestCCTP_ReceiveMessage(t *testing.T) { wrappedDepositForBurnBz, err := wrappedDepositForBurn.Bytes() require.NoError(t, err) - // in mainnet this would forward to dydx chain - forward := routertypes.IBCForwardMetadata{ - Port: "transfer", - Channel: "channel-0", - DestinationReceiver: gaiaReceiver, - } - - forwardBz, err := forward.Bytes(gaiaChainCfg.Bech32Prefix) - require.NoError(t, err) - - wrappedForward := cctptypes.Message{ - Version: 0, - SourceDomain: 0, // same source domain ! - DestinationDomain: 4, - Nonce: 1, // cant be same nonce as above - Sender: senderForward, // different sender ! - Recipient: burnRecipientPadded, - DestinationCaller: emptyDestinationCaller, - MessageBody: forwardBz, - } - - wrappedForwardBz, err := wrappedForward.Bytes() - require.NoError(t, err) - digestBurn := crypto.Keccak256(wrappedDepositForBurnBz) // hashed message is the key to the attestation - digestForward := crypto.Keccak256(wrappedForwardBz) attestationBurn := make([]byte, 0, len(attesters)*65) //65 byte - attestationForward := make([]byte, 0, len(attesters)*65) // CCTP requires attestations to have signatures sorted by address sort.Slice(attesters, func(i, j int) bool { @@ -274,11 +201,6 @@ func TestCCTP_ReceiveMessage(t *testing.T) { require.NoError(t, err) attestationBurn = append(attestationBurn, sig...) - - sig, err = crypto.Sign(digestForward, attesters[i]) - require.NoError(t, err) - - attestationForward = append(attestationForward, sig...) } t.Logf("Attested to messages: %s", tx.TxHash) @@ -304,55 +226,4 @@ func TestCCTP_ReceiveMessage(t *testing.T) { require.NoError(t, err) require.Equal(t, int64(1000000), balance) - - err = r.StartRelayer(ctx, eRep, pathName) - require.NoError(t, err) - t.Cleanup(func() { - _ = r.StopRelayer(ctx, eRep) - }) - - bCtx, bCancel = context.WithTimeout(ctx, 20*time.Second) - defer bCancel() - tx, err = cosmos.BroadcastTx( - bCtx, - broadcaster, - gw.fiatTfRoles.Owner, - &cctptypes.MsgReceiveMessage{ - From: gw.fiatTfRoles.Owner.FormattedAddress(), - Message: wrappedForwardBz, - Attestation: attestationForward, - }, - ) - - require.NoError(t, err, "error submitting cctp forward recv tx") - require.Zerof(t, tx.Code, "cctp forward recv transaction failed: %s - %s - %s", tx.Codespace, tx.RawLog, tx.Data) - - t.Logf("CCTP IBC forward message successfully received: %s", tx.TxHash) - - err = testutil.WaitForBlocks(ctx, 10, noble, gaia) - require.NoError(t, err) - - srcDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", denomMetadataDrachma.Base)) - dstIbcDenom := srcDenomTrace.IBCDenom() - - gaiaBal, err := gaia.GetBalance(ctx, gaiaReceiver, dstIbcDenom) - require.NoError(t, err) - require.Equal(t, int64(999900), gaiaBal) - - // now test deposit for burn noble -> eth - - // gaia.Validators[0].CreateKey(ctx, "my_key") - - // send ibc tx back to noble - // gaia.Validators[0].SendIBCTransfer(ctx, "channel-0", ) - - // depositForBurnNoble := &cctptypes.MsgDepositForBurn{ - // BurnToken:uusdc - // Amount: cosmossdk_io_math.NewInt(1000000), - // } - - // broad cast... take tx.. - // tx.event - - // make sure balance went down } diff --git a/interchaintest/cctp_receive_message_with_caller_test.go b/interchaintest/cctp_receive_message_with_caller_test.go index 7c2d039d..5b4c57c2 100644 --- a/interchaintest/cctp_receive_message_with_caller_test.go +++ b/interchaintest/cctp_receive_message_with_caller_test.go @@ -17,15 +17,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/bech32" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/strangelove-ventures/interchaintest/v3" "github.com/strangelove-ventures/interchaintest/v3/chain/cosmos" - "github.com/strangelove-ventures/interchaintest/v3/ibc" "github.com/strangelove-ventures/interchaintest/v3/testreporter" - "github.com/strangelove-ventures/interchaintest/v3/testutil" - routertypes "github.com/strangelove-ventures/noble-router/x/router/types" "github.com/strangelove-ventures/noble/cmd" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" @@ -53,12 +49,6 @@ func TestCCTP_ReceiveMessageWithCaller(t *testing.T) { cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ nobleChainSpec(ctx, &gw, "noble-1", nv, nf, true, false, true, false), - { - Name: "gaia", - Version: "v10.0.2", - NumValidators: &nv, - NumFullNodes: &nf, - }, }) chains, err := cf.Chains(t.Name()) @@ -66,26 +56,8 @@ func TestCCTP_ReceiveMessageWithCaller(t *testing.T) { gw.chain = chains[0].(*cosmos.CosmosChain) noble := gw.chain - gaia := chains[1].(*cosmos.CosmosChain) - - r := interchaintest.NewBuiltinRelayerFactory( - ibc.CosmosRly, - zaptest.NewLogger(t), - relayerImage, - ).Build(t, client, network) - - pathName := "noble-gaia" - - ic := interchaintest.NewInterchain(). - AddChain(noble). - AddChain(gaia). - AddRelayer(r, "r"). - AddLink(interchaintest.InterchainLink{ - Chain1: noble, - Chain2: gaia, - Relayer: r, - Path: pathName, - }) + + ic := interchaintest.NewInterchain().AddChain(noble) require.NoError(t, ic.Build(ctx, eRep, interchaintest.InterchainBuildOptions{ TestName: t.Name(), @@ -100,7 +72,6 @@ func TestCCTP_ReceiveMessageWithCaller(t *testing.T) { }) nobleChainCfg := noble.Config() - gaiaChainCfg := gaia.Config() cmd.SetPrefixes(nobleChainCfg.Bech32Prefix) @@ -157,24 +128,9 @@ func TestCCTP_ReceiveMessageWithCaller(t *testing.T) { t.Logf("Submitted add public keys tx: %s", tx.TxHash) - var senderForward = []byte("12345678901234567890123456789015") - bCtx, bCancel = context.WithTimeout(ctx, 20*time.Second) defer bCancel() - tx, err = cosmos.BroadcastTx( - bCtx, - broadcaster, - gw.paramAuthority, - &routertypes.MsgAddAllowedSourceDomainSender{ - From: gw.paramAuthority.FormattedAddress(), - DomainId: 0, - Address: senderForward, - }, - ) - require.NoError(t, err, "error submitting add allowed source domain sender tx") - require.Zero(t, tx.Code, "cctp add allowed source domain sender transaction failed: %s - %s - %s", tx.Codespace, tx.RawLog, tx.Data) - nobleValidator := noble.Validators[0] cctpModuleAccount := authtypes.NewModuleAddress(cctptypes.ModuleName).String() @@ -197,9 +153,6 @@ func TestCCTP_ReceiveMessageWithCaller(t *testing.T) { nobleReceiver, err := bech32.ConvertAndEncode(nobleChainCfg.Bech32Prefix, receiverBz) require.NoError(t, err) - gaiaReceiver, err := bech32.ConvertAndEncode(gaiaChainCfg.Bech32Prefix, receiverBz) - require.NoError(t, err) - burnRecipientPadded := append([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, receiverBz...) // someone burned USDC on Ethereum -> Mint on Noble @@ -232,35 +185,9 @@ func TestCCTP_ReceiveMessageWithCaller(t *testing.T) { wrappedDepositForBurnBz, err := wrappedDepositForBurn.Bytes() require.NoError(t, err) - // in mainnet this would forward to dydx chain - forward := routertypes.IBCForwardMetadata{ - Port: "transfer", - Channel: "channel-0", - DestinationReceiver: gaiaReceiver, - } - - forwardBz, err := forward.Bytes(gaiaChainCfg.Bech32Prefix) - require.NoError(t, err) - - wrappedForward := cctptypes.Message{ - Version: 0, - SourceDomain: 0, // same source domain ! - DestinationDomain: 4, - Nonce: 1, // cant be same nonce as above - Sender: senderForward, // different sender ! - Recipient: burnRecipientPadded, - DestinationCaller: destinationCaller, - MessageBody: forwardBz, - } - - wrappedForwardBz, err := wrappedForward.Bytes() - require.NoError(t, err) - digestBurn := crypto.Keccak256(wrappedDepositForBurnBz) // hashed message is the key to the attestation - digestForward := crypto.Keccak256(wrappedForwardBz) attestationBurn := make([]byte, 0, len(attesters)*65) //65 byte - attestationForward := make([]byte, 0, len(attesters)*65) // CCTP requires attestations to have signatures sorted by address sort.Slice(attesters, func(i, j int) bool { @@ -275,11 +202,6 @@ func TestCCTP_ReceiveMessageWithCaller(t *testing.T) { require.NoError(t, err) attestationBurn = append(attestationBurn, sig...) - - sig, err = crypto.Sign(digestForward, attesters[i]) - require.NoError(t, err) - - attestationForward = append(attestationForward, sig...) } t.Logf("Attested to messages: %s", tx.TxHash) @@ -305,55 +227,4 @@ func TestCCTP_ReceiveMessageWithCaller(t *testing.T) { require.NoError(t, err) require.Equal(t, int64(1000000), balance) - - err = r.StartRelayer(ctx, eRep, pathName) - require.NoError(t, err) - t.Cleanup(func() { - _ = r.StopRelayer(ctx, eRep) - }) - - bCtx, bCancel = context.WithTimeout(ctx, 20*time.Second) - defer bCancel() - tx, err = cosmos.BroadcastTx( - bCtx, - broadcaster, - gw.fiatTfRoles.Owner, - &cctptypes.MsgReceiveMessage{ - From: gw.fiatTfRoles.Owner.FormattedAddress(), - Message: wrappedForwardBz, - Attestation: attestationForward, - }, - ) - - require.NoError(t, err, "error submitting cctp forward recv tx") - require.Zerof(t, tx.Code, "cctp forward recv transaction failed: %s - %s - %s", tx.Codespace, tx.RawLog, tx.Data) - - t.Logf("CCTP IBC forward message successfully received: %s", tx.TxHash) - - err = testutil.WaitForBlocks(ctx, 10, noble, gaia) - require.NoError(t, err) - - srcDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", denomMetadataDrachma.Base)) - dstIbcDenom := srcDenomTrace.IBCDenom() - - gaiaBal, err := gaia.GetBalance(ctx, gaiaReceiver, dstIbcDenom) - require.NoError(t, err) - require.Equal(t, int64(999900), gaiaBal) - - // now test deposit for burn noble -> eth - - // gaia.Validators[0].CreateKey(ctx, "my_key") - - // send ibc tx back to noble - // gaia.Validators[0].SendIBCTransfer(ctx, "channel-0", ) - - // depositForBurnNoble := &cctptypes.MsgDepositForBurn{ - // BurnToken: "is this the sam as coming from e TRY UUSDC", - // Amount: cosmossdk_io_math.NewInt(1000000), - // } - - // broad cast... take tx.. - // tx.event - - // make sure balance went down } diff --git a/interchaintest/cctp_replace_deposit_for_burn_test.go b/interchaintest/cctp_replace_deposit_for_burn_test.go index 3bfce0ab..aed03e59 100644 --- a/interchaintest/cctp_replace_deposit_for_burn_test.go +++ b/interchaintest/cctp_replace_deposit_for_burn_test.go @@ -178,7 +178,7 @@ func TestCCTP_ReplaceDepositForBurn(t *testing.T) { SourceDomain: 4, // noble is 4 DestinationDomain: 0, Nonce: 0, // dif per message - Sender: messageSender, + Sender: cctptypes.PaddedModuleAddress, Recipient: cctptypes.PaddedModuleAddress, DestinationCaller: emptyDestinationCaller, MessageBody: depositForBurnBz, @@ -267,7 +267,7 @@ func TestCCTP_ReplaceDepositForBurn(t *testing.T) { require.Equal(t, wrappedDepositForBurn.SourceDomain, message.SourceDomain) require.Equal(t, wrappedDepositForBurn.DestinationDomain, message.DestinationDomain) require.Equal(t, wrappedDepositForBurn.Nonce, message.Nonce) - require.True(t, bytes.Equal(messageSender, message.Sender)) + require.Equal(t, cctptypes.PaddedModuleAddress, message.Sender) require.Equal(t, cctptypes.PaddedModuleAddress, message.Recipient) require.Equal(t, newDestCaller, message.DestinationCaller) diff --git a/interchaintest/genesis_test.go b/interchaintest/genesis_test.go index 4a98701e..be7897fa 100644 --- a/interchaintest/genesis_test.go +++ b/interchaintest/genesis_test.go @@ -494,10 +494,6 @@ func modifyGenesisAll(gw *genesisWrapper, minSetupTf, minSetupFiatTf bool) func( return nil, err } - if err := modifyGenesisRouter(g, authority); err != nil { - return nil, err - } - out, err := json.Marshal(&g) if err != nil { return nil, fmt.Errorf("failed to marshal genesis bytes to json: %w", err) @@ -596,14 +592,6 @@ func modifyGenesisCCTP(genbz map[string]interface{}, authority string) error { return nil } -func modifyGenesisRouter(genbz map[string]interface{}, authority string) error { - if err := dyno.Set(genbz, authority, "app_state", "router", "owner"); err != nil { - return fmt.Errorf("failed to set cctp authority address in genesis json: %w", err) - } - - return nil -} - func modifyGenesisTariffDefaults( genbz map[string]interface{}, distributionEntity string, diff --git a/interchaintest/go.mod b/interchaintest/go.mod index b03cf354..92ff4244 100644 --- a/interchaintest/go.mod +++ b/interchaintest/go.mod @@ -4,14 +4,13 @@ go 1.21 require ( cosmossdk.io/math v1.0.1 - github.com/circlefin/noble-cctp v0.0.0-20230925203250-4d2482bd0d7c + github.com/circlefin/noble-cctp v0.0.0-20231013164358-dc81b3e0d566 github.com/cosmos/cosmos-sdk v0.45.16 github.com/cosmos/ibc-go/v3 v3.4.0 github.com/ethereum/go-ethereum v1.12.2 github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845 github.com/strangelove-ventures/interchaintest/v3 v3.0.0-20230622221919-28c608364e27 github.com/strangelove-ventures/noble v1.0.1-0.20230717234609-400609f26a31 - github.com/strangelove-ventures/noble-router v1.0.0 github.com/strangelove-ventures/paramauthority v1.0.0 github.com/stretchr/testify v1.8.4 go.uber.org/zap v1.24.0 diff --git a/interchaintest/go.sum b/interchaintest/go.sum index bec52278..99cf75ec 100644 --- a/interchaintest/go.sum +++ b/interchaintest/go.sum @@ -189,8 +189,8 @@ github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/circlefin/noble-cctp v0.0.0-20230925203250-4d2482bd0d7c h1:RwSIc6O1bcBkfpOMrBF08xpctcwkVDxAQCIRlOHyg0U= -github.com/circlefin/noble-cctp v0.0.0-20230925203250-4d2482bd0d7c/go.mod h1:kTaX51dOT10LBoERZYT1ahuove3dL/+q5IagWQUABd0= +github.com/circlefin/noble-cctp v0.0.0-20231013164358-dc81b3e0d566 h1:PUo/InK7onrx6gt1aMfng5nBRIqKf523coNYhFvexmc= +github.com/circlefin/noble-cctp v0.0.0-20231013164358-dc81b3e0d566/go.mod h1:kTaX51dOT10LBoERZYT1ahuove3dL/+q5IagWQUABd0= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= @@ -1003,8 +1003,6 @@ github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jH github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= github.com/strangelove-ventures/interchaintest/v3 v3.0.0-20230622221919-28c608364e27 h1:oJ9yZIFp3yRTlH8BOLnACrsjR1fPIpHyOoLFjM5VRBc= github.com/strangelove-ventures/interchaintest/v3 v3.0.0-20230622221919-28c608364e27/go.mod h1:dWv7E8XtgidmA/A5Gy9x76qMIygES+SxPTnlWjYUb7g= -github.com/strangelove-ventures/noble-router v1.0.0 h1:YvBivqz/qpXLom8MpghbjYoRCYavnCmhwQDDmg2V6Po= -github.com/strangelove-ventures/noble-router v1.0.0/go.mod h1:zYp/EROBOZh//YJiAVTeiWEmjwsSWdp0iGvksSI93YY= github.com/strangelove-ventures/paramauthority v1.0.0 h1:kgWsSfkiBh25ZZyt/ZQUwXEVdFknX9YIdEWDm1X7AWg= github.com/strangelove-ventures/paramauthority v1.0.0/go.mod h1:31HVpoItQMa4Wj2BimVhQWbIYeb+kdUDJ8MzBEbGj28= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= diff --git a/testutil/network/network.go b/testutil/network/network.go index 2f9e9aea..7100bd9e 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -24,7 +24,6 @@ import ( paramstypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - routertypes "github.com/strangelove-ventures/noble-router/x/router/types" "github.com/strangelove-ventures/noble/app" "github.com/strangelove-ventures/noble/cmd" "github.com/strangelove-ventures/noble/testutil/sample" @@ -104,10 +103,6 @@ func DefaultConfig() network.Config { upgrade.Params.Authority = sample.AccAddress() cfg.GenesisState[upgradetypes.ModuleName] = encoding.Marshaler.MustMarshalJSON(upgrade) - router := routertypes.DefaultGenesis() - router.Owner = params.Params.Authority - cfg.GenesisState[routertypes.ModuleName] = encoding.Marshaler.MustMarshalJSON(router) - cctp := cctptypes.DefaultGenesis() cctp.Owner = sample.AccAddress() cctp.AttesterManager = sample.AccAddress()