From 43b6d7a63acacb1e71ff32f6b95e070b226b24b2 Mon Sep 17 00:00:00 2001 From: Trinity Date: Fri, 19 Apr 2024 17:39:26 +0700 Subject: [PATCH 01/61] add disconnection test --- .github/workflows/e2e-test-workflow-call.yml | 1 + .github/workflows/e2e_test.yml | 1 + Makefile | 3 + go.mod | 2 +- go.sum | 4 +- tests/disconnection_test.go | 185 +++++++++++++++++++ 6 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 tests/disconnection_test.go diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index fd76d7c6..4f424a78 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -30,6 +30,7 @@ jobs: - "e2e-test-transfer-multi-hop-evm" - "e2e-test-pfm-with-grace-period-evm" - "e2e-test-batch-finalization-evm" + - "e2e-test-disconnection-evm" - "e2e-test-rollapp-freeze-evm" - "e2e-test-other-rollapp-not-affected-evm" - "e2e-test-rollapp-genesis-event-evm" diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index e505b598..1673d511 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -32,6 +32,7 @@ jobs: - "e2e-test-transfer-multi-hop-evm" - "e2e-test-pfm-with-grace-period-evm" - "e2e-test-batch-finalization-evm" + - "e2e-test-disconnection-evm" - "e2e-test-rollapp-freeze-evm" - "e2e-test-other-rollapp-not-affected-evm" - "e2e-test-rollapp-genesis-event-evm" diff --git a/Makefile b/Makefile index 29b5cb04..0eb201d2 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ e2e-test-pfm-with-grace-period-evm: clean-e2e e2e-test-batch-finalization-evm: cd tests && go test -timeout=25m -race -v -run TestBatchFinalization_EVM . +e2e-test-disconnection-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestDisconnection_EVM . + e2e-test-rollapp-freeze-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollAppFreeze_EVM . diff --git a/go.mod b/go.mod index 681fe9b9..25c11298 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( cosmossdk.io/math v1.3.0 github.com/cosmos/cosmos-sdk v0.46.16 github.com/cosmos/ibc-go/v6 v6.2.1 - github.com/decentrio/rollup-e2e-testing v0.0.0-20240416082427-7fa3587bcf91 + github.com/decentrio/rollup-e2e-testing v0.0.0-20240419100059-4be856e59619 github.com/dymensionxyz/dymension-rdk v1.1.0-beta github.com/dymensionxyz/dymension/v3 v3.1.0-rc01.0.20240404003005-53ccf8a922fd github.com/evmos/ethermint v0.22.0 diff --git a/go.sum b/go.sum index a56458b3..a0d990cb 100644 --- a/go.sum +++ b/go.sum @@ -328,8 +328,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240416082427-7fa3587bcf91 h1:HlW38l78RMd7+XFF7IxsVzirI+vy2kQi+Z6bRSeU2Uk= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240416082427-7fa3587bcf91/go.mod h1:Hy/8P41OEKrlAatPG5NcD/BOWTa2s+laECwpZpmA9f0= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240419100059-4be856e59619 h1:g+dXAUOIukmrMSiA6CgZTLbTjTbSIpIuWvYu6Nf7Ugo= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240419100059-4be856e59619/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go new file mode 100644 index 00000000..cde65ebe --- /dev/null +++ b/tests/disconnection_test.go @@ -0,0 +1,185 @@ +package tests + +import ( + "context" + "fmt" + "testing" + "time" + + "cosmossdk.io/math" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" + + test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" +) + +func TestDisconnection_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppVals := 1 + numRollAppFn := 0 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + walletAmount := math.NewInt(1_000_000_000_000) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, _ := users[0], users[1] + + // IBC channel for rollapps + channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym, 1) + + channelDymRollapp := channsDym[0].ChannelID + + triggerHubGenesisEvent(t, dymension, rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channelDymRollapp, + userKey: dymensionUser.KeyName(), + }) + + // Wait for rollapp finalized + rollapp1Height, err := rollapp1.Height(ctx) + require.NoError(t, err) + dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 300) + + t.Run("hub disconnect", func(t *testing.T) { + err = dymension.StopAllNodes(ctx) + require.NoError(t, err) + + rollappHeight, err := rollapp1.Height(ctx) + require.NoError(t, err) + + time.Sleep(time.Minute) + + newRollappHeight, err := rollapp1.Height(ctx) + require.NoError(t, err) + + require.Equal(t, rollappHeight, newRollappHeight) + + err = dymension.StartAllNodes(ctx) + require.NoError(t, err) + + // Make sure rollapp start pro + err = testutil.WaitForBlocks(ctx, 1, rollapp1) + require.NoError(t, err) + }) +} From d32e65aaa9a5e4b8ec413b13604d89045b945d6b Mon Sep 17 00:00:00 2001 From: Trinity Date: Mon, 22 Apr 2024 15:06:17 +0700 Subject: [PATCH 02/61] fix disconnection test --- tests/disconnection_test.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index cde65ebe..2ea19ebd 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -165,15 +165,26 @@ func TestDisconnection_EVM(t *testing.T) { err = dymension.StopAllNodes(ctx) require.NoError(t, err) + // Wait until rollapp stops produce block rollappHeight, err := rollapp1.Height(ctx) require.NoError(t, err) - time.Sleep(time.Minute) + err = testutil.WaitForCondition( + time.Minute*5, + time.Second*5, + func() (bool, error) { + newRollappHeight, err := rollapp1.Height(ctx) + require.NoError(t, err) - newRollappHeight, err := rollapp1.Height(ctx) - require.NoError(t, err) + if newRollappHeight > rollappHeight { + rollappHeight = newRollappHeight + return false, nil + } - require.Equal(t, rollappHeight, newRollappHeight) + return true, nil + }, + ) + require.NoError(t, err) err = dymension.StartAllNodes(ctx) require.NoError(t, err) From 9a23669244efa0d3f38720c09f346079b591151a Mon Sep 17 00:00:00 2001 From: Trinity Date: Mon, 22 Apr 2024 17:41:30 +0700 Subject: [PATCH 03/61] fix disconnection test --- tests/disconnection_test.go | 94 ++++++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 16 deletions(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index 2ea19ebd..716d738d 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -2,15 +2,18 @@ package tests import ( "context" + "encoding/json" "fmt" "testing" "time" "cosmossdk.io/math" + "github.com/icza/dyno" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" @@ -41,24 +44,83 @@ func TestDisconnection_EVM(t *testing.T) { numRollAppVals := 1 numRollAppFn := 0 + customGenesisKV := append(rollappEVMGenesisKV, cosmos.GenesisKV{ + Key: "app_state.incentives.params.distr_epoch_identifier", + Value: "custom", + }) + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", ChainConfig: ibc.ChainConfig{ - Type: "rollapp-dym", - Name: "rollapp-temp", - ChainID: "rollappevm_1234-1", - Images: []ibc.DockerImage{rollappEVMImage}, - Bin: "rollappd", - Bech32Prefix: "ethm", - Denom: "urax", - CoinType: "60", - GasPrices: "0.0urax", - GasAdjustment: 1.1, - TrustingPeriod: "112h", - EncodingConfig: encodingConfig(), - NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + // Custom genesis to make the epoch last 5 seconds + ModifyGenesis: func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { + g := make(map[string]interface{}) + if err := json.Unmarshal(inputGenBz, &g); err != nil { + return nil, fmt.Errorf("failed to unmarshal genesis file: %w", err) + } + + epochData, err := dyno.Get(g, "app_state", "epochs", "epochs") + if err != nil { + return nil, fmt.Errorf("failed to retrieve epochs: %w", err) + } + epochs := epochData.([]interface{}) + exist := false + // Check if the "minute" identifier already exists + for _, epoch := range epochs { + if epochMap, ok := epoch.(map[string]interface{}); ok { + if epochMap["identifier"] == "custom" { + exist = true + } + } + } + if !exist { + // Define the new epoch type to be added + newEpochType := map[string]interface{}{ + "identifier": "custom", + "start_time": "0001-01-01T00:00:00Z", + "duration": "5s", + "current_epoch": "0", + "current_epoch_start_time": "0001-01-01T00:00:00Z", + "epoch_counting_started": false, + "current_epoch_start_height": "0", + } + + // Add the new epoch to the epochs array + updatedEpochs := append(epochs, newEpochType) + if err := dyno.Set(g, updatedEpochs, "app_state", "epochs", "epochs"); err != nil { + return nil, fmt.Errorf("failed to set epochs in genesis json: %w", err) + } + } + if err := dyno.Set(g, "adym", "app_state", "gov", "deposit_params", "min_deposit", 0, "denom"); err != nil { + return nil, fmt.Errorf("failed to set denom on gov min_deposit in genesis json: %w", err) + } + if err := dyno.Set(g, "10000000000", "app_state", "gov", "deposit_params", "min_deposit", 0, "amount"); err != nil { + return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) + } + if err := dyno.Set(g, "adym", "app_state", "gamm", "params", "pool_creation_fee", 0, "denom"); err != nil { + return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) + } + outputGenBz, err := json.Marshal(g) + if err != nil { + return nil, fmt.Errorf("failed to marshal genesis bytes to json: %w", err) + } + + return cosmos.ModifyGenesis(customGenesisKV)(chainConfig, outputGenBz) + }, ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -170,8 +232,8 @@ func TestDisconnection_EVM(t *testing.T) { require.NoError(t, err) err = testutil.WaitForCondition( - time.Minute*5, - time.Second*5, + time.Minute*10, + time.Second*5, // each epoch is 5 seconds func() (bool, error) { newRollappHeight, err := rollapp1.Height(ctx) require.NoError(t, err) From 50006398201502f108046f26d04e9f2a1e343080 Mon Sep 17 00:00:00 2001 From: Trinity Date: Mon, 22 Apr 2024 17:51:37 +0700 Subject: [PATCH 04/61] custom dymension epoch for faster disconnection --- tests/disconnection_test.go | 151 +++++++++++++++++++----------------- 1 file changed, 78 insertions(+), 73 deletions(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index 716d738d..17b705d7 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -44,83 +44,88 @@ func TestDisconnection_EVM(t *testing.T) { numRollAppVals := 1 numRollAppFn := 0 - customGenesisKV := append(rollappEVMGenesisKV, cosmos.GenesisKV{ - Key: "app_state.incentives.params.distr_epoch_identifier", - Value: "custom", - }) + // Custom dymension epoch for faster disconnection + modifiedGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.incentives.params.distr_epoch_identifier", + Value: "custom", + }, + ) + customDymensionConfig := dymensionConfig + customDymensionConfig.ModifyGenesis = func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { + g := make(map[string]interface{}) + if err := json.Unmarshal(inputGenBz, &g); err != nil { + return nil, fmt.Errorf("failed to unmarshal genesis file: %w", err) + } + + epochData, err := dyno.Get(g, "app_state", "epochs", "epochs") + if err != nil { + return nil, fmt.Errorf("failed to retrieve epochs: %w", err) + } + epochs := epochData.([]interface{}) + exist := false + // Check if the "custom" identifier already exists + for _, epoch := range epochs { + if epochMap, ok := epoch.(map[string]interface{}); ok { + if epochMap["identifier"] == "custom" { + exist = true + } + } + } + if !exist { + // Define the new epoch type to be added + newEpochType := map[string]interface{}{ + "identifier": "custom", + "start_time": "0001-01-01T00:00:00Z", + "duration": "5s", + "current_epoch": "0", + "current_epoch_start_time": "0001-01-01T00:00:00Z", + "epoch_counting_started": false, + "current_epoch_start_height": "0", + } + + // Add the new epoch to the epochs array + updatedEpochs := append(epochs, newEpochType) + if err := dyno.Set(g, updatedEpochs, "app_state", "epochs", "epochs"); err != nil { + return nil, fmt.Errorf("failed to set epochs in genesis json: %w", err) + } + } + if err := dyno.Set(g, "adym", "app_state", "gov", "deposit_params", "min_deposit", 0, "denom"); err != nil { + return nil, fmt.Errorf("failed to set denom on gov min_deposit in genesis json: %w", err) + } + if err := dyno.Set(g, "10000000000", "app_state", "gov", "deposit_params", "min_deposit", 0, "amount"); err != nil { + return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) + } + if err := dyno.Set(g, "adym", "app_state", "gamm", "params", "pool_creation_fee", 0, "denom"); err != nil { + return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) + } + outputGenBz, err := json.Marshal(g) + if err != nil { + return nil, fmt.Errorf("failed to marshal genesis bytes to json: %w", err) + } + + return cosmos.ModifyGenesis(modifiedGenesisKV)(chainConfig, outputGenBz) + } cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", ChainConfig: ibc.ChainConfig{ - Type: "rollapp-dym", - Name: "rollapp-temp", - ChainID: "rollappevm_1234-1", - Images: []ibc.DockerImage{rollappEVMImage}, - Bin: "rollappd", - Bech32Prefix: "ethm", - Denom: "urax", - CoinType: "60", - GasPrices: "0.0urax", - GasAdjustment: 1.1, - TrustingPeriod: "112h", - EncodingConfig: encodingConfig(), - NoHostMount: false, - // Custom genesis to make the epoch last 5 seconds - ModifyGenesis: func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { - g := make(map[string]interface{}) - if err := json.Unmarshal(inputGenBz, &g); err != nil { - return nil, fmt.Errorf("failed to unmarshal genesis file: %w", err) - } - - epochData, err := dyno.Get(g, "app_state", "epochs", "epochs") - if err != nil { - return nil, fmt.Errorf("failed to retrieve epochs: %w", err) - } - epochs := epochData.([]interface{}) - exist := false - // Check if the "minute" identifier already exists - for _, epoch := range epochs { - if epochMap, ok := epoch.(map[string]interface{}); ok { - if epochMap["identifier"] == "custom" { - exist = true - } - } - } - if !exist { - // Define the new epoch type to be added - newEpochType := map[string]interface{}{ - "identifier": "custom", - "start_time": "0001-01-01T00:00:00Z", - "duration": "5s", - "current_epoch": "0", - "current_epoch_start_time": "0001-01-01T00:00:00Z", - "epoch_counting_started": false, - "current_epoch_start_height": "0", - } - - // Add the new epoch to the epochs array - updatedEpochs := append(epochs, newEpochType) - if err := dyno.Set(g, updatedEpochs, "app_state", "epochs", "epochs"); err != nil { - return nil, fmt.Errorf("failed to set epochs in genesis json: %w", err) - } - } - if err := dyno.Set(g, "adym", "app_state", "gov", "deposit_params", "min_deposit", 0, "denom"); err != nil { - return nil, fmt.Errorf("failed to set denom on gov min_deposit in genesis json: %w", err) - } - if err := dyno.Set(g, "10000000000", "app_state", "gov", "deposit_params", "min_deposit", 0, "amount"); err != nil { - return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) - } - if err := dyno.Set(g, "adym", "app_state", "gamm", "params", "pool_creation_fee", 0, "denom"); err != nil { - return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) - } - outputGenBz, err := json.Marshal(g) - if err != nil { - return nil, fmt.Errorf("failed to marshal genesis bytes to json: %w", err) - } - - return cosmos.ModifyGenesis(customGenesisKV)(chainConfig, outputGenBz) - }, + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -128,7 +133,7 @@ func TestDisconnection_EVM(t *testing.T) { }, { Name: "dymension-hub", - ChainConfig: dymensionConfig, + ChainConfig: customDymensionConfig, NumValidators: &numHubVals, NumFullNodes: &numHubFullNodes, }, From 1ca51cd1aa9953acceba8e129d6b63e287db5b7e Mon Sep 17 00:00:00 2001 From: Trinity Date: Mon, 22 Apr 2024 18:02:05 +0700 Subject: [PATCH 05/61] remove previous epoch set --- tests/disconnection_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index 17b705d7..2a7046dd 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -45,13 +45,13 @@ func TestDisconnection_EVM(t *testing.T) { numRollAppFn := 0 // Custom dymension epoch for faster disconnection - modifiedGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.incentives.params.distr_epoch_identifier", - Value: "custom", - }, - ) + modifyGenesisKV := dymensionGenesisKV + for _, kv := range modifyGenesisKV { + if kv.Key == "app_state.incentives.params.distr_epoch_identifier" { + kv.Value = "custom" + } + } + customDymensionConfig := dymensionConfig customDymensionConfig.ModifyGenesis = func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { g := make(map[string]interface{}) @@ -105,7 +105,7 @@ func TestDisconnection_EVM(t *testing.T) { return nil, fmt.Errorf("failed to marshal genesis bytes to json: %w", err) } - return cosmos.ModifyGenesis(modifiedGenesisKV)(chainConfig, outputGenBz) + return cosmos.ModifyGenesis(modifyGenesisKV)(chainConfig, outputGenBz) } cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ From 4f074e87f1817f6a991c28053249829a78c67454 Mon Sep 17 00:00:00 2001 From: Trinity Date: Mon, 22 Apr 2024 18:10:49 +0700 Subject: [PATCH 06/61] remove previous epoch set --- tests/disconnection_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index 2a7046dd..0f1b011c 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -47,7 +47,7 @@ func TestDisconnection_EVM(t *testing.T) { // Custom dymension epoch for faster disconnection modifyGenesisKV := dymensionGenesisKV for _, kv := range modifyGenesisKV { - if kv.Key == "app_state.incentives.params.distr_epoch_identifier" { + if kv.Key == "app_state.incentives.params.distr_epoch_identifier" || kv.Key == "app_state.txfees.params.epoch_identifier" { kv.Value = "custom" } } From 1ed1ed04e2ce7d7869f0b8537fb6a94de8d211da Mon Sep 17 00:00:00 2001 From: Trinity Date: Mon, 22 Apr 2024 18:24:24 +0700 Subject: [PATCH 07/61] use index to modify genesisKV --- tests/disconnection_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index 0f1b011c..ab622a11 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -46,9 +46,9 @@ func TestDisconnection_EVM(t *testing.T) { // Custom dymension epoch for faster disconnection modifyGenesisKV := dymensionGenesisKV - for _, kv := range modifyGenesisKV { + for i, kv := range modifyGenesisKV { if kv.Key == "app_state.incentives.params.distr_epoch_identifier" || kv.Key == "app_state.txfees.params.epoch_identifier" { - kv.Value = "custom" + modifyGenesisKV[i].Value = "custom" } } From 9345dc34c7f5aeabd7ec1d0337da2552f85eb787 Mon Sep 17 00:00:00 2001 From: Trinity Date: Tue, 23 Apr 2024 14:52:12 +0700 Subject: [PATCH 08/61] add disconnection test for rollapp-wasm --- .github/workflows/e2e-test-workflow-call.yml | 1 + .github/workflows/e2e_test.yml | 1 + Makefile | 5 + tests/disconnection_test.go | 227 +++++++++++++++++-- 4 files changed, 212 insertions(+), 22 deletions(-) diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 3f539207..9022c319 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -79,6 +79,7 @@ jobs: - "e2e-test-transfer-multi-hop-wasm" - "e2e-test-pfm-with-grace-period-wasm" - "e2e-test-batch-finalization-wasm" + - "e2e-test-disconnection-wasm" - "e2e-test-rollapp-freeze-wasm" - "e2e-test-other-rollapp-not-affected-wasm" fail-fast: false diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 1c655c76..42336f33 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -67,6 +67,7 @@ jobs: - "e2e-test-transfer-multi-hop-wasm" - "e2e-test-pfm-with-grace-period-wasm" - "e2e-test-batch-finalization-wasm" + - "e2e-test-disconnection-wasm" - "e2e-test-rollapp-freeze-wasm" - "e2e-test-other-rollapp-not-affected-wasm" fail-fast: false diff --git a/Makefile b/Makefile index f9b3c1d1..4cff920e 100644 --- a/Makefile +++ b/Makefile @@ -80,6 +80,9 @@ e2e-test-pfm-with-grace-period-wasm: clean-e2e e2e-test-batch-finalization-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestBatchFinalization_Wasm . +e2e-test-disconnection-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestDisconnection_Wasm . + e2e-test-rollapp-freeze-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollAppFreeze_Wasm . @@ -109,6 +112,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-eibc-pfm-wasm \ e2e-test-pfm-with-grace-period-wasm \ e2e-test-batch-finalization-wasm \ + e2e-test-disconnection-wasm \ e2e-test-rollapp-freeze-wasm \ e2e-test-other-rollapp-not-affected-wasm @@ -137,6 +141,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-transfer-multi-hop-wasm \ e2e-test-pfm-with-grace-period-wasm \ e2e-test-batch-finalization-wasm \ + e2e-test-disconnection-wasm \ e2e-test-rollapp-freeze-wasm \ e2e-test-other-rollapp-not-affected-wasm diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index ab622a11..8f19ae24 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -22,28 +22,11 @@ import ( "github.com/decentrio/rollup-e2e-testing/testutil" ) -func TestDisconnection_EVM(t *testing.T) { - if testing.Short() { - t.Skip() - } - - ctx := context.Background() - - configFileOverrides := make(map[string]any) - dymintTomlOverrides := make(testutil.Toml) - dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" - - configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - // Create chain factory with dymension - numHubVals := 1 - numHubFullNodes := 1 - numRollAppVals := 1 - numRollAppFn := 0 +var ( + customDymensionConfig ibc.ChainConfig +) +func init() { // Custom dymension epoch for faster disconnection modifyGenesisKV := dymensionGenesisKV for i, kv := range modifyGenesisKV { @@ -52,7 +35,7 @@ func TestDisconnection_EVM(t *testing.T) { } } - customDymensionConfig := dymensionConfig + customDymensionConfig = dymensionConfig customDymensionConfig.ModifyGenesis = func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { g := make(map[string]interface{}) if err := json.Unmarshal(inputGenBz, &g); err != nil { @@ -108,6 +91,30 @@ func TestDisconnection_EVM(t *testing.T) { return cosmos.ModifyGenesis(modifyGenesisKV)(chainConfig, outputGenBz) } +} + +func TestDisconnection_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppVals := 1 + numRollAppFn := 0 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", @@ -261,3 +268,179 @@ func TestDisconnection_EVM(t *testing.T) { require.NoError(t, err) }) } + +func TestDisconnection_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppVals := 1 + numRollAppFn := 0 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: customDymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + walletAmount := math.NewInt(1_000_000_000_000) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, _ := users[0], users[1] + + // IBC channel for rollapps + channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym, 1) + + channelDymRollapp := channsDym[0].ChannelID + + triggerHubGenesisEvent(t, dymension, rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channelDymRollapp, + userKey: dymensionUser.KeyName(), + }) + + // Wait for rollapp finalized + rollapp1Height, err := rollapp1.Height(ctx) + require.NoError(t, err) + dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 300) + + t.Run("hub disconnect", func(t *testing.T) { + err = dymension.StopAllNodes(ctx) + require.NoError(t, err) + + // Wait until rollapp stops produce block + rollappHeight, err := rollapp1.Height(ctx) + require.NoError(t, err) + + err = testutil.WaitForCondition( + time.Minute*10, + time.Second*5, // each epoch is 5 seconds + func() (bool, error) { + newRollappHeight, err := rollapp1.Height(ctx) + require.NoError(t, err) + + if newRollappHeight > rollappHeight { + rollappHeight = newRollappHeight + return false, nil + } + + return true, nil + }, + ) + require.NoError(t, err) + + err = dymension.StartAllNodes(ctx) + require.NoError(t, err) + + // Make sure rollapp start pro + err = testutil.WaitForBlocks(ctx, 1, rollapp1) + require.NoError(t, err) + }) +} From 36bf25f01e84a99e2e06a4ec4c09d71bfa1c7209 Mon Sep 17 00:00:00 2001 From: Trinity Date: Tue, 23 Apr 2024 14:58:51 +0700 Subject: [PATCH 09/61] use customDymensionConfig as a clone of dymensionConfig --- tests/disconnection_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index 8f19ae24..e9d5a2a9 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -35,7 +35,7 @@ func init() { } } - customDymensionConfig = dymensionConfig + customDymensionConfig = dymensionConfig.Clone() customDymensionConfig.ModifyGenesis = func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { g := make(map[string]interface{}) if err := json.Unmarshal(inputGenBz, &g); err != nil { @@ -291,6 +291,7 @@ func TestDisconnection_Wasm(t *testing.T) { numRollAppVals := 1 numRollAppFn := 0 + fmt.Println("customDymensionConfig: ", customDymensionConfig) cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", From 044a3fcd3d56ed4abff685aa33684c061a3383a3 Mon Sep 17 00:00:00 2001 From: Trinity Date: Tue, 23 Apr 2024 15:01:31 +0700 Subject: [PATCH 10/61] remove relayer --- tests/disconnection_test.go | 120 +----------------------------------- 1 file changed, 2 insertions(+), 118 deletions(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index e9d5a2a9..8715ba69 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -7,7 +7,6 @@ import ( "testing" "time" - "cosmossdk.io/math" "github.com/icza/dyno" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" @@ -17,7 +16,6 @@ import ( "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" - "github.com/decentrio/rollup-e2e-testing/relayer" "github.com/decentrio/rollup-e2e-testing/testreporter" "github.com/decentrio/rollup-e2e-testing/testutil" ) @@ -156,19 +154,8 @@ func TestDisconnection_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) - r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), - ).Build(t, client, "relayer", network) - ic := test.NewSetup(). - AddRollUp(dymension, rollapp1). - AddRelayer(r, "relayer"). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp1, - Relayer: r, - Path: ibcPath, - }) + AddRollUp(dymension, rollapp1) rep := testreporter.NewNopReporter() eRep := rep.RelayerExecReporter(t) @@ -184,52 +171,6 @@ func TestDisconnection_EVM(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - walletAmount := math.NewInt(1_000_000_000_000) - - // Create some user accounts on both chains - users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - - // Get our Bech32 encoded user addresses - dymensionUser, _ := users[0], users[1] - - // IBC channel for rollapps - channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) - require.NoError(t, err) - require.Len(t, channsDym, 1) - - channelDymRollapp := channsDym[0].ChannelID - - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp1.Config().ChainID, - channelID: channelDymRollapp, - userKey: dymensionUser.KeyName(), - }) - // Wait for rollapp finalized rollapp1Height, err := rollapp1.Height(ctx) require.NoError(t, err) @@ -333,19 +274,8 @@ func TestDisconnection_Wasm(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) - r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), - ).Build(t, client, "relayer", network) - ic := test.NewSetup(). - AddRollUp(dymension, rollapp1). - AddRelayer(r, "relayer"). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp1, - Relayer: r, - Path: ibcPath, - }) + AddRollUp(dymension, rollapp1) rep := testreporter.NewNopReporter() eRep := rep.RelayerExecReporter(t) @@ -361,52 +291,6 @@ func TestDisconnection_Wasm(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - walletAmount := math.NewInt(1_000_000_000_000) - - // Create some user accounts on both chains - users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - - // Get our Bech32 encoded user addresses - dymensionUser, _ := users[0], users[1] - - // IBC channel for rollapps - channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) - require.NoError(t, err) - require.Len(t, channsDym, 1) - - channelDymRollapp := channsDym[0].ChannelID - - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp1.Config().ChainID, - channelID: channelDymRollapp, - userKey: dymensionUser.KeyName(), - }) - // Wait for rollapp finalized rollapp1Height, err := rollapp1.Height(ctx) require.NoError(t, err) From ea8996397ce85ff95529f204ea7a0df798ac8631 Mon Sep 17 00:00:00 2001 From: Trinity Date: Tue, 23 Apr 2024 15:10:01 +0700 Subject: [PATCH 11/61] make customDymensionConfig separate with dymensionConfig --- tests/disconnection_test.go | 111 ++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 48 deletions(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index 8715ba69..e0ab9783 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -33,60 +33,75 @@ func init() { } } - customDymensionConfig = dymensionConfig.Clone() - customDymensionConfig.ModifyGenesis = func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { - g := make(map[string]interface{}) - if err := json.Unmarshal(inputGenBz, &g); err != nil { - return nil, fmt.Errorf("failed to unmarshal genesis file: %w", err) - } + customDymensionConfig = ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { + g := make(map[string]interface{}) + if err := json.Unmarshal(inputGenBz, &g); err != nil { + return nil, fmt.Errorf("failed to unmarshal genesis file: %w", err) + } - epochData, err := dyno.Get(g, "app_state", "epochs", "epochs") - if err != nil { - return nil, fmt.Errorf("failed to retrieve epochs: %w", err) - } - epochs := epochData.([]interface{}) - exist := false - // Check if the "custom" identifier already exists - for _, epoch := range epochs { - if epochMap, ok := epoch.(map[string]interface{}); ok { - if epochMap["identifier"] == "custom" { - exist = true - } + epochData, err := dyno.Get(g, "app_state", "epochs", "epochs") + if err != nil { + return nil, fmt.Errorf("failed to retrieve epochs: %w", err) } - } - if !exist { - // Define the new epoch type to be added - newEpochType := map[string]interface{}{ - "identifier": "custom", - "start_time": "0001-01-01T00:00:00Z", - "duration": "5s", - "current_epoch": "0", - "current_epoch_start_time": "0001-01-01T00:00:00Z", - "epoch_counting_started": false, - "current_epoch_start_height": "0", + epochs := epochData.([]interface{}) + exist := false + // Check if the "custom" identifier already exists + for _, epoch := range epochs { + if epochMap, ok := epoch.(map[string]interface{}); ok { + if epochMap["identifier"] == "custom" { + exist = true + } + } } + if !exist { + // Define the new epoch type to be added + newEpochType := map[string]interface{}{ + "identifier": "custom", + "start_time": "0001-01-01T00:00:00Z", + "duration": "5s", + "current_epoch": "0", + "current_epoch_start_time": "0001-01-01T00:00:00Z", + "epoch_counting_started": false, + "current_epoch_start_height": "0", + } - // Add the new epoch to the epochs array - updatedEpochs := append(epochs, newEpochType) - if err := dyno.Set(g, updatedEpochs, "app_state", "epochs", "epochs"); err != nil { - return nil, fmt.Errorf("failed to set epochs in genesis json: %w", err) + // Add the new epoch to the epochs array + updatedEpochs := append(epochs, newEpochType) + if err := dyno.Set(g, updatedEpochs, "app_state", "epochs", "epochs"); err != nil { + return nil, fmt.Errorf("failed to set epochs in genesis json: %w", err) + } + } + if err := dyno.Set(g, "adym", "app_state", "gov", "deposit_params", "min_deposit", 0, "denom"); err != nil { + return nil, fmt.Errorf("failed to set denom on gov min_deposit in genesis json: %w", err) + } + if err := dyno.Set(g, "10000000000", "app_state", "gov", "deposit_params", "min_deposit", 0, "amount"); err != nil { + return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) + } + if err := dyno.Set(g, "adym", "app_state", "gamm", "params", "pool_creation_fee", 0, "denom"); err != nil { + return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) + } + outputGenBz, err := json.Marshal(g) + if err != nil { + return nil, fmt.Errorf("failed to marshal genesis bytes to json: %w", err) } - } - if err := dyno.Set(g, "adym", "app_state", "gov", "deposit_params", "min_deposit", 0, "denom"); err != nil { - return nil, fmt.Errorf("failed to set denom on gov min_deposit in genesis json: %w", err) - } - if err := dyno.Set(g, "10000000000", "app_state", "gov", "deposit_params", "min_deposit", 0, "amount"); err != nil { - return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) - } - if err := dyno.Set(g, "adym", "app_state", "gamm", "params", "pool_creation_fee", 0, "denom"); err != nil { - return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) - } - outputGenBz, err := json.Marshal(g) - if err != nil { - return nil, fmt.Errorf("failed to marshal genesis bytes to json: %w", err) - } - return cosmos.ModifyGenesis(modifyGenesisKV)(chainConfig, outputGenBz) + return cosmos.ModifyGenesis(modifyGenesisKV)(chainConfig, outputGenBz) + }, + ConfigFileOverrides: nil, } } From e1d97ece9e874dccfa441c21e47f88de3ec6e42d Mon Sep 17 00:00:00 2001 From: Trinity Date: Tue, 23 Apr 2024 15:18:54 +0700 Subject: [PATCH 12/61] use function that returns ibc.ChainConfig instead of init() --- tests/disconnection_test.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index e0ab9783..05b26d62 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -20,11 +20,7 @@ import ( "github.com/decentrio/rollup-e2e-testing/testutil" ) -var ( - customDymensionConfig ibc.ChainConfig -) - -func init() { +func customConfig() ibc.ChainConfig { // Custom dymension epoch for faster disconnection modifyGenesisKV := dymensionGenesisKV for i, kv := range modifyGenesisKV { @@ -33,7 +29,7 @@ func init() { } } - customDymensionConfig = ibc.ChainConfig{ + customDymensionConfig := ibc.ChainConfig{ Type: "hub-dym", Name: "dymension", ChainID: "dymension_100-1", @@ -104,6 +100,7 @@ func init() { ConfigFileOverrides: nil, } + return customDymensionConfig } func TestDisconnection_EVM(t *testing.T) { @@ -153,7 +150,7 @@ func TestDisconnection_EVM(t *testing.T) { }, { Name: "dymension-hub", - ChainConfig: customDymensionConfig, + ChainConfig: customConfig(), NumValidators: &numHubVals, NumFullNodes: &numHubFullNodes, }, @@ -247,7 +244,6 @@ func TestDisconnection_Wasm(t *testing.T) { numRollAppVals := 1 numRollAppFn := 0 - fmt.Println("customDymensionConfig: ", customDymensionConfig) cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", @@ -273,7 +269,7 @@ func TestDisconnection_Wasm(t *testing.T) { }, { Name: "dymension-hub", - ChainConfig: customDymensionConfig, + ChainConfig: customConfig(), NumValidators: &numHubVals, NumFullNodes: &numHubFullNodes, }, From dceed603def9118840f26623d4cbd3736a7c9ca7 Mon Sep 17 00:00:00 2001 From: Trinity Date: Tue, 23 Apr 2024 15:33:54 +0700 Subject: [PATCH 13/61] add fullnode-sync test --- .github/workflows/e2e-test-workflow-call.yml | 2 + .github/workflows/e2e_test.yml | 2 + Makefile | 6 + tests/fullnode_sync_test.go | 254 +++++++++++++++++++ 4 files changed, 264 insertions(+) create mode 100644 tests/fullnode_sync_test.go diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 9022c319..d2e3bf22 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -36,6 +36,7 @@ jobs: - "e2e-test-pfm-with-grace-period-evm" - "e2e-test-batch-finalization-evm" - "e2e-test-disconnection-evm" + - "e2e-test-fullnode-sync-evm" - "e2e-test-rollapp-freeze-evm" - "e2e-test-other-rollapp-not-affected-evm" - "e2e-test-rollapp-genesis-event-evm" @@ -80,6 +81,7 @@ jobs: - "e2e-test-pfm-with-grace-period-wasm" - "e2e-test-batch-finalization-wasm" - "e2e-test-disconnection-wasm" + - "e2e-test-fullnode-sync-wasm" - "e2e-test-rollapp-freeze-wasm" - "e2e-test-other-rollapp-not-affected-wasm" fail-fast: false diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 42336f33..fce21894 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -38,6 +38,7 @@ jobs: - "e2e-test-pfm-with-grace-period-evm" - "e2e-test-batch-finalization-evm" - "e2e-test-disconnection-evm" + - "e2e-test-fullnode-sync-evm" - "e2e-test-rollapp-freeze-evm" - "e2e-test-other-rollapp-not-affected-evm" - "e2e-test-rollapp-genesis-event-evm" @@ -68,6 +69,7 @@ jobs: - "e2e-test-pfm-with-grace-period-wasm" - "e2e-test-batch-finalization-wasm" - "e2e-test-disconnection-wasm" + - "e2e-test-fullnode-sync-wasm" - "e2e-test-rollapp-freeze-wasm" - "e2e-test-other-rollapp-not-affected-wasm" fail-fast: false diff --git a/Makefile b/Makefile index 4cff920e..6b753471 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,9 @@ e2e-test-batch-finalization-evm: clean-e2e e2e-test-disconnection-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDisconnection_EVM . +e2e-test-fullnode-sync-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestFullnodeSync_EVM . + e2e-test-rollapp-freeze-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollAppFreeze_EVM . @@ -83,6 +86,9 @@ e2e-test-batch-finalization-wasm: clean-e2e e2e-test-disconnection-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDisconnection_Wasm . +e2e-test-fullnode-sync-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestFullnodeSync_Wasm . + e2e-test-rollapp-freeze-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollAppFreeze_Wasm . diff --git a/tests/fullnode_sync_test.go b/tests/fullnode_sync_test.go new file mode 100644 index 00000000..f9a457d2 --- /dev/null +++ b/tests/fullnode_sync_test.go @@ -0,0 +1,254 @@ +package tests + +import ( + "context" + "fmt" + "testing" + "time" + + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" + + test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" +) + +func TestFullnodeSynv_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppVals := 1 + numRollAppFn := 1 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: customConfig(), + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + // Wait for rollapp finalized + rollapp1Height, err := rollapp1.Height(ctx) + require.NoError(t, err) + dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 300) + + // Stop the full node + err = rollapp1.FullNodes[0].StopContainer(ctx) + require.NoError(t, err) + + // Wait for a few blocks before start the node again and sync + err = testutil.WaitForBlocks(ctx, 50, rollapp1) + require.NoError(t, err) + + // Start full node again + err = rollapp1.FullNodes[0].StartContainer(ctx) + require.NoError(t, err) + + // Poll until full node is sync + err = testutil.WaitForCondition( + time.Minute*10, + time.Second*5, // each epoch is 5 seconds + func() (bool, error) { + valHeight, err := rollapp1.Validators[0].Height(ctx) + require.NoError(t, err) + + fullnodeHeight, err := rollapp1.FullNodes[0].Height(ctx) + require.NoError(t, err) + + if valHeight > fullnodeHeight { + return false, nil + } + + return true, nil + }, + ) + require.NoError(t, err) +} + +func TestFullnodeSync_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppVals := 1 + numRollAppFn := 0 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: customConfig(), + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + // Wait for rollapp finalized + rollapp1Height, err := rollapp1.Height(ctx) + require.NoError(t, err) + dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 300) + + // Stop the full node + err = rollapp1.FullNodes[0].StopContainer(ctx) + require.NoError(t, err) + + // Wait for a few blocks before start the node again and sync + err = testutil.WaitForBlocks(ctx, 50, rollapp1) + require.NoError(t, err) + + // Start full node again + err = rollapp1.FullNodes[0].StartContainer(ctx) + require.NoError(t, err) + + // Poll until full node is sync + err = testutil.WaitForCondition( + time.Minute*10, + time.Second*5, // each epoch is 5 seconds + func() (bool, error) { + valHeight, err := rollapp1.Validators[0].Height(ctx) + require.NoError(t, err) + + fullnodeHeight, err := rollapp1.FullNodes[0].Height(ctx) + require.NoError(t, err) + + if valHeight > fullnodeHeight { + return false, nil + } + + return true, nil + }, + ) + require.NoError(t, err) +} From c3b007b3d8ed1799fb0e70c59c69ca3022c6f16f Mon Sep 17 00:00:00 2001 From: Trinity Date: Tue, 23 Apr 2024 16:03:16 +0700 Subject: [PATCH 14/61] change fullnode on wasm test to 1 --- tests/fullnode_sync_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fullnode_sync_test.go b/tests/fullnode_sync_test.go index f9a457d2..9cab9f0a 100644 --- a/tests/fullnode_sync_test.go +++ b/tests/fullnode_sync_test.go @@ -155,7 +155,7 @@ func TestFullnodeSync_Wasm(t *testing.T) { numHubVals := 1 numHubFullNodes := 1 numRollAppVals := 1 - numRollAppFn := 0 + numRollAppFn := 1 cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { From 01b860dde7f697bdcbad5723e425777a5040afbf Mon Sep 17 00:00:00 2001 From: Trinity Date: Wed, 24 Apr 2024 15:17:27 +0700 Subject: [PATCH 15/61] refactor test --- tests/disconnection_test.go | 92 ++----------------------------------- tests/fullnode_sync_test.go | 6 +-- tests/setup.go | 84 +++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 92 deletions(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index 05b26d62..1f937a20 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -2,17 +2,14 @@ package tests import ( "context" - "encoding/json" "fmt" "testing" "time" - "github.com/icza/dyno" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" @@ -20,89 +17,6 @@ import ( "github.com/decentrio/rollup-e2e-testing/testutil" ) -func customConfig() ibc.ChainConfig { - // Custom dymension epoch for faster disconnection - modifyGenesisKV := dymensionGenesisKV - for i, kv := range modifyGenesisKV { - if kv.Key == "app_state.incentives.params.distr_epoch_identifier" || kv.Key == "app_state.txfees.params.epoch_identifier" { - modifyGenesisKV[i].Value = "custom" - } - } - - customDymensionConfig := ibc.ChainConfig{ - Type: "hub-dym", - Name: "dymension", - ChainID: "dymension_100-1", - Images: []ibc.DockerImage{dymensionImage}, - Bin: "dymd", - Bech32Prefix: "dym", - Denom: "adym", - CoinType: "60", - GasPrices: "0.0adym", - EncodingConfig: encodingConfig(), - GasAdjustment: 1.1, - TrustingPeriod: "112h", - NoHostMount: false, - ModifyGenesis: func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { - g := make(map[string]interface{}) - if err := json.Unmarshal(inputGenBz, &g); err != nil { - return nil, fmt.Errorf("failed to unmarshal genesis file: %w", err) - } - - epochData, err := dyno.Get(g, "app_state", "epochs", "epochs") - if err != nil { - return nil, fmt.Errorf("failed to retrieve epochs: %w", err) - } - epochs := epochData.([]interface{}) - exist := false - // Check if the "custom" identifier already exists - for _, epoch := range epochs { - if epochMap, ok := epoch.(map[string]interface{}); ok { - if epochMap["identifier"] == "custom" { - exist = true - } - } - } - if !exist { - // Define the new epoch type to be added - newEpochType := map[string]interface{}{ - "identifier": "custom", - "start_time": "0001-01-01T00:00:00Z", - "duration": "5s", - "current_epoch": "0", - "current_epoch_start_time": "0001-01-01T00:00:00Z", - "epoch_counting_started": false, - "current_epoch_start_height": "0", - } - - // Add the new epoch to the epochs array - updatedEpochs := append(epochs, newEpochType) - if err := dyno.Set(g, updatedEpochs, "app_state", "epochs", "epochs"); err != nil { - return nil, fmt.Errorf("failed to set epochs in genesis json: %w", err) - } - } - if err := dyno.Set(g, "adym", "app_state", "gov", "deposit_params", "min_deposit", 0, "denom"); err != nil { - return nil, fmt.Errorf("failed to set denom on gov min_deposit in genesis json: %w", err) - } - if err := dyno.Set(g, "10000000000", "app_state", "gov", "deposit_params", "min_deposit", 0, "amount"); err != nil { - return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) - } - if err := dyno.Set(g, "adym", "app_state", "gamm", "params", "pool_creation_fee", 0, "denom"); err != nil { - return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) - } - outputGenBz, err := json.Marshal(g) - if err != nil { - return nil, fmt.Errorf("failed to marshal genesis bytes to json: %w", err) - } - - return cosmos.ModifyGenesis(modifyGenesisKV)(chainConfig, outputGenBz) - }, - ConfigFileOverrides: nil, - } - - return customDymensionConfig -} - func TestDisconnection_EVM(t *testing.T) { if testing.Short() { t.Skip() @@ -150,7 +64,7 @@ func TestDisconnection_EVM(t *testing.T) { }, { Name: "dymension-hub", - ChainConfig: customConfig(), + ChainConfig: customEpochConfig("5s"), NumValidators: &numHubVals, NumFullNodes: &numHubFullNodes, }, @@ -242,7 +156,7 @@ func TestDisconnection_Wasm(t *testing.T) { numHubVals := 1 numHubFullNodes := 1 numRollAppVals := 1 - numRollAppFn := 0 + numRollAppFn := 1 cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -269,7 +183,7 @@ func TestDisconnection_Wasm(t *testing.T) { }, { Name: "dymension-hub", - ChainConfig: customConfig(), + ChainConfig: customEpochConfig("5s"), NumValidators: &numHubVals, NumFullNodes: &numHubFullNodes, }, diff --git a/tests/fullnode_sync_test.go b/tests/fullnode_sync_test.go index 9cab9f0a..13b9f022 100644 --- a/tests/fullnode_sync_test.go +++ b/tests/fullnode_sync_test.go @@ -17,7 +17,7 @@ import ( "github.com/decentrio/rollup-e2e-testing/testutil" ) -func TestFullnodeSynv_EVM(t *testing.T) { +func TestFullnodeSync_EVM(t *testing.T) { if testing.Short() { t.Skip() } @@ -64,7 +64,7 @@ func TestFullnodeSynv_EVM(t *testing.T) { }, { Name: "dymension-hub", - ChainConfig: customConfig(), + ChainConfig: customEpochConfig("5s"), NumValidators: &numHubVals, NumFullNodes: &numHubFullNodes, }, @@ -182,7 +182,7 @@ func TestFullnodeSync_Wasm(t *testing.T) { }, { Name: "dymension-hub", - ChainConfig: customConfig(), + ChainConfig: customEpochConfig("5s"), NumValidators: &numHubVals, NumFullNodes: &numHubFullNodes, }, diff --git a/tests/setup.go b/tests/setup.go index 717a8673..1ac71f01 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -326,6 +326,90 @@ func defaultConfig() *simappparams.EncodingConfig { return &cfg } + +func customEpochConfig(epochDuration string) ibc.ChainConfig { + // Custom dymension epoch for faster disconnection + modifyGenesisKV := dymensionGenesisKV + for i, kv := range modifyGenesisKV { + if kv.Key == "app_state.incentives.params.distr_epoch_identifier" || kv.Key == "app_state.txfees.params.epoch_identifier" { + modifyGenesisKV[i].Value = "custom" + } + } + + customDymensionConfig := ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { + g := make(map[string]interface{}) + if err := json.Unmarshal(inputGenBz, &g); err != nil { + return nil, fmt.Errorf("failed to unmarshal genesis file: %w", err) + } + + epochData, err := dyno.Get(g, "app_state", "epochs", "epochs") + if err != nil { + return nil, fmt.Errorf("failed to retrieve epochs: %w", err) + } + epochs := epochData.([]interface{}) + exist := false + // Check if the "custom" identifier already exists + for _, epoch := range epochs { + if epochMap, ok := epoch.(map[string]interface{}); ok { + if epochMap["identifier"] == "custom" { + exist = true + } + } + } + if !exist { + // Define the new epoch type to be added + newEpochType := map[string]interface{}{ + "identifier": "custom", + "start_time": "0001-01-01T00:00:00Z", + "duration": epochDuration, + "current_epoch": "0", + "current_epoch_start_time": "0001-01-01T00:00:00Z", + "epoch_counting_started": false, + "current_epoch_start_height": "0", + } + + // Add the new epoch to the epochs array + updatedEpochs := append(epochs, newEpochType) + if err := dyno.Set(g, updatedEpochs, "app_state", "epochs", "epochs"); err != nil { + return nil, fmt.Errorf("failed to set epochs in genesis json: %w", err) + } + } + if err := dyno.Set(g, "adym", "app_state", "gov", "deposit_params", "min_deposit", 0, "denom"); err != nil { + return nil, fmt.Errorf("failed to set denom on gov min_deposit in genesis json: %w", err) + } + if err := dyno.Set(g, "10000000000", "app_state", "gov", "deposit_params", "min_deposit", 0, "amount"); err != nil { + return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) + } + if err := dyno.Set(g, "adym", "app_state", "gamm", "params", "pool_creation_fee", 0, "denom"); err != nil { + return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) + } + outputGenBz, err := json.Marshal(g) + if err != nil { + return nil, fmt.Errorf("failed to marshal genesis bytes to json: %w", err) + } + + return cosmos.ModifyGenesis(modifyGenesisKV)(chainConfig, outputGenBz) + }, + ConfigFileOverrides: nil, + } + + return customDymensionConfig +} + func modifyRollappEVMGenesis(genesisKV []cosmos.GenesisKV) func(ibc.ChainConfig, []byte) ([]byte, error) { return func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { g := make(map[string]interface{}) From 05a6aab3c18479af7acb3561671bcef5884792bd Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Wed, 24 Apr 2024 11:31:18 +0700 Subject: [PATCH 16/61] [PFM] E2E test for transfer from gaia to rollapp (#117) Co-authored-by: lacsomot --- .github/workflows/e2e-test-workflow-call.yml | 8 +- .github/workflows/e2e_test.yml | 8 +- Makefile | 31 +- tests/ibc_pfm_test.go | 578 +++++++++++++++++++ tests/setup.go | 2 +- 5 files changed, 610 insertions(+), 17 deletions(-) diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index d2e3bf22..7e2fab07 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -26,14 +26,15 @@ jobs: - "e2e-test-ibc-success-evm" - "e2e-test-ibc-timeout-evm" - "e2e-test-ibc-grace-period-evm" - - "e2e-test-eibc-fulfillment-evm" - - "e2e-test-eibc-pfm-evm" - - "e2e-test-eibc-fulfill-no-balance-evm" - "e2e-test-eibc-corrupted-memo-evm" - "e2e-test-eibc-excessive-fee-evm" + - "e2e-test-eibc-fulfillment-evm" + - "e2e-test-eibc-fulfill-no-balance-evm" + - "e2e-test-eibc-pfm-evm" - "e2e-test-eibc-timeout-evm" - "e2e-test-transfer-multi-hop-evm" - "e2e-test-pfm-with-grace-period-evm" + - "e2e-test-pfm-gaia-to-rollapp-evm" - "e2e-test-batch-finalization-evm" - "e2e-test-disconnection-evm" - "e2e-test-fullnode-sync-evm" @@ -79,6 +80,7 @@ jobs: - "e2e-test-eibc-pfm-wasm" - "e2e-test-transfer-multi-hop-wasm" - "e2e-test-pfm-with-grace-period-wasm" + - "e2e-test-pfm-gaia-to-rollapp-wasm" - "e2e-test-batch-finalization-wasm" - "e2e-test-disconnection-wasm" - "e2e-test-fullnode-sync-wasm" diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index fce21894..186c73c4 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -28,14 +28,15 @@ jobs: - "e2e-test-ibc-success-evm" - "e2e-test-ibc-timeout-evm" - "e2e-test-ibc-grace-period-evm" - - "e2e-test-eibc-fulfillment-evm" - - "e2e-test-eibc-pfm-evm" - - "e2e-test-eibc-fulfill-no-balance-evm" - "e2e-test-eibc-corrupted-memo-evm" - "e2e-test-eibc-excessive-fee-evm" + - "e2e-test-eibc-fulfillment-evm" + - "e2e-test-eibc-fulfill-no-balance-evm" + - "e2e-test-eibc-pfm-evm" - "e2e-test-eibc-timeout-evm" - "e2e-test-transfer-multi-hop-evm" - "e2e-test-pfm-with-grace-period-evm" + - "e2e-test-pfm-gaia-to-rollapp-evm" - "e2e-test-batch-finalization-evm" - "e2e-test-disconnection-evm" - "e2e-test-fullnode-sync-evm" @@ -67,6 +68,7 @@ jobs: - "e2e-test-eibc-pfm-wasm" - "e2e-test-transfer-multi-hop-wasm" - "e2e-test-pfm-with-grace-period-wasm" + - "e2e-test-pfm-gaia-to-rollapp-wasm" - "e2e-test-batch-finalization-wasm" - "e2e-test-disconnection-wasm" - "e2e-test-fullnode-sync-wasm" diff --git a/Makefile b/Makefile index 6b753471..ddb3f4d4 100644 --- a/Makefile +++ b/Makefile @@ -94,20 +94,28 @@ e2e-test-rollapp-freeze-wasm: clean-e2e e2e-test-other-rollapp-not-affected-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestOtherRollappNotAffected_Wasm . - + +e2e-test-pfm-gaia-to-rollapp-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestIBCTransferGaiaToRollApp_EVM . + +e2e-test-pfm-gaia-to-rollapp-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestIBCTransferGaiaToRollApp_Wasm . + +# Executes all tests via rollup-e2e-testing e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ e2e-test-ibc-grace-period-evm \ + e2e-test-eibc-corrupted-memo-evm \ + e2e-test-eibc-excessive-fee-evm \ + e2e-test-eibc-fulfillment-evm \ + e2e-test-eibc-fulfill-no-balance-evm \ + e2e-test-eibc-pfm-evm \ + e2e-test-eibc-timeout-evm \ e2e-test-transfer-multi-hop-evm \ e2e-test-pfm-with-grace-period-evm \ + e2e-test-pfm-gaia-to-rollapp-evm \ e2e-test-batch-finalization-evm \ e2e-test-disconnection-evm \ - e2e-test-eibc-fulfillment-evm \ - e2e-test-eibc-pfm-evm \ - e2e-test-eibc-fulfill-no-balance-evm \ - e2e-test-eibc-corrupted-memo-evm \ - e2e-test-eibc-excessive-fee-evm \ - e2e-test-eibc-timeout-evm \ e2e-test-rollapp-freeze-evm \ e2e-test-other-rollapp-not-affected-evm \ e2e-test-ibc-success-wasm \ @@ -117,6 +125,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-eibc-fulfillment-wasm \ e2e-test-eibc-pfm-wasm \ e2e-test-pfm-with-grace-period-wasm \ + e2e-test-pfm-gaia-to-rollapp-wasm \ e2e-test-batch-finalization-wasm \ e2e-test-disconnection-wasm \ e2e-test-rollapp-freeze-wasm \ @@ -127,14 +136,15 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ e2e-test-ibc-grace-period-evm \ - e2e-test-eibc-fulfillment-evm \ - e2e-test-eibc-pfm-evm \ - e2e-test-eibc-fulfill-no-balance-evm \ e2e-test-eibc-corrupted-memo-evm \ e2e-test-eibc-excessive-fee-evm \ + e2e-test-eibc-fulfillment-evm \ + e2e-test-eibc-fulfill-no-balance-evm \ + e2e-test-eibc-pfm-evm \ e2e-test-eibc-timeout-evm \ e2e-test-transfer-multi-hop-evm \ e2e-test-pfm-with-grace-period-evm \ + e2e-test-pfm-gaia-to-rollapp-evm \ e2e-test-batch-finalization-evm \ e2e-test-disconnection-evm \ e2e-test-rollapp-freeze-evm \ @@ -146,6 +156,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-eibc-pfm-wasm \ e2e-test-transfer-multi-hop-wasm \ e2e-test-pfm-with-grace-period-wasm \ + e2e-test-pfm-gaia-to-rollapp-wasm \ e2e-test-batch-finalization-wasm \ e2e-test-disconnection-wasm \ e2e-test-rollapp-freeze-wasm \ diff --git a/tests/ibc_pfm_test.go b/tests/ibc_pfm_test.go index 7975cb0e..44f27f86 100644 --- a/tests/ibc_pfm_test.go +++ b/tests/ibc_pfm_test.go @@ -623,3 +623,581 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, secondHopIBCDenom, transferAmount) }) } + +func TestIBCTransferGaiaToRollApp_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_1234-1", "0adym", "3s") + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + numVals := 1 + numFullNodes := 0 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-test", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + { + Name: "gaia-1", + Version: "v14.2.0", + ChainConfig: gaiaConfig, + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + }) + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + gaia := chains[2].(*cosmos.CosmosChain) + + // Relayer Factory + client, network := test.DockerSetup(t) + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + ).Build(t, client, "relayer", network) + + r2 := test.NewBuiltinRelayerFactory( + ibc.CosmosRly, + zaptest.NewLogger(t), + relayer.CustomDockerImage(IBCRelayerImage, IBCRelayerVersion, "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddChain(gaia). + AddRelayer(r, "relayer"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: gaia, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + t.Cleanup(func() { + _ = ic.Close() + }) + + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, anotherIbcPath) + require.NoError(t, err) + + err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, gaia) + require.NoError(t, err) + + r2.UpdateClients(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = r2.CreateConnections(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, gaia) + require.NoError(t, err) + + err = r2.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) + require.NoError(t, err) + + channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym, 2) + + rollAppChan, err := r.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, rollAppChan, 1) + + dymRollAppChan := rollAppChan[0].Counterparty + require.NotEmpty(t, dymRollAppChan.ChannelID) + + rollappDymChan := rollAppChan[0] + require.NotEmpty(t, rollappDymChan.ChannelID) + + gaiaChan, err := r2.GetChannels(ctx, eRep, gaia.GetChainID()) + require.NoError(t, err) + require.Len(t, gaiaChan, 1) + + dymGaiaChan := gaiaChan[0].Counterparty + require.NotEmpty(t, dymGaiaChan.ChannelID) + + gaiaDymChan := gaiaChan[0] + require.NotEmpty(t, gaiaDymChan.ChannelID) + + // Start the relayer and set the cleanup function. + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + t.Cleanup( + func() { + err := r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer2: %s", err) + } + }, + ) + + walletAmount := math.NewInt(1_000_000_000_000) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, gaia) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser, gaiaUser := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + gaiaUserAddr := gaiaUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + gaiaOrigBal, err := gaia.GetBalance(ctx, gaiaUserAddr, gaia.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, gaiaOrigBal) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: dymRollAppChan.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + t.Run("multihop gaia->dym->rollapp", func(t *testing.T) { + + firstHopDenom := transfertypes.GetPrefixedDenom(dymGaiaChan.PortID, dymGaiaChan.ChannelID, gaia.Config().Denom) + secondHopDenom := transfertypes.GetPrefixedDenom(rollappDymChan.PortID, rollappDymChan.ChannelID, firstHopDenom) + + firstHopDenomTrace := transfertypes.ParseDenomTrace(firstHopDenom) + secondHopDenomTrace := transfertypes.ParseDenomTrace(secondHopDenom) + + firstHopIBCDenom := firstHopDenomTrace.IBCDenom() + secondHopIBCDenom := secondHopDenomTrace.IBCDenom() + + zeroBal := math.ZeroInt() + transferAmount := math.NewInt(100_000) + + // Send packet from gaia -> dym -> rollapp1 + transfer := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: gaia.Config().Denom, + Amount: transferAmount, + } + + firstHopMetadata := &PacketMetadata{ + Forward: &ForwardMetadata{ + Receiver: rollappUserAddr, + Channel: dymRollAppChan.ChannelID, + Port: dymRollAppChan.PortID, + Timeout: 5 * time.Minute, + }, + } + + memo, err := json.Marshal(firstHopMetadata) + require.NoError(t, err) + + transferTx, err := gaia.SendIBCTransfer(ctx, gaiaDymChan.ChannelID, gaiaUser.KeyName(), transfer, ibc.TransferOptions{Memo: string(memo)}) + require.NoError(t, err) + err = transferTx.Validate() + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + err = testutil.WaitForBlocks(ctx, 20, dymension, gaia) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, gaia.Config().Denom, walletAmount.Sub(transferAmount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, zeroBal) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, secondHopIBCDenom, transferAmount) + }) +} + +func TestIBCTransferGaiaToRollApp_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappwasm_1234-1", "0adym", "3s") + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + numVals := 1 + numFullNodes := 0 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-test", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + { + Name: "gaia-1", + Version: "v14.2.0", + ChainConfig: gaiaConfig, + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + }) + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + gaia := chains[2].(*cosmos.CosmosChain) + + // Relayer Factory + client, network := test.DockerSetup(t) + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + ).Build(t, client, "relayer", network) + + r2 := test.NewBuiltinRelayerFactory( + ibc.CosmosRly, + zaptest.NewLogger(t), + relayer.CustomDockerImage(IBCRelayerImage, IBCRelayerVersion, "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddChain(gaia). + AddRelayer(r, "relayer"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: gaia, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + t.Cleanup(func() { + _ = ic.Close() + }) + + err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, anotherIbcPath) + require.NoError(t, err) + + err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, gaia) + require.NoError(t, err) + + r2.UpdateClients(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = r2.CreateConnections(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, gaia) + require.NoError(t, err) + + err = r2.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) + require.NoError(t, err) + + channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym, 2) + + rollAppChan, err := r.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, rollAppChan, 1) + + dymRollAppChan := rollAppChan[0].Counterparty + require.NotEmpty(t, dymRollAppChan.ChannelID) + + rollappDymChan := rollAppChan[0] + require.NotEmpty(t, rollappDymChan.ChannelID) + + gaiaChan, err := r2.GetChannels(ctx, eRep, gaia.GetChainID()) + require.NoError(t, err) + require.Len(t, gaiaChan, 1) + + dymGaiaChan := gaiaChan[0].Counterparty + require.NotEmpty(t, dymGaiaChan.ChannelID) + + gaiaDymChan := gaiaChan[0] + require.NotEmpty(t, gaiaDymChan.ChannelID) + + // Start the relayer and set the cleanup function. + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + t.Cleanup( + func() { + err := r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer2: %s", err) + } + }, + ) + + walletAmount := math.NewInt(1_000_000_000_000) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, gaia) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser, gaiaUser := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + gaiaUserAddr := gaiaUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + gaiaOrigBal, err := gaia.GetBalance(ctx, gaiaUserAddr, gaia.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, gaiaOrigBal) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: dymRollAppChan.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + t.Run("multihop gaia->dym->rollapp", func(t *testing.T) { + + firstHopDenom := transfertypes.GetPrefixedDenom(dymGaiaChan.PortID, dymGaiaChan.ChannelID, gaia.Config().Denom) + secondHopDenom := transfertypes.GetPrefixedDenom(rollappDymChan.PortID, rollappDymChan.ChannelID, firstHopDenom) + + firstHopDenomTrace := transfertypes.ParseDenomTrace(firstHopDenom) + secondHopDenomTrace := transfertypes.ParseDenomTrace(secondHopDenom) + + firstHopIBCDenom := firstHopDenomTrace.IBCDenom() + secondHopIBCDenom := secondHopDenomTrace.IBCDenom() + + zeroBal := math.ZeroInt() + transferAmount := math.NewInt(100_000) + + // Send packet from gaia -> dym -> rollapp1 + transfer := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: gaia.Config().Denom, + Amount: transferAmount, + } + + firstHopMetadata := &PacketMetadata{ + Forward: &ForwardMetadata{ + Receiver: rollappUserAddr, + Channel: dymRollAppChan.ChannelID, + Port: dymRollAppChan.PortID, + Timeout: 5 * time.Minute, + }, + } + + memo, err := json.Marshal(firstHopMetadata) + require.NoError(t, err) + + transferTx, err := gaia.SendIBCTransfer(ctx, gaiaDymChan.ChannelID, gaiaUser.KeyName(), transfer, ibc.TransferOptions{Memo: string(memo)}) + require.NoError(t, err) + err = transferTx.Validate() + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + err = testutil.WaitForBlocks(ctx, 20, dymension, gaia) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, gaia.Config().Denom, walletAmount.Sub(transferAmount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, zeroBal) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, secondHopIBCDenom, transferAmount) + }) +} \ No newline at end of file diff --git a/tests/setup.go b/tests/setup.go index 1ac71f01..866731f3 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -101,7 +101,7 @@ var ( gaiaConfig = ibc.ChainConfig{ Type: "cosmos", Name: "gaia", - ChainID: "gaia-1", + ChainID: "gaia_1", Images: []ibc.DockerImage{gaiaImage}, Bin: "gaiad", Bech32Prefix: "cosmos", From 8a2858687c3b06ce78b2970e650eedcd6bead22e Mon Sep 17 00:00:00 2001 From: lacsomot <153717732+lacsomot@users.noreply.github.com> Date: Wed, 24 Apr 2024 14:56:18 +0700 Subject: [PATCH 17/61] 3rd party demand orders tests (#125) --- .github/workflows/e2e-test-workflow-call.yml | 2 + .github/workflows/e2e_test.yml | 2 + Makefile | 19 +- tests/eibc_fulfillment_test.go | 869 +++++++++++++++++++ 4 files changed, 889 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 7e2fab07..ddcb603c 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -30,6 +30,7 @@ jobs: - "e2e-test-eibc-excessive-fee-evm" - "e2e-test-eibc-fulfillment-evm" - "e2e-test-eibc-fulfill-no-balance-evm" + - "e2e-test-eibc-fulfillment-thirdparty-evm" - "e2e-test-eibc-pfm-evm" - "e2e-test-eibc-timeout-evm" - "e2e-test-transfer-multi-hop-evm" @@ -77,6 +78,7 @@ jobs: - "e2e-test-ibc-timeout-wasm" - "e2e-test-ibc-grace-period-wasm" - "e2e-test-eibc-fulfillment-wasm" + - "e2e-test-eibc-fulfillment-thirdparty-wasm" - "e2e-test-eibc-pfm-wasm" - "e2e-test-transfer-multi-hop-wasm" - "e2e-test-pfm-with-grace-period-wasm" diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 186c73c4..e07f12e4 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -32,6 +32,7 @@ jobs: - "e2e-test-eibc-excessive-fee-evm" - "e2e-test-eibc-fulfillment-evm" - "e2e-test-eibc-fulfill-no-balance-evm" + - "e2e-test-eibc-fulfillment-thirdparty-evm" - "e2e-test-eibc-pfm-evm" - "e2e-test-eibc-timeout-evm" - "e2e-test-transfer-multi-hop-evm" @@ -65,6 +66,7 @@ jobs: - "e2e-test-ibc-timeout-wasm" - "e2e-test-ibc-grace-period-wasm" - "e2e-test-eibc-fulfillment-wasm" + - "e2e-test-eibc-fulfillment-thirdparty-wasm" - "e2e-test-eibc-pfm-wasm" - "e2e-test-transfer-multi-hop-wasm" - "e2e-test-pfm-with-grace-period-wasm" diff --git a/Makefile b/Makefile index ddb3f4d4..53f610d2 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,10 @@ e2e-test-other-rollapp-not-affected-evm: clean-e2e e2e-test-rollapp-genesis-event-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollappGenesisEvent_EVM . +e2e-test-eibc-fulfillment-thirdparty-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_ThirdParty_EVM . + +# Executes IBC tests via rollup-e2e-testing e2e-test-ibc-success-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferSuccess_Wasm . @@ -95,6 +99,9 @@ e2e-test-rollapp-freeze-wasm: clean-e2e e2e-test-other-rollapp-not-affected-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestOtherRollappNotAffected_Wasm . +e2e-test-eibc-fulfillment-thirdparty-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_ThirdParty_Wasm . + e2e-test-pfm-gaia-to-rollapp-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferGaiaToRollApp_EVM . @@ -108,7 +115,8 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-eibc-corrupted-memo-evm \ e2e-test-eibc-excessive-fee-evm \ e2e-test-eibc-fulfillment-evm \ - e2e-test-eibc-fulfill-no-balance-evm \ + e2e-test-eibc-fulfill-no-balance-evm \ + e2e-test-eibc-fulfillment-thirdparty-evm \ e2e-test-eibc-pfm-evm \ e2e-test-eibc-timeout-evm \ e2e-test-transfer-multi-hop-evm \ @@ -118,12 +126,14 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-disconnection-evm \ e2e-test-rollapp-freeze-evm \ e2e-test-other-rollapp-not-affected-evm \ + e2e-test-rollapp-genesis-event-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ e2e-test-ibc-grace-period-wasm \ - e2e-test-transfer-multi-hop-wasm \ e2e-test-eibc-fulfillment-wasm \ + e2e-test-eibc-fulfillment-thirdparty-wasm \ e2e-test-eibc-pfm-wasm \ + e2e-test-transfer-multi-hop-wasm \ e2e-test-pfm-with-grace-period-wasm \ e2e-test-pfm-gaia-to-rollapp-wasm \ e2e-test-batch-finalization-wasm \ @@ -140,6 +150,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-eibc-excessive-fee-evm \ e2e-test-eibc-fulfillment-evm \ e2e-test-eibc-fulfill-no-balance-evm \ + e2e-test-eibc-fulfillment-thirdparty-evm \ e2e-test-eibc-pfm-evm \ e2e-test-eibc-timeout-evm \ e2e-test-transfer-multi-hop-evm \ @@ -148,11 +159,13 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-evm \ e2e-test-disconnection-evm \ e2e-test-rollapp-freeze-evm \ - e2e-test-other-rollapp-not-affected-evm \ + e2e-test-other-rollapp-not-affected-evm \ + e2e-test-rollapp-genesis-event-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ e2e-test-ibc-grace-period-wasm \ e2e-test-eibc-fulfillment-wasm \ + e2e-test-eibc-fulfillment-thirdparty-wasm \ e2e-test-eibc-pfm-wasm \ e2e-test-transfer-multi-hop-wasm \ e2e-test-pfm-with-grace-period-wasm \ diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 921a835f..e0529fdb 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -672,6 +672,852 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { ) } +// This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub +// with third party ibc token that is fulfilled by the market maker +func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + const BLOCK_FINALITY_PERIOD = 50 + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Disable erc20 + modifyRollappGeneisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.erc20.params.enable_erc20", + Value: false, + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + numVals := 1 + numFullNodes := 0 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(modifyRollappGeneisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(modifyRollappGeneisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + { + Name: "gaia", + Version: "v14.2.0", + ChainConfig: gaiaConfig, + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + gaia := chains[3].(*cosmos.CosmosChain) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + ).Build(t, client, "relayer2", network) + + r3 := test.NewBuiltinRelayerFactory( + ibc.CosmosRly, + zaptest.NewLogger(t), + relayer.CustomDockerImage(IBCRelayerImage, IBCRelayerVersion, "100:1000"), + ).Build(t, client, "relayer3", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddChain(gaia). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddRelayer(r3, "relayer3"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: gaia, + Relayer: r3, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + err = r1.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) + require.NoError(t, err) + err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, ibcPath) + require.NoError(t, err) + err = r3.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r1.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + err = r2.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + err = r3.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r1.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + r2.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + r3.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r1.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r3.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + err = r1.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + err = r2.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + err = r3.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) + + walletAmount := math.NewInt(1_000_000_000_000) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, gaia) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollapp1User, gaiaUser := users[0], users[1], users[2], users[3] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollapp1UserAddr := rollapp1User.FormattedAddress() + gaiaUserAddr := gaiaUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, gaia.Config().Denom, walletAmount) + + transferAmount := math.NewInt(1_000_000) + bigTransferAmount := math.NewInt(1_000_000_000) + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 3, len(dymChannels)) + + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp2, 1) + + gaiaChannels, err := r3.GetChannels(ctx, eRep, gaia.GetChainID()) + require.NoError(t, err) + + require.Len(t, dymChannels, 3) + require.Len(t, gaiaChannels, 1) + + channDymGaia := gaiaChannels[0].Counterparty + require.NotEmpty(t, channDymGaia.ChannelID) + + channGaiaDym := gaiaChannels[0] + require.NotEmpty(t, channGaiaDym.ChannelID) + + triggerHubGenesisEvent(t, dymension, rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channsRollApp1[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + triggerHubGenesisEvent(t, dymension, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channsRollApp2[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r3.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: gaia.Config().Denom, + Amount: bigTransferAmount, + } + + // Get the IBC denom + gaiaTokenDenom := transfertypes.GetPrefixedDenom(channDymGaia.PortID, channDymGaia.ChannelID, gaia.Config().Denom) + gaiaIBCDenom := transfertypes.ParseDenomTrace(gaiaTokenDenom).IBCDenom() + + secondHopDenom := transfertypes.GetPrefixedDenom(channsRollApp1[0].PortID, channsRollApp1[0].ChannelID, gaiaTokenDenom) + secondHopIBCDenom := transfertypes.ParseDenomTrace(secondHopDenom).IBCDenom() + + // First hop + var options ibc.TransferOptions + _, err = gaia.SendIBCTransfer(ctx, channGaiaDym.ChannelID, gaiaUserAddr, transferData, options) + require.NoError(t, err) + + t.Log("gaiaIBCDenom:", gaiaIBCDenom) + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + balance, err := dymension.GetBalance(ctx, dymensionUserAddr, gaiaIBCDenom) + require.NoError(t, err) + require.True(t, balance.Equal(bigTransferAmount), fmt.Sprintf("Value mismatch. Expected %s, actual %s", bigTransferAmount, balance)) + + transferData = ibc.WalletData{ + Address: rollapp1UserAddr, + Denom: gaiaIBCDenom, + Amount: bigTransferAmount, + } + + // Second hop + _, err = dymension.SendIBCTransfer(ctx, channsRollApp1[0].Counterparty.ChannelID, dymensionUserAddr, transferData, options) + require.NoError(t, err) + + balance, err = rollapp1.GetBalance(ctx, rollapp1UserAddr, secondHopIBCDenom) + require.NoError(t, err) + require.True(t, balance.Equal(bigTransferAmount), fmt.Sprintf("Value mismatch. Expected %s, actual %s", bigTransferAmount, balance)) + + transferData = ibc.WalletData{ + Address: marketMakerAddr, + Denom: secondHopIBCDenom, + Amount: transferAmount, + } + + // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, options) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) + require.NoError(t, err) + require.True(t, balance.Equal(transferAmount), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmount, balance)) + // done preparation + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: secondHopIBCDenom, + Amount: transferAmount, + } + + options.Memo = BuildEIbcMemo(eibcFee) + + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, options) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + fmt.Println("Event:", eibcEvents[0]) + + // fulfill demand order + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr) + require.NoError(t, err) + fmt.Println(txhash) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, gaiaIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmountWithoutFee), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalance := transferAmount.Sub((transferAmountWithoutFee)) + require.True(t, balance.Equal(expMmBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalance, balance)) + + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + expMmBalance = expMmBalance.Add(transferData.Amount) + require.True(t, balance.Equal(expMmBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalance, balance)) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + + err = r3.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +// This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub +// with third party ibc token that is fulfilled by the market maker +func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + const BLOCK_FINALITY_PERIOD = 50 + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + numVals := 1 + numFullNodes := 0 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + { + Name: "gaia", + Version: "v14.2.0", + ChainConfig: gaiaConfig, + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + gaia := chains[3].(*cosmos.CosmosChain) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + ).Build(t, client, "relayer2", network) + // Relayer for gaia + r3 := test.NewBuiltinRelayerFactory( + ibc.CosmosRly, + zaptest.NewLogger(t), + relayer.CustomDockerImage(IBCRelayerImage, IBCRelayerVersion, "100:1000"), + ).Build(t, client, "relayer3", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddChain(gaia). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddRelayer(r3, "relayer3"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: gaia, + Relayer: r3, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath) + CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) + + walletAmount := math.NewInt(1_000_000_000_000) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, gaia) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollapp1User, gaiaUser := users[0], users[1], users[2], users[3] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollapp1UserAddr := rollapp1User.FormattedAddress() + gaiaUserAddr := gaiaUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, gaia.Config().Denom, walletAmount) + + transferAmount := math.NewInt(1_000_000) + bigTransferAmount := math.NewInt(1_000_000_000) + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 3, len(dymChannels)) + + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp2, 1) + + gaiaChannels, err := r3.GetChannels(ctx, eRep, gaia.GetChainID()) + require.NoError(t, err) + + require.Len(t, dymChannels, 3) + require.Len(t, gaiaChannels, 1) + + channDymGaia := gaiaChannels[0].Counterparty + require.NotEmpty(t, channDymGaia.ChannelID) + + channGaiaDym := gaiaChannels[0] + require.NotEmpty(t, channGaiaDym.ChannelID) + + triggerHubGenesisEvent(t, dymension, rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channsRollApp1[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + triggerHubGenesisEvent(t, dymension, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channsRollApp2[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r3.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: gaia.Config().Denom, + Amount: bigTransferAmount, + } + + // Get the IBC denom + gaiaTokenDenom := transfertypes.GetPrefixedDenom(channDymGaia.PortID, channDymGaia.ChannelID, gaia.Config().Denom) + gaiaIBCDenom := transfertypes.ParseDenomTrace(gaiaTokenDenom).IBCDenom() + + secondHopDenom := transfertypes.GetPrefixedDenom(channsRollApp1[0].PortID, channsRollApp1[0].ChannelID, gaiaTokenDenom) + secondHopIBCDenom := transfertypes.ParseDenomTrace(secondHopDenom).IBCDenom() + + // First hop + var options ibc.TransferOptions + _, err = gaia.SendIBCTransfer(ctx, channGaiaDym.ChannelID, gaiaUserAddr, transferData, options) + require.NoError(t, err) + + t.Log("gaiaIBCDenom:", gaiaIBCDenom) + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + balance, err := dymension.GetBalance(ctx, dymensionUserAddr, gaiaIBCDenom) + require.NoError(t, err) + require.True(t, balance.Equal(bigTransferAmount), fmt.Sprintf("Value mismatch. Expected %s, actual %s", bigTransferAmount, balance)) + + transferData = ibc.WalletData{ + Address: rollapp1UserAddr, + Denom: gaiaIBCDenom, + Amount: bigTransferAmount, + } + + // Second hop + _, err = dymension.SendIBCTransfer(ctx, channsRollApp1[0].Counterparty.ChannelID, dymensionUserAddr, transferData, options) + require.NoError(t, err) + + balance, err = rollapp1.GetBalance(ctx, rollapp1UserAddr, secondHopIBCDenom) + require.NoError(t, err) + require.True(t, balance.Equal(bigTransferAmount), fmt.Sprintf("Value mismatch. Expected %s, actual %s", bigTransferAmount, balance)) + + transferData = ibc.WalletData{ + Address: marketMakerAddr, + Denom: secondHopIBCDenom, + Amount: transferAmount, + } + + // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, options) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) + require.NoError(t, err) + require.True(t, balance.Equal(transferAmount), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmount, balance)) + // done preparation + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: secondHopIBCDenom, + Amount: transferAmount, + } + + options.Memo = BuildEIbcMemo(eibcFee) + + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, options) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + fmt.Println("Event:", eibcEvents[0]) + + // fulfill demand order + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr) + require.NoError(t, err) + fmt.Println(txhash) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, gaiaIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmountWithoutFee), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalance := transferAmount.Sub((transferAmountWithoutFee)) + require.True(t, balance.Equal(expMmBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalance, balance)) + + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + expMmBalance = expMmBalance.Add(transferData.Amount) + require.True(t, balance.Equal(expMmBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalance, balance)) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + + err = r3.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + func getEibcEventFromTx(t *testing.T, dymension *dym_hub.DymHub, txhash string) *dymensiontesting.EibcEvent { txResp, err := dymension.GetTransaction(txhash) if err != nil { @@ -776,3 +1622,26 @@ func getEventsOfType(chain *cosmos.CosmosChain, startHeight uint64, endHeight ui func BuildEIbcMemo(eibcFee math.Int) string { return fmt.Sprintf(`{"eibc": {"fee": "%s"}}`, eibcFee.String()) } + +func CreateChannel(ctx context.Context, t *testing.T, r ibc.Relayer, eRep *testreporter.RelayerExecReporter, chainA, chainB *cosmos.CosmosChain, ibcPath string) { + err := r.GeneratePath(ctx, eRep, chainA.Config().ChainID, chainB.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, chainA) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, chainA) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) +} From 218259b0c13e90916a8dd332b5db5e83f2c700dd Mon Sep 17 00:00:00 2001 From: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Date: Thu, 25 Apr 2024 11:41:47 +0700 Subject: [PATCH 18/61] chore!: Bump relayer version (#129) --- tests/eibc_corrupted_memo_test.go | 2 +- tests/eibc_fee_test.go | 2 +- tests/eibc_fulfillment_test.go | 8 ++++---- tests/eibc_nobalance_test.go | 2 +- tests/eibc_pfm_test.go | 8 ++++---- tests/eibc_timeout_test.go | 2 +- tests/frozen_test.go | 16 ++++++++-------- tests/ibc_grace_period_test.go | 10 ++++------ tests/ibc_pfm_test.go | 4 ++-- tests/ibc_pfm_with_grace_period_test.go | 4 ++-- tests/ibc_timeout_test.go | 4 ++-- tests/ibc_transfer_test.go | 7 ++----- tests/rollapp_genesis_event_test.go | 2 +- 13 files changed, 33 insertions(+), 38 deletions(-) diff --git a/tests/eibc_corrupted_memo_test.go b/tests/eibc_corrupted_memo_test.go index f70fd060..f98d36c0 100644 --- a/tests/eibc_corrupted_memo_test.go +++ b/tests/eibc_corrupted_memo_test.go @@ -109,7 +109,7 @@ func TestEIBCCorruptedMemoNegative(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) const ibcPath = "ibc-path" ic := test.NewSetup(). diff --git a/tests/eibc_fee_test.go b/tests/eibc_fee_test.go index 8c816a70..01f7bf0e 100644 --- a/tests/eibc_fee_test.go +++ b/tests/eibc_fee_test.go @@ -109,7 +109,7 @@ func TestEIBCFeeTooHigh(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) const ibcPath = "ibc-path" ic := test.NewSetup(). diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index e0529fdb..7249dcba 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -141,11 +141,11 @@ func TestEIBCFulfillment_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -470,11 +470,11 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/eibc_nobalance_test.go b/tests/eibc_nobalance_test.go index e91babfb..1549b957 100644 --- a/tests/eibc_nobalance_test.go +++ b/tests/eibc_nobalance_test.go @@ -110,7 +110,7 @@ func TestEIBCNoBalanceToFulfillOrder(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) const ibcPath = "ibc-path" ic := test.NewSetup(). diff --git a/tests/eibc_pfm_test.go b/tests/eibc_pfm_test.go index 781f0749..47b6d051 100644 --- a/tests/eibc_pfm_test.go +++ b/tests/eibc_pfm_test.go @@ -139,11 +139,11 @@ func TestEIBCPFM_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -462,11 +462,11 @@ func TestEIBCPFM_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/eibc_timeout_test.go b/tests/eibc_timeout_test.go index 2e2a7cf8..4dd50a35 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -106,7 +106,7 @@ func TestEIBCTimeoutHubToRollapp(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) const ibcPath = "ibc-path" ic := test.NewSetup(). diff --git a/tests/frozen_test.go b/tests/frozen_test.go index 186dd649..517f1657 100644 --- a/tests/frozen_test.go +++ b/tests/frozen_test.go @@ -132,11 +132,11 @@ func TestRollAppFreeze_EVM(t *testing.T) { // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -508,11 +508,11 @@ func TestRollAppFreeze_Wasm(t *testing.T) { // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -924,11 +924,11 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) s := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -1398,11 +1398,11 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) s := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/ibc_grace_period_test.go b/tests/ibc_grace_period_test.go index 090cc7b3..06ae4e67 100644 --- a/tests/ibc_grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -42,7 +42,6 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { gas_price_rollapp2 := "0adym" configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) - modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -137,11 +136,11 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -348,7 +347,6 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { gas_price_rollapp2 := "0adym" configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) - modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -443,11 +441,11 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/ibc_pfm_test.go b/tests/ibc_pfm_test.go index 44f27f86..a7a50afd 100644 --- a/tests/ibc_pfm_test.go +++ b/tests/ibc_pfm_test.go @@ -92,7 +92,7 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) r2 := test.NewBuiltinRelayerFactory( @@ -393,7 +393,7 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) r2 := test.NewBuiltinRelayerFactory( diff --git a/tests/ibc_pfm_with_grace_period_test.go b/tests/ibc_pfm_with_grace_period_test.go index e824e11b..49db5112 100644 --- a/tests/ibc_pfm_with_grace_period_test.go +++ b/tests/ibc_pfm_with_grace_period_test.go @@ -116,7 +116,7 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { r := test.NewBuiltinRelayerFactory( ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) r2 := test.NewBuiltinRelayerFactory( @@ -458,7 +458,7 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { r := test.NewBuiltinRelayerFactory( ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) r2 := test.NewBuiltinRelayerFactory( diff --git a/tests/ibc_timeout_test.go b/tests/ibc_timeout_test.go index cb9622e1..eea65f1a 100644 --- a/tests/ibc_timeout_test.go +++ b/tests/ibc_timeout_test.go @@ -108,7 +108,7 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -362,7 +362,7 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). diff --git a/tests/ibc_transfer_test.go b/tests/ibc_transfer_test.go index 09fc3a7f..16767ed8 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -84,7 +84,7 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -305,7 +305,7 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -350,9 +350,6 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) require.NoError(t, err) diff --git a/tests/rollapp_genesis_event_test.go b/tests/rollapp_genesis_event_test.go index 4c7248c8..e44f8bc7 100644 --- a/tests/rollapp_genesis_event_test.go +++ b/tests/rollapp_genesis_event_test.go @@ -88,7 +88,7 @@ func TestRollappGenesisEvent_EVM(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). From 8091ed3dc6fd90ac0314c0759449c81bd50072a7 Mon Sep 17 00:00:00 2001 From: lacsomot <153717732+lacsomot@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:08:35 +0700 Subject: [PATCH 19/61] Check packet commitments on ibc grace period ends (#123) --- .github/workflows/e2e-test-workflow-call.yml | 2 + .github/workflows/e2e_test.yml | 2 + Makefile | 17 +- go.mod | 2 +- go.sum | 4 +- tests/eibc_fulfillment_test.go | 23 - tests/ibc_grace_period_test.go | 583 ++++++++++++++++++- tests/setup.go | 24 + 8 files changed, 619 insertions(+), 38 deletions(-) diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index ddcb603c..90134f00 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -42,6 +42,7 @@ jobs: - "e2e-test-rollapp-freeze-evm" - "e2e-test-other-rollapp-not-affected-evm" - "e2e-test-rollapp-genesis-event-evm" + - "e2e-test-delayedack-pending-packets-evm" fail-fast: false runs-on: ubuntu-latest steps: @@ -88,6 +89,7 @@ jobs: - "e2e-test-fullnode-sync-wasm" - "e2e-test-rollapp-freeze-wasm" - "e2e-test-other-rollapp-not-affected-wasm" + - "e2e-test-delayedack-pending-packets-wasm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index e07f12e4..22b25bf5 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -44,6 +44,7 @@ jobs: - "e2e-test-rollapp-freeze-evm" - "e2e-test-other-rollapp-not-affected-evm" - "e2e-test-rollapp-genesis-event-evm" + - "e2e-test-delayedack-pending-packets-evm" fail-fast: false runs-on: ubuntu-latest steps: @@ -76,6 +77,7 @@ jobs: - "e2e-test-fullnode-sync-wasm" - "e2e-test-rollapp-freeze-wasm" - "e2e-test-other-rollapp-not-affected-wasm" + - "e2e-test-delayedack-pending-packets-wasm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/Makefile b/Makefile index 53f610d2..313bdf36 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,9 @@ e2e-test-other-rollapp-not-affected-evm: clean-e2e e2e-test-rollapp-genesis-event-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollappGenesisEvent_EVM . +e2e-test-delayedack-pending-packets-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestDelayedAck_NoFinalizedStates_EVM . + e2e-test-eibc-fulfillment-thirdparty-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_ThirdParty_EVM . @@ -108,6 +111,10 @@ e2e-test-pfm-gaia-to-rollapp-evm: clean-e2e e2e-test-pfm-gaia-to-rollapp-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferGaiaToRollApp_Wasm . +e2e-test-delayedack-pending-packets-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestDelayedAck_NoFinalizedStates_Wasm . + + # Executes all tests via rollup-e2e-testing e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ @@ -115,7 +122,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-eibc-corrupted-memo-evm \ e2e-test-eibc-excessive-fee-evm \ e2e-test-eibc-fulfillment-evm \ - e2e-test-eibc-fulfill-no-balance-evm \ + e2e-test-eibc-fulfill-no-balance-evm \ e2e-test-eibc-fulfillment-thirdparty-evm \ e2e-test-eibc-pfm-evm \ e2e-test-eibc-timeout-evm \ @@ -139,7 +146,8 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-wasm \ e2e-test-disconnection-wasm \ e2e-test-rollapp-freeze-wasm \ - e2e-test-other-rollapp-not-affected-wasm + e2e-test-other-rollapp-not-affected-wasm \ + e2e-test-delayedack-pending-packets-wasm .PHONY: clean-e2e \ e2e-test-all \ @@ -159,7 +167,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-evm \ e2e-test-disconnection-evm \ e2e-test-rollapp-freeze-evm \ - e2e-test-other-rollapp-not-affected-evm \ + e2e-test-other-rollapp-not-affected-evm \ e2e-test-rollapp-genesis-event-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ @@ -173,5 +181,6 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-wasm \ e2e-test-disconnection-wasm \ e2e-test-rollapp-freeze-wasm \ - e2e-test-other-rollapp-not-affected-wasm + e2e-test-other-rollapp-not-affected-wasm \ + e2e-test-delayedack-pending-packets-wasm diff --git a/go.mod b/go.mod index 25c11298..44e549e5 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( cosmossdk.io/math v1.3.0 github.com/cosmos/cosmos-sdk v0.46.16 github.com/cosmos/ibc-go/v6 v6.2.1 - github.com/decentrio/rollup-e2e-testing v0.0.0-20240419100059-4be856e59619 + github.com/decentrio/rollup-e2e-testing v0.0.0-20240423082530-c894964c401d github.com/dymensionxyz/dymension-rdk v1.1.0-beta github.com/dymensionxyz/dymension/v3 v3.1.0-rc01.0.20240404003005-53ccf8a922fd github.com/evmos/ethermint v0.22.0 diff --git a/go.sum b/go.sum index a0d990cb..f3ab2208 100644 --- a/go.sum +++ b/go.sum @@ -328,8 +328,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240419100059-4be856e59619 h1:g+dXAUOIukmrMSiA6CgZTLbTjTbSIpIuWvYu6Nf7Ugo= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240419100059-4be856e59619/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240423082530-c894964c401d h1:py4u2CvZAWg4uQ+m3ErDcqVoxgycZcKW1L2IPtNfVp4= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240423082530-c894964c401d/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 7249dcba..c8b85e9f 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -1622,26 +1622,3 @@ func getEventsOfType(chain *cosmos.CosmosChain, startHeight uint64, endHeight ui func BuildEIbcMemo(eibcFee math.Int) string { return fmt.Sprintf(`{"eibc": {"fee": "%s"}}`, eibcFee.String()) } - -func CreateChannel(ctx context.Context, t *testing.T, r ibc.Relayer, eRep *testreporter.RelayerExecReporter, chainA, chainB *cosmos.CosmosChain, ibcPath string) { - err := r.GeneratePath(ctx, eRep, chainA.Config().ChainID, chainB.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, chainA) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, chainA) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) -} diff --git a/tests/ibc_grace_period_test.go b/tests/ibc_grace_period_test.go index 06ae4e67..4010b0ec 100644 --- a/tests/ibc_grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -3,6 +3,7 @@ package tests import ( "context" "fmt" + "strings" "testing" "cosmossdk.io/math" @@ -306,6 +307,11 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) + // Packet commitments exist + res, err := rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.NoError(t, err) + require.Equal(t, len(res.Commitments) > 0, true, "no packet commitments exist") + // wait until the packet is finalized isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) @@ -315,6 +321,13 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount) + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // No packet commitments should exist on rollapp anymore + res, err = rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.Equal(t, len(res.Commitments) == 0, true, "packet commitments still exist") + t.Cleanup( func() { err := r1.StopRelayer(ctx, eRep) @@ -478,34 +491,46 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) + err = r1.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) require.NoError(t, err) - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) - require.NoError(t, err) err = r1.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) require.NoError(t, err) - err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) err = testutil.WaitForBlocks(ctx, 30, dymension) require.NoError(t, err) r1.UpdateClients(ctx, eRep, ibcPath) require.NoError(t, err) - r2.UpdateClients(ctx, eRep, anotherIbcPath) - require.NoError(t, err) err = r1.CreateConnections(ctx, eRep, ibcPath) require.NoError(t, err) - err = r2.CreateConnections(ctx, eRep, anotherIbcPath) - require.NoError(t, err) err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) err = r1.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) require.NoError(t, err) + + err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) + require.NoError(t, err) + + err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + + r2.UpdateClients(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = r2.CreateConnections(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + err = r2.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) require.NoError(t, err) @@ -608,6 +633,11 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, math.NewInt(0)) + // Packet commitments exist + res, err := rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.NoError(t, err) + require.Equal(t, len(res.Commitments) > 0, true, "no packet commitments exist") + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -620,6 +650,543 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount) + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // No packet commitments should exist on rollapp anymore + res, err = rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.Equal(t, len(res.Commitments) == 0, true, "packet commitments still exist") + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + // Increase dispute blocks + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: "200", + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + walletAmount := math.NewInt(1_000_000_000_000) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollapp1UserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) + + // Compose an IBC transfer and send from rollapp -> dymension + transferAmount := math.NewInt(1_000_000) + + rollApp1Channel, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, rollApp1Channel, 1) + + channDymRollApp1 := rollApp1Channel[0].Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + dymChannel, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 2, len(dymChannel)) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: dymChannel[0].ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the rollapp because transfer amount was deducted from wallet balance + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // Require rollapp has no finalized states + _, err = dymension.QueryRollappState(ctx, rollapp1.GetChainID(), true) + require.Error(t, err) + require.Equal(t, strings.Contains(err.Error(), "no finalized state yet for rollapp"), true, "rollapp has finalized state index") + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + // Assert funds are waiting + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, math.NewInt(0)) + + // Packet commitments exist + res, err := rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.NoError(t, err) + require.Equal(t, len(res.Commitments) > 0, true, "no packet commitments exist") + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 600) + require.NoError(t, err) + require.True(t, isFinalized) + + // Assert balance was updated on the Hub + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // No packet commitments should exist on rollapp anymore + res, err = rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.Equal(t, len(res.Commitments) == 0, true, "packet commitments still exist") + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + // Increase dispute blocks + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: "200", + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + walletAmount := math.NewInt(1_000_000_000_000) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollapp1UserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) + + // Compose an IBC transfer and send from rollapp -> dymension + transferAmount := math.NewInt(1_000_000) + + rollApp1Channel, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, rollApp1Channel, 1) + + channDymRollApp1 := rollApp1Channel[0].Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + dymChannel, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 2, len(dymChannel)) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: dymChannel[0].ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the rollapp because transfer amount was deducted from wallet balance + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // Require rollapp has no finalized states + _, err = dymension.QueryRollappState(ctx, rollapp1.GetChainID(), true) + require.Error(t, err) + require.Equal(t, strings.Contains(err.Error(), "no finalized state yet for rollapp"), true, "rollapp has finalized state index") + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + // Assert funds are waiting + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, math.NewInt(0)) + + // Packet commitments exist + res, err := rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.NoError(t, err) + require.Equal(t, len(res.Commitments) > 0, true, "no packet commitments exist") + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 600) + require.NoError(t, err) + require.True(t, isFinalized) + + // Assert balance was updated on the Hub + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // No packet commitments should exist on rollapp anymore + res, err = rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.Equal(t, len(res.Commitments) == 0, true, "packet commitments still exist") + t.Cleanup( func() { err := r1.StopRelayer(ctx, eRep) diff --git a/tests/setup.go b/tests/setup.go index 866731f3..55acfe26 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -14,6 +14,7 @@ import ( "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/dymension" "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/testreporter" "github.com/decentrio/rollup-e2e-testing/testutil" "github.com/icza/dyno" "github.com/stretchr/testify/require" @@ -545,3 +546,26 @@ func overridesDymintToml(settlemenLayer, nodeAddress, rollappId, gasPrices, empt return configFileOverrides } + +func CreateChannel(ctx context.Context, t *testing.T, r ibc.Relayer, eRep *testreporter.RelayerExecReporter, chainA, chainB *cosmos.CosmosChain, ibcPath string) { + err := r.GeneratePath(ctx, eRep, chainA.Config().ChainID, chainB.Config().ChainID, ibcPath) + require.NoError(t, err) + + err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, chainA) + require.NoError(t, err) + + r.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r.CreateConnections(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, chainA) + require.NoError(t, err) + + err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) + require.NoError(t, err) +} From 750f95ca5f73ce173450e5313dea07cc2ff49729 Mon Sep 17 00:00:00 2001 From: lacsomot <153717732+lacsomot@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:54:49 +0700 Subject: [PATCH 20/61] Refactor create channel (#132) Co-authored-by: anhductn2001 Co-authored-by: ducnt131 <62016666+anhductn2001@users.noreply.github.com> --- tests/disconnection_test.go | 2 +- tests/eibc_corrupted_memo_test.go | 21 +-- tests/eibc_fee_test.go | 21 +-- tests/eibc_fulfillment_test.go | 118 +++------------ tests/eibc_nobalance_test.go | 21 +-- tests/eibc_pfm_test.go | 32 +--- tests/eibc_timeout_test.go | 21 +-- tests/frozen_test.go | 184 +---------------------- tests/ibc_grace_period_test.go | 74 +--------- tests/ibc_pfm_test.go | 186 ++---------------------- tests/ibc_pfm_with_grace_period_test.go | 92 +----------- tests/ibc_timeout_test.go | 42 +----- tests/ibc_transfer_test.go | 21 +-- tests/rollapp_genesis_event_test.go | 21 +-- 14 files changed, 59 insertions(+), 797 deletions(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index 1f937a20..d1f93a53 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -249,7 +249,7 @@ func TestDisconnection_Wasm(t *testing.T) { err = dymension.StartAllNodes(ctx) require.NoError(t, err) - // Make sure rollapp start pro + // Make sure rollapp start produce blocks err = testutil.WaitForBlocks(ctx, 1, rollapp1) require.NoError(t, err) }) diff --git a/tests/eibc_corrupted_memo_test.go b/tests/eibc_corrupted_memo_test.go index f98d36c0..f68616ce 100644 --- a/tests/eibc_corrupted_memo_test.go +++ b/tests/eibc_corrupted_memo_test.go @@ -136,26 +136,7 @@ func TestEIBCCorruptedMemoNegative(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) walletAmount := math.NewInt(1_000_000_000_000) diff --git a/tests/eibc_fee_test.go b/tests/eibc_fee_test.go index 01f7bf0e..cd539008 100644 --- a/tests/eibc_fee_test.go +++ b/tests/eibc_fee_test.go @@ -136,26 +136,7 @@ func TestEIBCFeeTooHigh(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) walletAmount := math.NewInt(1_000_000_000_000) diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index c8b85e9f..707dea45 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -179,36 +179,8 @@ func TestEIBCFulfillment_EVM(t *testing.T) { }) require.NoError(t, err) - err = r1.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) - require.NoError(t, err) - - err = r1.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r1.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - r2.UpdateClients(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = r1.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - err = r2.CreateConnections(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r1.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - err = r2.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) walletAmount := math.NewInt(1_000_000_000_000) @@ -508,26 +480,8 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { }) require.NoError(t, err) - err = r1.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r1.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r1.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r1.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r1.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) walletAmount := math.NewInt(1_000_000_000_000) @@ -556,8 +510,19 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 transferAmountWithoutFee := transferAmount.Sub(eibcFee) - channel, err := ibc.GetTransferChannel(ctx, r1, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 2, len(dymChannels)) + + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp2, 1) + + require.Len(t, dymChannels, 2) // Start relayer err = r1.StartRelayer(ctx, eRep, ibcPath) @@ -570,7 +535,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { rollapp := rollappParam{ rollappID: rollapp1.Config().ChainID, - channelID: channel.ChannelID, + channelID: channsRollApp1[0].Counterparty.ChannelID, userKey: dymensionUser.KeyName(), } triggerHubGenesisEvent(t, dymension, rollapp) @@ -582,12 +547,12 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { } // Get the IBC denom for urax on Hub - rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappTokenDenom := transfertypes.GetPrefixedDenom(channsRollApp1[0].Counterparty.PortID, channsRollApp1[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() var options ibc.TransferOptions // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, options) + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -613,7 +578,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { // set eIBC specific memo options.Memo = BuildEIbcMemo(eibcFee) - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, options) + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -861,46 +826,9 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { }) require.NoError(t, err) - err = r1.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, ibcPath) - require.NoError(t, err) - err = r3.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r1.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - err = r2.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - err = r3.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r1.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - r2.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - r3.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r1.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - err = r2.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - err = r3.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r1.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - err = r2.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - err = r3.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath) + CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) walletAmount := math.NewInt(1_000_000_000_000) diff --git a/tests/eibc_nobalance_test.go b/tests/eibc_nobalance_test.go index 1549b957..516790d4 100644 --- a/tests/eibc_nobalance_test.go +++ b/tests/eibc_nobalance_test.go @@ -137,26 +137,7 @@ func TestEIBCNoBalanceToFulfillOrder(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) walletAmount := math.NewInt(1_000_000_000_000) diff --git a/tests/eibc_pfm_test.go b/tests/eibc_pfm_test.go index 47b6d051..e56df9b9 100644 --- a/tests/eibc_pfm_test.go +++ b/tests/eibc_pfm_test.go @@ -177,36 +177,8 @@ func TestEIBCPFM_EVM(t *testing.T) { }) require.NoError(t, err) - err = r1.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) - require.NoError(t, err) - - err = r1.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r1.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - r2.UpdateClients(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = r1.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - err = r2.CreateConnections(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r1.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - err = r2.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) // Start both relayers err = r1.StartRelayer(ctx, eRep, ibcPath) diff --git a/tests/eibc_timeout_test.go b/tests/eibc_timeout_test.go index 4dd50a35..38db4125 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -133,26 +133,7 @@ func TestEIBCTimeoutHubToRollapp(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) walletAmount := math.NewInt(1_000_000_000_000) diff --git a/tests/frozen_test.go b/tests/frozen_test.go index 517f1657..1e59e42a 100644 --- a/tests/frozen_test.go +++ b/tests/frozen_test.go @@ -170,50 +170,8 @@ func TestRollAppFreeze_EVM(t *testing.T) { }) require.NoError(t, err) - err = r1.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r1.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r1.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r1.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r1.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) - require.NoError(t, err) - - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) - require.NoError(t, err) - - err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r2.UpdateClients(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = r2.CreateConnections(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) - require.NoError(t, err) - - err = r2.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) // Start both relayers err = r1.StartRelayer(ctx, eRep, ibcPath) @@ -546,50 +504,8 @@ func TestRollAppFreeze_Wasm(t *testing.T) { }) require.NoError(t, err) - err = r1.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r1.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r1.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r1.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r1.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) - require.NoError(t, err) - - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) - require.NoError(t, err) - - err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r2.UpdateClients(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = r2.CreateConnections(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) - require.NoError(t, err) - - err = r2.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) // Start both relayers err = r1.StartRelayer(ctx, eRep, ibcPath) @@ -962,50 +878,8 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) - require.NoError(t, err) - - err = s.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) - require.NoError(t, err) - - err = s.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - s.UpdateClients(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = s.CreateConnections(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) - require.NoError(t, err) - - err = s.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) require.NoError(t, err) @@ -1436,50 +1310,8 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) - require.NoError(t, err) - - err = s.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) - require.NoError(t, err) - - err = s.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - s.UpdateClients(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = s.CreateConnections(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) - require.NoError(t, err) - - err = s.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) // Start both relayers err = r.StartRelayer(ctx, eRep, ibcPath) diff --git a/tests/ibc_grace_period_test.go b/tests/ibc_grace_period_test.go index 4010b0ec..28872722 100644 --- a/tests/ibc_grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -174,36 +174,9 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), }) require.NoError(t, err) - err = r1.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) - require.NoError(t, err) - - err = r1.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r1.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - r2.UpdateClients(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = r1.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - err = r2.CreateConnections(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r1.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - err = r2.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) walletAmount := math.NewInt(1_000_000_000_000) @@ -492,47 +465,8 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { }) require.NoError(t, err) - err = r1.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r1.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r1.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r1.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r1.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) - require.NoError(t, err) - - err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r2.UpdateClients(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = r2.CreateConnections(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r2.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) walletAmount := math.NewInt(1_000_000_000_000) diff --git a/tests/ibc_pfm_test.go b/tests/ibc_pfm_test.go index a7a50afd..061f2395 100644 --- a/tests/ibc_pfm_test.go +++ b/tests/ibc_pfm_test.go @@ -136,50 +136,8 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { _ = ic.Close() }) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r2.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension, gaia) - require.NoError(t, err) - - r2.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r2.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - err = r2.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, ibcPath) err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) require.NoError(t, err) @@ -437,50 +395,8 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { _ = ic.Close() }) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r2.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension, gaia) - require.NoError(t, err) - - r2.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r2.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - err = r2.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, ibcPath) err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) require.NoError(t, err) @@ -730,50 +646,8 @@ func TestIBCTransferGaiaToRollApp_EVM(t *testing.T) { _ = ic.Close() }) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, anotherIbcPath) - require.NoError(t, err) - - err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension, gaia) - require.NoError(t, err) - - r2.UpdateClients(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = r2.CreateConnections(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, gaia) - require.NoError(t, err) - - err = r2.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) require.NoError(t, err) @@ -1019,50 +893,8 @@ func TestIBCTransferGaiaToRollApp_Wasm(t *testing.T) { _ = ic.Close() }) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, anotherIbcPath) - require.NoError(t, err) - - err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension, gaia) - require.NoError(t, err) - - r2.UpdateClients(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = r2.CreateConnections(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, gaia) - require.NoError(t, err) - - err = r2.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) require.NoError(t, err) @@ -1200,4 +1032,4 @@ func TestIBCTransferGaiaToRollApp_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, secondHopIBCDenom, transferAmount) }) -} \ No newline at end of file +} diff --git a/tests/ibc_pfm_with_grace_period_test.go b/tests/ibc_pfm_with_grace_period_test.go index 49db5112..939dae37 100644 --- a/tests/ibc_pfm_with_grace_period_test.go +++ b/tests/ibc_pfm_with_grace_period_test.go @@ -160,50 +160,8 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { _ = ic.Close() }) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r2.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension, gaia) - require.NoError(t, err) - - r2.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r2.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - err = r2.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, ibcPath) err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) require.NoError(t, err) @@ -502,50 +460,8 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { _ = ic.Close() }) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, gaia.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r2.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension, gaia) - require.NoError(t, err) - - r2.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r2.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - err = r2.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, ibcPath) err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) require.NoError(t, err) diff --git a/tests/ibc_timeout_test.go b/tests/ibc_timeout_test.go index eea65f1a..6bdbf316 100644 --- a/tests/ibc_timeout_test.go +++ b/tests/ibc_timeout_test.go @@ -135,26 +135,7 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) walletAmount := math.NewInt(1_000_000_000_000) @@ -389,26 +370,7 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) walletAmount := math.NewInt(1_000_000_000_000) diff --git a/tests/ibc_transfer_test.go b/tests/ibc_transfer_test.go index 16767ed8..411fc56c 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -111,26 +111,7 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) walletAmount := math.NewInt(1_000_000_000_000) diff --git a/tests/rollapp_genesis_event_test.go b/tests/rollapp_genesis_event_test.go index e44f8bc7..503efc9d 100644 --- a/tests/rollapp_genesis_event_test.go +++ b/tests/rollapp_genesis_event_test.go @@ -115,26 +115,7 @@ func TestRollappGenesisEvent_EVM(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) walletAmount := math.NewInt(1_000_000_000_000) From 75920c81eb53b0c8db46b1c7b3320074ecf86e75 Mon Sep 17 00:00:00 2001 From: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Date: Fri, 26 Apr 2024 00:03:37 +0700 Subject: [PATCH 21/61] Remove Claims module (#137) --- tests/setup.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/setup.go b/tests/setup.go index 55acfe26..fa5b2278 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -130,10 +130,7 @@ var ( Key: "app_state.evm.params.evm_denom", Value: "urax", }, - { - Key: "app_state.claims.params.claims_denom", - Value: "urax", - }, + { Key: "consensus_params.block.max_gas", Value: "40000000", From 1f943afb06021a6392fbb3147cb1f56f1bd6bfb6 Mon Sep 17 00:00:00 2001 From: lacsomot <153717732+lacsomot@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:49:11 +0700 Subject: [PATCH 22/61] Test delayed ack relayer down (#134) --- .github/workflows/e2e-test-workflow-call.yml | 2 + .github/workflows/e2e_test.yml | 2 + Makefile | 9 +- tests/ibc_grace_period_test.go | 562 +++++++++++++++++++ 4 files changed, 574 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 90134f00..442a20cb 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -43,6 +43,7 @@ jobs: - "e2e-test-other-rollapp-not-affected-evm" - "e2e-test-rollapp-genesis-event-evm" - "e2e-test-delayedack-pending-packets-evm" + - "e2e-test-delayedack-relayer-down-evm" fail-fast: false runs-on: ubuntu-latest steps: @@ -90,6 +91,7 @@ jobs: - "e2e-test-rollapp-freeze-wasm" - "e2e-test-other-rollapp-not-affected-wasm" - "e2e-test-delayedack-pending-packets-wasm" + - "e2e-test-delayedack-relayer-down-wasm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 22b25bf5..19d9901c 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -45,6 +45,7 @@ jobs: - "e2e-test-other-rollapp-not-affected-evm" - "e2e-test-rollapp-genesis-event-evm" - "e2e-test-delayedack-pending-packets-evm" + - "e2e-test-delayedack-relayer-down-evm" fail-fast: false runs-on: ubuntu-latest steps: @@ -78,6 +79,7 @@ jobs: - "e2e-test-rollapp-freeze-wasm" - "e2e-test-other-rollapp-not-affected-wasm" - "e2e-test-delayedack-pending-packets-wasm" + - "e2e-test-delayedack-relayer-down-wasm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/Makefile b/Makefile index 313bdf36..af6c9fc1 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,9 @@ e2e-test-delayedack-pending-packets-evm: clean-e2e e2e-test-eibc-fulfillment-thirdparty-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_ThirdParty_EVM . +e2e-test-delayedack-relayer-down-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestDelayedAck_RelayerDown_EVM . + # Executes IBC tests via rollup-e2e-testing e2e-test-ibc-success-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferSuccess_Wasm . @@ -113,6 +116,9 @@ e2e-test-pfm-gaia-to-rollapp-wasm: clean-e2e e2e-test-delayedack-pending-packets-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_NoFinalizedStates_Wasm . + +e2e-test-delayedack-relayer-down-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestDelayedAck_RelayerDown_Wasm . # Executes all tests via rollup-e2e-testing @@ -147,7 +153,8 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-disconnection-wasm \ e2e-test-rollapp-freeze-wasm \ e2e-test-other-rollapp-not-affected-wasm \ - e2e-test-delayedack-pending-packets-wasm + e2e-test-delayedack-pending-packets-wasm \ + e2e-test-delayedack-relayer-down-wasm .PHONY: clean-e2e \ e2e-test-all \ diff --git a/tests/ibc_grace_period_test.go b/tests/ibc_grace_period_test.go index 28872722..f011fbc6 100644 --- a/tests/ibc_grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -1130,3 +1130,565 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { }, ) } + +func TestDelayedAck_RelayerDown_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + // Increase dispute blocks + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: "20", + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + walletAmount := math.NewInt(1_000_000_000_000) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollapp1UserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) + + // Compose an IBC transfer and send from rollapp -> dymension + transferAmount := math.NewInt(1_000_000) + + rollApp1Channel, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, rollApp1Channel, 1) + + channDymRollApp1 := rollApp1Channel[0].Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + dymChannel, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 2, len(dymChannel)) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: dymChannel[0].ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + transferData := ibc.WalletData{ + Address: rollapp1UserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Stop replayer right before sending IBC Transfer + err = r1.StopRelayer(ctx, eRep) + require.NoError(t, err) + + _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the hub because transfer amount was deducted from wallet balance + + // Get the IBC denom for urax on rollapp + dymTokenDenom := transfertypes.GetPrefixedDenom(rollApp1Channel[0].PortID, rollApp1Channel[0].ChannelID, dymension.Config().Denom) + dymIBCDenom := transfertypes.ParseDenomTrace(dymTokenDenom).IBCDenom() + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + // Assert balance was updated on the hub because transfer amount was deducted from wallet balance + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + // Assert funds are waiting + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymIBCDenom, math.NewInt(0)) + + // Packet commitments exist + res, err := dymension.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.NoError(t, err) + require.Equal(t, len(res.Commitments) > 0, true, "no packet commitments exist") + + // Restart Relayer + r1.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 600) + require.NoError(t, err) + require.True(t, isFinalized) + + t.Log("rollapp1UserAddr:", rollapp1UserAddr) + t.Log("dymIBCDenom:", dymIBCDenom) + // Assert balance was updated on rollapp + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymIBCDenom, transferData.Amount) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // No packet commitments should exist on rollapp anymore + res, err = rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.Equal(t, len(res.Commitments) == 0, true, "packet commitments still exist") + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + // Increase dispute blocks + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: "20", + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + walletAmount := math.NewInt(1_000_000_000_000) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollapp1UserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) + + // Compose an IBC transfer and send from rollapp -> dymension + transferAmount := math.NewInt(1_000_000) + + rollApp1Channel, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, rollApp1Channel, 1) + + channDymRollApp1 := rollApp1Channel[0].Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + dymChannel, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 2, len(dymChannel)) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: dymChannel[0].ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + transferData := ibc.WalletData{ + Address: rollapp1UserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Stop replayer right before sending IBC Transfer + err = r1.StopRelayer(ctx, eRep) + require.NoError(t, err) + + _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the hub because transfer amount was deducted from wallet balance + + // Get the IBC denom for urax on rollapp + dymTokenDenom := transfertypes.GetPrefixedDenom(rollApp1Channel[0].PortID, rollApp1Channel[0].ChannelID, dymension.Config().Denom) + dymIBCDenom := transfertypes.ParseDenomTrace(dymTokenDenom).IBCDenom() + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + // Assert balance was updated on the hub because transfer amount was deducted from wallet balance + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + // Assert funds are waiting + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymIBCDenom, math.NewInt(0)) + + // Packet commitments exist + res, err := dymension.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.NoError(t, err) + require.Equal(t, len(res.Commitments) > 0, true, "no packet commitments exist") + + // Restart Relayer + r1.UpdateClients(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 600) + require.NoError(t, err) + require.True(t, isFinalized) + + t.Log("rollapp1UserAddr:", rollapp1UserAddr) + t.Log("dymIBCDenom:", dymIBCDenom) + // Assert balance was updated on rollapp + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymIBCDenom, transferData.Amount) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // No packet commitments should exist on rollapp anymore + res, err = rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.Equal(t, len(res.Commitments) == 0, true, "packet commitments still exist") + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} \ No newline at end of file From 4cdfa794fd68bf4bab2331a9f5fec79adf079b4b Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Thu, 2 May 2024 13:52:19 +0700 Subject: [PATCH 23/61] [pfm] `e2e for rollapp1 to rollapp2 with register erc20` (#124) Co-authored-by: Trinity Co-authored-by: ducnt131 <62016666+anhductn2001@users.noreply.github.com> --- .github/workflows/e2e-test-workflow-call.yml | 1 + .github/workflows/e2e_test.yml | 1 + Makefile | 9 +- tests/ibc_pfm_with_grace_period_test.go | 354 ++++++++++++++++++- tests_spec/pfm.md | 4 +- 5 files changed, 362 insertions(+), 7 deletions(-) diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 442a20cb..9dcf87fc 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -35,6 +35,7 @@ jobs: - "e2e-test-eibc-timeout-evm" - "e2e-test-transfer-multi-hop-evm" - "e2e-test-pfm-with-grace-period-evm" + - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20" - "e2e-test-pfm-gaia-to-rollapp-evm" - "e2e-test-batch-finalization-evm" - "e2e-test-disconnection-evm" diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 19d9901c..2ab5833c 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -37,6 +37,7 @@ jobs: - "e2e-test-eibc-timeout-evm" - "e2e-test-transfer-multi-hop-evm" - "e2e-test-pfm-with-grace-period-evm" + - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20" - "e2e-test-pfm-gaia-to-rollapp-evm" - "e2e-test-batch-finalization-evm" - "e2e-test-disconnection-evm" diff --git a/Makefile b/Makefile index af6c9fc1..a9c65e6d 100644 --- a/Makefile +++ b/Makefile @@ -89,8 +89,11 @@ e2e-test-transfer-multi-hop-wasm: clean-e2e e2e-test-pfm-with-grace-period-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCPFMWithGracePeriod_Wasm . - -e2e-test-batch-finalization-wasm: clean-e2e + +e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestIBCPFM_RollApp1ToRollApp2WithErc20 . + +e2e-test-batch-finalization-wasm: cd tests && go test -timeout=25m -race -v -run TestBatchFinalization_Wasm . e2e-test-disconnection-wasm: clean-e2e @@ -134,6 +137,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-eibc-timeout-evm \ e2e-test-transfer-multi-hop-evm \ e2e-test-pfm-with-grace-period-evm \ + e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20 \ e2e-test-pfm-gaia-to-rollapp-evm \ e2e-test-batch-finalization-evm \ e2e-test-disconnection-evm \ @@ -170,6 +174,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-eibc-timeout-evm \ e2e-test-transfer-multi-hop-evm \ e2e-test-pfm-with-grace-period-evm \ + e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20 \ e2e-test-pfm-gaia-to-rollapp-evm \ e2e-test-batch-finalization-evm \ e2e-test-disconnection-evm \ diff --git a/tests/ibc_pfm_with_grace_period_test.go b/tests/ibc_pfm_with_grace_period_test.go index 939dae37..a0a8429b 100644 --- a/tests/ibc_pfm_with_grace_period_test.go +++ b/tests/ibc_pfm_with_grace_period_test.go @@ -8,10 +8,8 @@ import ( "time" "cosmossdk.io/math" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" - "github.com/stretchr/testify/require" - "go.uber.org/zap/zaptest" - test "github.com/decentrio/rollup-e2e-testing" "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" @@ -20,6 +18,8 @@ import ( "github.com/decentrio/rollup-e2e-testing/relayer" "github.com/decentrio/rollup-e2e-testing/testreporter" "github.com/decentrio/rollup-e2e-testing/testutil" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" ) func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { @@ -621,3 +621,351 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { require.True(t, gaiaBalance.Equal(transferAmount)) }) } + +// PFM with grace period rollApp1 to rollApp2 with Erc20 registed on rollApp2 +func TestIBCPFM_RollApp1ToRollApp2WithErc20(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_1234-1", "0adym", "3s") + configFileOverrides2 := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_12345-1", "0adym", "3s") + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + modifyRollappGeneisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.erc20.params.enable_erc20", + Value: true, + }, + ) + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(modifyRollappGeneisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + channsDym, err := r1.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym, 2) + + rollapp1Chan, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, rollapp1Chan, 1) + + dymRollApp1Chan := rollapp1Chan[0].Counterparty + require.NotEmpty(t, dymRollApp1Chan.ChannelID) + + rollapp1DymChan := rollapp1Chan[0] + require.NotEmpty(t, rollapp1DymChan.ChannelID) + + rollapp2Chan, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, rollapp2Chan, 1) + + dymRollApp2Chan := rollapp2Chan[0].Counterparty + require.NotEmpty(t, dymRollApp2Chan.ChannelID) + + rollapp2DymChan := rollapp2Chan[0] + require.NotEmpty(t, rollapp2DymChan.ChannelID) + + // Start the relayer and set the cleanup function. + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer2: %s", err) + } + }, + ) + + walletAmount := math.NewInt(1_000_000_000_000) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, rollapp2) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollapp1User, rollapp2User := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollapp1UserAddr := rollapp1User.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, rollapp2.Config().Denom, walletAmount) + + rollapp1Param := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: dymRollApp1Chan.ChannelID, + userKey: dymensionUser.KeyName(), + } + + rollapp2Param := rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: dymRollApp2Chan.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp1Param, rollapp2Param) + + t.Run("multihop rollapp1->dym->rollapp2, funds received on rollapp2 after grace period", func(t *testing.T) { + firstHopDenom := transfertypes.GetPrefixedDenom(dymRollApp1Chan.PortID, dymRollApp1Chan.ChannelID, rollapp1.Config().Denom) + secondHopDenom := transfertypes.GetPrefixedDenom(rollapp2DymChan.PortID, rollapp2DymChan.ChannelID, firstHopDenom) + + firstHopDenomTrace := transfertypes.ParseDenomTrace(firstHopDenom) + secondHopDenomTrace := transfertypes.ParseDenomTrace(secondHopDenom) + + firstHopIBCDenom := firstHopDenomTrace.IBCDenom() + secondHopIBCDenom := secondHopDenomTrace.IBCDenom() + + // register ibc denom (secondHopIBCDenom) on rollapp2 + metadata := banktypes.Metadata{ + Description: "IBC token from Dymension", + DenomUnits: []*banktypes.DenomUnit{ + { + Denom: secondHopIBCDenom, + Exponent: 0, + Aliases: []string{"urax"}, + }, + { + Denom: "urax", + Exponent: 6, + }, + }, + // Setting base as IBC hash denom since bank keepers's SetDenomMetadata uses + // Base as key path and the IBC hash is what gives this token uniqueness + // on the executing chain + Base: secondHopIBCDenom, + Display: "urax", + Name: "urax", + Symbol: "urax", + } + + data := map[string][]banktypes.Metadata{ + "metadata": {metadata}, + } + + contentFile, err := json.Marshal(data) + require.NoError(t, err) + rollapp2.GetNode().WriteFile(ctx, contentFile, "./ibcmetadata.json") + deposit := "500000000000" + rollapp1.Config().Denom + rollapp2.GetNode().HostName() + _, err = rollapp2.GetNode().RegisterIBCTokenDenomProposal(ctx, rollapp2User.KeyName(), deposit, rollapp2.GetNode().HomeDir()+"/ibcmetadata.json") + require.NoError(t, err) + + err = rollapp2.VoteOnProposalAllValidators(ctx, "1", cosmos.ProposalVoteYes) + require.NoError(t, err, "failed to submit votes") + + height, err := rollapp2.Height(ctx) + require.NoError(t, err, "error fetching height") + _, err = cosmos.PollForProposalStatus(ctx, rollapp2.CosmosChain, height, height+30, "1", cosmos.ProposalStatusPassed) + require.NoError(t, err, "proposal status did not change to passed") + + zeroBal := math.ZeroInt() + transferAmount := math.NewInt(100_000) + + // Send packet from rollapp1 -> dym -> rollapp2 + transfer := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + firstHopMetadata := &PacketMetadata{ + Forward: &ForwardMetadata{ + Receiver: rollapp2UserAddr, + Channel: dymRollApp2Chan.ChannelID, + Port: dymRollApp2Chan.PortID, + Timeout: 5 * time.Minute, + }, + } + + memo, err := json.Marshal(firstHopMetadata) + require.NoError(t, err) + + transferTx, err := rollapp1.SendIBCTransfer(ctx, rollapp2DymChan.ChannelID, rollapp1User.KeyName(), transfer, ibc.TransferOptions{Memo: string(memo)}) + require.NoError(t, err) + err = transferTx.Validate() + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 20, rollapp1) + require.NoError(t, err) + + rollAppBalance, err := rollapp1.GetBalance(ctx, rollapp1UserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + + dymBalance, err := dymension.GetBalance(ctx, dymensionUserAddr, firstHopIBCDenom) + require.NoError(t, err) + + erc20MAcc, err := rollapp2.Validators[0].QueryModuleAccount(ctx, "erc20") + require.NoError(t, err) + erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address + rollapp2Erc20MaccBalance, err := rollapp2.GetBalance(ctx, erc20MAccAddr, secondHopIBCDenom) + require.NoError(t, err) + + // Make sure that the transfer is not successful yet due to the grace period + require.True(t, rollAppBalance.Equal(walletAmount.Sub(transferAmount))) + require.True(t, dymBalance.Equal(zeroBal)) + require.True(t, rollapp2Erc20MaccBalance.Equal(zeroBal)) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + err = testutil.WaitForBlocks(ctx, 20, dymension, rollapp2) + require.NoError(t, err) + + rollapp2Erc20MaccBalance, err = rollapp2.GetBalance(ctx, erc20MAccAddr, secondHopIBCDenom) + require.NoError(t, err) + require.True(t, rollapp2Erc20MaccBalance.Equal(transferAmount)) + }) + // Check the commitment was deleted + resp, err := rollapp2.GetNode().QueryPacketCommitments(ctx, "transfer", rollapp2DymChan.ChannelID) + require.NoError(t, err) + require.Equal(t, 0, len(resp.Commitments)) +} diff --git a/tests_spec/pfm.md b/tests_spec/pfm.md index 61bf0846..541219d2 100644 --- a/tests_spec/pfm.md +++ b/tests_spec/pfm.md @@ -5,6 +5,6 @@ | 1 | Rollapp to 3rd party chain | | |
  • Try to send RAX from rollapp to an external chain, eibc should be switched off
  • RAX should be available on a 3rd party chain after rollapp grace period is reached
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| Partly solved
(lack query `packet commitment` left on the rollapp) | [test_pfm_with_grace_period](../tests/ibc_pfm_with_grace_period_test.go) | | 2 | 3rd party chain to Rollapp | | |
  • transfer from 3rd party chain to rollapp
  • funds should be available on rollapp almost immediately
| 🛑
(missing) | TODO | | 3 | Rollapp to 3rd party chain with eIBC | | |
  • send PFM + eIBC memo should fail with ackError on hub
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TODO | -| 4 | Rollapp to Rollapp - ERC20 registered | erc20 registered on rollapp2 for rollapp 1 IBC | 🛑
(missing) |
  • send from rollapp 1 to rollapp 2 using PFM
  • rollapp token 1 should be available on the rollapp 2 after rollapp1 grace period is reached
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TODO | +| 4 | Rollapp to Rollapp - ERC20 registered | erc20 registered on rollapp2 for rollapp 1 IBC | ✅ |
  • send from rollapp 1 to rollapp 2 using PFM
  • rollapp token 1 should be available on the rollapp 2 after rollapp1 grace period is reached
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestIBCPFM_RollApp1ToRollApp2WithErc20](../tests/ibc_pfm_with_grace_period_test.go#L710)| | 5 | Rollapp to Rollapp - ERC20 not registered | erc20 NOT registered on rollapp2 for rollapp 1 IBC | 🛑
(missing) |
  • send from rollapp 1 to rollapp 2 using PFM should fail
  • rollapp token 1 should return to rollapp1 after (rollapp1 grace period + rollapp2 grace period) is reached.
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TODO | -| 6 | Rollapp to Rollapp + eIBC | | | send from rollapp 1 to rollapp 2 using PFM + eIBC should fail | 🛑
(missing) | TODO | \ No newline at end of file +| 6 | Rollapp to Rollapp + eIBC | | | send from rollapp 1 to rollapp 2 using PFM + eIBC should fail | 🛑
(missing) | TODO | From 9b8f72fdced29e89f495f88cf25a16f0e71aa569 Mon Sep 17 00:00:00 2001 From: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Date: Mon, 6 May 2024 16:36:54 +0700 Subject: [PATCH 24/61] Optimize time run (#141) Co-authored-by: lacsomot --- tests/eibc_corrupted_memo_test.go | 14 +- tests/eibc_fee_test.go | 15 +- tests/eibc_fulfillment_test.go | 124 ++++++--------- tests/eibc_nobalance_test.go | 16 +- tests/eibc_pfm_test.go | 88 ++--------- tests/eibc_timeout_test.go | 21 ++- tests/frozen_test.go | 200 ++++++++---------------- tests/ibc_grace_period_test.go | 194 ++++++++--------------- tests/ibc_pfm_test.go | 73 ++------- tests/ibc_pfm_with_grace_period_test.go | 59 ++----- tests/ibc_timeout_test.go | 58 +++---- tests/ibc_transfer_test.go | 94 ++--------- tests/rollapp_genesis_event_test.go | 7 - tests/setup.go | 21 ++- tests/tx_batch_finalization_test.go | 15 -- 15 files changed, 283 insertions(+), 716 deletions(-) diff --git a/tests/eibc_corrupted_memo_test.go b/tests/eibc_corrupted_memo_test.go index f68616ce..0d8373ec 100644 --- a/tests/eibc_corrupted_memo_test.go +++ b/tests/eibc_corrupted_memo_test.go @@ -38,7 +38,7 @@ func TestEIBCCorruptedMemoNegative(t *testing.T) { dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - const BLOCK_FINALITY_PERIOD = 50 + modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -138,15 +138,9 @@ func TestEIBCCorruptedMemoNegative(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, dymensionUser2, dymensionUser3, rollappUser := users[0], users[1], users[2], users[3] @@ -161,8 +155,6 @@ func TestEIBCCorruptedMemoNegative(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr3, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - transferAmount := math.NewInt(1_000_000) - channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) require.NoError(t, err) @@ -228,8 +220,8 @@ func TestEIBCCorruptedMemoNegative(t *testing.T) { require.True(t, isFinalized) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr2, rollappIBCDenom, math.NewInt(0)) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr3, rollappIBCDenom, math.NewInt(0)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr2, rollappIBCDenom, zeroBal) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr3, rollappIBCDenom, zeroBal) t.Cleanup( func() { diff --git a/tests/eibc_fee_test.go b/tests/eibc_fee_test.go index cd539008..1c610c0c 100644 --- a/tests/eibc_fee_test.go +++ b/tests/eibc_fee_test.go @@ -38,7 +38,7 @@ func TestEIBCFeeTooHigh(t *testing.T) { dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - const BLOCK_FINALITY_PERIOD = 50 + modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -138,15 +138,9 @@ func TestEIBCFeeTooHigh(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -157,7 +151,6 @@ func TestEIBCFeeTooHigh(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - transferAmount := math.NewInt(1_000_000) eibcFee := math.NewInt(2_000_000) // set fee to be more than a transfer amount channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) @@ -190,12 +183,12 @@ func TestEIBCFeeTooHigh(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) // balance right after sending IBC transfer - zeroBalance := math.NewInt(0) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBalance) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) // get eIbc event eibcEvents, _ := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) @@ -206,7 +199,7 @@ func TestEIBCFeeTooHigh(t *testing.T) { require.True(t, isFinalized) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBalance) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) t.Cleanup( func() { diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 707dea45..7cebe48a 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -46,7 +46,6 @@ func TestEIBCFulfillment_EVM(t *testing.T) { gas_price_rollapp2 := "0adym" configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) - const BLOCK_FINALITY_PERIOD = 50 modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -182,15 +181,9 @@ func TestEIBCFulfillment_EVM(t *testing.T) { CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, marketMaker, rollappUser := users[0], users[1], users[2] @@ -203,7 +196,6 @@ func TestEIBCFulfillment_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - transferAmount := math.NewInt(1_000_000) multiplier := math.NewInt(10) eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 @@ -223,10 +215,8 @@ func TestEIBCFulfillment_EVM(t *testing.T) { // Start relayer err = r1.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = r2.StartRelayer(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) require.NoError(t, err) transferData := ibc.WalletData{ @@ -243,6 +233,7 @@ func TestEIBCFulfillment_EVM(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -269,13 +260,15 @@ func TestEIBCFulfillment_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - zeroBalance := math.NewInt(0) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) - require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) // get eIbc event eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) @@ -292,7 +285,7 @@ func TestEIBCFulfillment_EVM(t *testing.T) { } // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address @@ -347,7 +340,6 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { gas_price_rollapp2 := "0adym" configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) - const BLOCK_FINALITY_PERIOD = 50 modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -483,15 +475,9 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, marketMaker, rollappUser := users[0], users[1], users[2] @@ -504,7 +490,6 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - transferAmount := math.NewInt(1_000_000) multiplier := math.NewInt(10) eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 @@ -530,9 +515,6 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { err = r2.StartRelayer(ctx, eRep, anotherIbcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 3, dymension) - require.NoError(t, err) - rollapp := rollappParam{ rollappID: rollapp1.Config().ChainID, channelID: channsRollApp1[0].Counterparty.ChannelID, @@ -554,6 +536,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -580,13 +563,15 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - zeroBalance := math.NewInt(0) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) - require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) // get eIbc event eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) @@ -603,7 +588,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { } // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address @@ -660,7 +645,6 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { gas_price_rollapp2 := "0adym" configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) - const BLOCK_FINALITY_PERIOD = 50 modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -774,11 +758,11 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) r3 := test.NewBuiltinRelayerFactory( @@ -830,15 +814,9 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, gaia) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, marketMaker, rollapp1User, gaiaUser := users[0], users[1], users[2], users[3] @@ -853,7 +831,6 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, gaia.Config().Denom, walletAmount) - transferAmount := math.NewInt(1_000_000) bigTransferAmount := math.NewInt(1_000_000_000) multiplier := math.NewInt(10) @@ -884,17 +861,17 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { channGaiaDym := gaiaChannels[0] require.NotEmpty(t, channGaiaDym.ChannelID) - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp1.Config().ChainID, - channelID: channsRollApp1[0].Counterparty.ChannelID, - userKey: dymensionUser.KeyName(), - }) - - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp2.Config().ChainID, - channelID: channsRollApp2[0].Counterparty.ChannelID, - userKey: dymensionUser.KeyName(), - }) + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channsRollApp1[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }, + rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channsRollApp2[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }) // Start relayer err = r1.StartRelayer(ctx, eRep, ibcPath) @@ -904,9 +881,6 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { err = r3.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension) - require.NoError(t, err) - transferData := ibc.WalletData{ Address: dymensionUserAddr, Denom: gaia.Config().Denom, @@ -926,8 +900,9 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { require.NoError(t, err) t.Log("gaiaIBCDenom:", gaiaIBCDenom) + // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) balance, err := dymension.GetBalance(ctx, dymensionUserAddr, gaiaIBCDenom) @@ -1000,7 +975,7 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { } // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address @@ -1069,7 +1044,6 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { gas_price_rollapp2 := "0adym" configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) - const BLOCK_FINALITY_PERIOD = 50 modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -1174,11 +1148,11 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) // Relayer for gaia r3 := test.NewBuiltinRelayerFactory( @@ -1230,15 +1204,9 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, gaia) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, marketMaker, rollapp1User, gaiaUser := users[0], users[1], users[2], users[3] @@ -1253,7 +1221,6 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, gaia.Config().Denom, walletAmount) - transferAmount := math.NewInt(1_000_000) bigTransferAmount := math.NewInt(1_000_000_000) multiplier := math.NewInt(10) @@ -1284,17 +1251,16 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { channGaiaDym := gaiaChannels[0] require.NotEmpty(t, channGaiaDym.ChannelID) - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp1.Config().ChainID, - channelID: channsRollApp1[0].Counterparty.ChannelID, - userKey: dymensionUser.KeyName(), - }) - - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp2.Config().ChainID, - channelID: channsRollApp2[0].Counterparty.ChannelID, - userKey: dymensionUser.KeyName(), - }) + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channsRollApp1[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channsRollApp2[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }) // Start relayer err = r1.StartRelayer(ctx, eRep, ibcPath) @@ -1304,9 +1270,6 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { err = r3.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension) - require.NoError(t, err) - transferData := ibc.WalletData{ Address: dymensionUserAddr, Denom: gaia.Config().Denom, @@ -1326,8 +1289,9 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { require.NoError(t, err) t.Log("gaiaIBCDenom:", gaiaIBCDenom) + // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) balance, err := dymension.GetBalance(ctx, dymensionUserAddr, gaiaIBCDenom) @@ -1400,7 +1364,7 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { } // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address diff --git a/tests/eibc_nobalance_test.go b/tests/eibc_nobalance_test.go index 516790d4..c15d78ea 100644 --- a/tests/eibc_nobalance_test.go +++ b/tests/eibc_nobalance_test.go @@ -39,7 +39,7 @@ func TestEIBCNoBalanceToFulfillOrder(t *testing.T) { dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - const BLOCK_FINALITY_PERIOD = 50 + modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -139,15 +139,9 @@ func TestEIBCNoBalanceToFulfillOrder(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, marketMaker, rollappUser := users[0], users[1], users[2] @@ -160,7 +154,6 @@ func TestEIBCNoBalanceToFulfillOrder(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - transferAmount := math.NewInt(1_000_000) multiplier := math.NewInt(10) eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 @@ -194,11 +187,12 @@ func TestEIBCNoBalanceToFulfillOrder(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) + // verify funds balance right after sending the IBC transfer - zeroBalance := math.NewInt(0) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBalance) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) // get eIbc event @@ -220,7 +214,7 @@ func TestEIBCNoBalanceToFulfillOrder(t *testing.T) { require.True(t, isFinalized) // verify funds were transferred to dymensionUserAddr - testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, rollappIBCDenom, zeroBalance) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, rollappIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount) t.Cleanup( diff --git a/tests/eibc_pfm_test.go b/tests/eibc_pfm_test.go index e56df9b9..212a28fd 100644 --- a/tests/eibc_pfm_test.go +++ b/tests/eibc_pfm_test.go @@ -49,7 +49,6 @@ func TestEIBCPFM_EVM(t *testing.T) { numRollAppFn := 0 numRollAppVals := 1 - const BLOCK_FINALITY_PERIOD = 80 modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -200,15 +199,9 @@ func TestEIBCPFM_EVM(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollapp1User, rollapp2User := users[0], users[1], users[2] @@ -248,25 +241,13 @@ func TestEIBCPFM_EVM(t *testing.T) { userKey: dymensionUser.KeyName(), } - triggerHubGenesisEvent(t, dymension, rollapp1Param) - - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - - // wait until the rollapp1 is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - rollapp2Param := rollappParam{ rollappID: rollapp2.Config().ChainID, channelID: channDymRollApp2.ChannelID, userKey: dymensionUser.KeyName(), } - triggerHubGenesisEvent(t, dymension, rollapp2Param) + triggerHubGenesisEvent(t, dymension, rollapp1Param, rollapp2Param) - zeroBal := math.ZeroInt() - transferAmount := math.NewInt(1_000_000) multiplier := math.NewInt(10) eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 @@ -292,14 +273,15 @@ func TestEIBCPFM_EVM(t *testing.T) { tx, err := rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollapp1User.KeyName(), transfer, ibc.TransferOptions{Memo: string(memo)}) require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 110, rollapp1, dymension) - // require.NoError(t, err) - rollapp1Height, err := rollapp1.Height(ctx) require.NoError(t, err) ack, err := testutil.PollForAck(ctx, rollapp1, rollapp1Height, rollapp1Height+30, tx.Packet) require.NoError(t, err) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 300) + require.NoError(t, err) + require.True(t, isFinalized) + // Make sure the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) @@ -344,7 +326,6 @@ func TestEIBCPFM_Wasm(t *testing.T) { numRollAppFn := 0 numRollAppVals := 1 - const BLOCK_FINALITY_PERIOD = 80 modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -472,36 +453,8 @@ func TestEIBCPFM_Wasm(t *testing.T) { }) require.NoError(t, err) - err = r1.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - err = r2.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp2.Config().ChainID, anotherIbcPath) - require.NoError(t, err) - - err = r1.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - err = r2.CreateClients(ctx, eRep, anotherIbcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r1.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - r2.UpdateClients(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = r1.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - err = r2.CreateConnections(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r1.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - err = r2.CreateChannel(ctx, eRep, anotherIbcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) // Start both relayers err = r1.StartRelayer(ctx, eRep, ibcPath) @@ -523,15 +476,9 @@ func TestEIBCPFM_Wasm(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollapp1User, rollapp2User := users[0], users[1], users[2] @@ -571,25 +518,13 @@ func TestEIBCPFM_Wasm(t *testing.T) { userKey: dymensionUser.KeyName(), } - triggerHubGenesisEvent(t, dymension, rollapp1Param) - - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - - // wait until the rollapp1 is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - rollapp2Param := rollappParam{ rollappID: rollapp2.Config().ChainID, channelID: channDymRollApp2.ChannelID, userKey: dymensionUser.KeyName(), } - triggerHubGenesisEvent(t, dymension, rollapp2Param) + triggerHubGenesisEvent(t, dymension, rollapp1Param, rollapp2Param) - zeroBal := math.ZeroInt() - transferAmount := math.NewInt(1_000_000) multiplier := math.NewInt(10) eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 @@ -615,14 +550,15 @@ func TestEIBCPFM_Wasm(t *testing.T) { tx, err := rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollapp1User.KeyName(), transfer, ibc.TransferOptions{Memo: string(memo)}) require.NoError(t, err) - // err = testutil.WaitForBlocks(ctx, 110, rollapp1, dymension) - // require.NoError(t, err) - rollapp1Height, err := rollapp1.Height(ctx) require.NoError(t, err) ack, err := testutil.PollForAck(ctx, rollapp1, rollapp1Height, rollapp1Height+30, tx.Packet) require.NoError(t, err) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 300) + require.NoError(t, err) + require.True(t, isFinalized) + // Make sure the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) diff --git a/tests/eibc_timeout_test.go b/tests/eibc_timeout_test.go index 38db4125..5f77cb98 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -37,7 +37,7 @@ func TestEIBCTimeoutHubToRollapp(t *testing.T) { dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - const BLOCK_FINALITY_PERIOD = 50 + modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -135,15 +135,9 @@ func TestEIBCTimeoutHubToRollapp(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, marketMakerUser, rollappUser := users[0], users[1], users[2] @@ -191,18 +185,21 @@ func TestEIBCTimeoutHubToRollapp(t *testing.T) { // Compose an IBC transfer and send from Hub -> rollapp _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, options) require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) - // Assert balance was updated on the hub - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0)) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) // According to delayedack module, we need the rollapp to have finalizedHeight > ibcClientLatestHeight // in order to trigger ibc timeout or else it will trigger callback - err = testutil.WaitForBlocks(ctx, 1, rollapp1) + err = testutil.WaitForBlocks(ctx, 1, dymension, rollapp1) require.NoError(t, err) err = r.StartRelayer(ctx, eRep, ibcPath) @@ -235,12 +232,14 @@ func TestEIBCTimeoutHubToRollapp(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) expBalance := walletAmount.Sub(transferData.Amount).Add(transferAmountWithoutFee) require.True(t, balance.Equal(expBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalance, balance)) + // verify funds were deducted from market maker's wallet address balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) expBalanceMarketMaker := walletAmount.Sub((transferAmountWithoutFee)) require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) + // wait until packet finalization and verify funds (incl. fee) were added to market maker's wallet address isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) diff --git a/tests/frozen_test.go b/tests/frozen_test.go index 1e59e42a..9695735d 100644 --- a/tests/frozen_test.go +++ b/tests/frozen_test.go @@ -7,7 +7,6 @@ import ( "strings" "testing" - "cosmossdk.io/math" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" @@ -193,25 +192,15 @@ func TestRollAppFreeze_EVM(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] dymensionUserAddr := dymensionUser.FormattedAddress() rollappUserAddr := rollappUser.FormattedAddress() - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) - require.NoError(t, err) - keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() sequencerAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", keyDir) require.NoError(t, err) @@ -245,17 +234,16 @@ func TestRollAppFreeze_EVM(t *testing.T) { channsRollApp2Dym := channsRollApp2[0] require.NotEmpty(t, channsRollApp2Dym.ChannelID) - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp1.Config().ChainID, - channelID: channDymRollApp1.ChannelID, - userKey: dymensionUser.KeyName(), - }) - - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp2.Config().ChainID, - channelID: channDymRollApp2.ChannelID, - userKey: dymensionUser.KeyName(), - }) + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }) oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -309,10 +297,6 @@ func TestRollAppFreeze_EVM(t *testing.T) { _, err = cosmos.PollForProposalStatus(ctx, dymension.CosmosChain, height, height+20, propTx.ProposalID, cosmos.ProposalStatusPassed) require.NoError(t, err, "proposal status did not change to passed") - // Wait a few blocks for the gov to pass and to verify if the state index increment - err = testutil.WaitForBlocks(ctx, 20, dymension, rollapp1) - require.NoError(t, err) - // Check if rollapp has frozen or not rollappParams, err := dymension.QueryRollappParams(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -325,8 +309,6 @@ func TestRollAppFreeze_EVM(t *testing.T) { // IBC Transfer not working // Compose an IBC transfer and send from dymension -> rollapp - transferAmount := math.NewInt(1_000_000) - transferData := ibc.WalletData{ Address: rollappUserAddr, Denom: dymension.Config().Denom, @@ -356,8 +338,7 @@ func TestRollAppFreeze_EVM(t *testing.T) { require.NoError(t, err) // Wait a few blocks - err = testutil.WaitForBlocks(ctx, 40, dymension) - require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 20, dymension) // Get updated dym hub ibc denom balance dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, rollapp1IbcDenom) @@ -527,15 +508,9 @@ func TestRollAppFreeze_Wasm(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -551,10 +526,6 @@ func TestRollAppFreeze_Wasm(t *testing.T) { require.NoError(t, err) require.Equal(t, walletAmount, rollappOrigBal) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) - require.NoError(t, err) - // IBC channel for rollapps channsDym1, err := r1.GetChannels(ctx, eRep, dymension.GetChainID()) require.NoError(t, err) @@ -584,15 +555,16 @@ func TestRollAppFreeze_Wasm(t *testing.T) { channsRollApp2Dym := channsRollApp2[0] require.NotEmpty(t, channsRollApp2Dym.ChannelID) - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp1.Config().ChainID, - channelID: channDymRollApp1.ChannelID, - userKey: dymensionUser.KeyName(), - }, rollappParam{ - rollappID: rollapp2.Config().ChainID, - channelID: channDymRollApp2.ChannelID, - userKey: dymensionUser.KeyName(), - }) + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }) oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -668,10 +640,6 @@ func TestRollAppFreeze_Wasm(t *testing.T) { _, err = cosmos.PollForProposalStatus(ctx, dymension.CosmosChain, height, height+20, propTx.ProposalID, cosmos.ProposalStatusPassed) require.NoError(t, err, "proposal status did not change to passed") - // Wait a few blocks for the gov to pass and to verify if the state index increment - err = testutil.WaitForBlocks(ctx, 20, dymension, rollapp1) - require.NoError(t, err) - // Check if rollapp has frozen or not rollappParams, err := dymension.QueryRollappParams(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -684,8 +652,6 @@ func TestRollAppFreeze_Wasm(t *testing.T) { // IBC Transfer not working // Compose an IBC transfer and send from dymension -> rollapp - transferAmount := math.NewInt(1_000_000) - transferData := ibc.WalletData{ Address: rollappUserAddr, Denom: dymension.Config().Denom, @@ -715,8 +681,7 @@ func TestRollAppFreeze_Wasm(t *testing.T) { require.NoError(t, err) // Wait a few blocks - err = testutil.WaitForBlocks(ctx, 40, dymension) - require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 20, dymension) // Get updated dym hub ibc denom balance dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, rollapp1IbcDenom) @@ -881,9 +846,6 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1, rollapp2) - require.NoError(t, err) - // Start both relayers err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) @@ -905,15 +867,9 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollapp1User, rollapp2User := users[0], users[1], users[2] @@ -934,10 +890,6 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { require.NoError(t, err) require.Equal(t, walletAmount, rollapp2OrigBal) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) - require.NoError(t, err) - keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() sequencerAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", keyDir) require.NoError(t, err) @@ -971,17 +923,16 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { channsRollApp2Dym := channsRollApp2[0] require.NotEmpty(t, channsRollApp2Dym.ChannelID) - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp1.Config().ChainID, - channelID: channDymRollApp1.ChannelID, - userKey: dymensionUser.KeyName(), - }) - - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp2.Config().ChainID, - channelID: channDymRollApp2.ChannelID, - userKey: dymensionUser.KeyName(), - }) + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }) oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -1036,9 +987,11 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { err = dymension.VoteOnProposalAllValidators(ctx, propTx.ProposalID, cosmos.ProposalVoteYes) require.NoError(t, err, "failed to submit votes") - // Wait a few blocks for the gov to pass and to verify if the state index increment - err = testutil.WaitForBlocks(ctx, 20, dymension, rollapp1) - require.NoError(t, err) + height, err := dymension.Height(ctx) + require.NoError(t, err, "error fetching height") + + _, err = cosmos.PollForProposalStatus(ctx, dymension.CosmosChain, height, height+20, propTx.ProposalID, cosmos.ProposalStatusPassed) + require.NoError(t, err, "proposal status did not change to passed") // Check if rollapp1 has frozen or not rollappParams, err := dymension.QueryRollappParams(ctx, rollapp1.Config().ChainID) @@ -1051,8 +1004,6 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { require.Equal(t, fmt.Sprint(targetIndex), latestIndex.StateIndex.Index, "rollapp state index still increment") // Compose an IBC transfer and send from dymension -> rollapp - transferAmount := math.NewInt(1_000_000) - transferData := ibc.WalletData{ Address: rollapp1UserAddr, Denom: dymension.Config().Denom, @@ -1062,6 +1013,7 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { // Confirm IBC Transfer not working between Dymension <-> rollapp1 _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) require.Error(t, err) + require.Equal(t, true, strings.Contains(err.Error(), "status Frozen")) transferData = ibc.WalletData{ Address: dymensionUserAddr, @@ -1081,8 +1033,7 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { require.NoError(t, err) // Wait a few blocks - err = testutil.WaitForBlocks(ctx, 40, dymension) - require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 20, dymension) // Get updated dym hub ibc denom balance dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, rollapp1IbcDenom) @@ -1096,9 +1047,6 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { require.NoError(t, err) require.True(t, rollapp2IndexLater.StateIndex.Index > rollapp2Index.StateIndex.Index, "Another rollapp got freeze") - err = testutil.WaitForBlocks(ctx, 20, dymension) - require.NoError(t, err) - // Get the IBC denom rollapp2IbcDenom := GetIBCDenom(channsRollApp2Dym.Counterparty.PortID, channsRollApp2Dym.Counterparty.ChannelID, rollapp2.Config().Denom) dymToRollapp2IbcDenom := GetIBCDenom(channsRollApp2Dym.PortID, channsRollApp2Dym.ChannelID, dymension.Config().Denom) @@ -1120,13 +1068,7 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channDymRollApp2.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - rollappHeight, err = rollapp2.GetNode().Height(ctx) - require.NoError(t, err) - - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) + testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) rollapp2UserUpdateBal, err := rollapp2.GetBalance(ctx, rollapp2UserAddr, dymToRollapp2IbcDenom) require.NoError(t, err) @@ -1147,7 +1089,7 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { require.NoError(t, err) // wait until the packet is finalized - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) @@ -1334,15 +1276,9 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollapp1User, rollapp2User := users[0], users[1], users[2] @@ -1363,10 +1299,6 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { require.NoError(t, err) require.Equal(t, walletAmount, rollapp2OrigBal) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) - require.NoError(t, err) - keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() sequencerAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", keyDir) require.NoError(t, err) @@ -1400,17 +1332,16 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { channsRollApp2Dym := channsRollApp2[0] require.NotEmpty(t, channsRollApp2Dym.ChannelID) - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp1.Config().ChainID, - channelID: channDymRollApp1.ChannelID, - userKey: dymensionUser.KeyName(), - }) - - triggerHubGenesisEvent(t, dymension, rollappParam{ - rollappID: rollapp2.Config().ChainID, - channelID: channDymRollApp2.ChannelID, - userKey: dymensionUser.KeyName(), - }) + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }) oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -1465,9 +1396,11 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { err = dymension.VoteOnProposalAllValidators(ctx, propTx.ProposalID, cosmos.ProposalVoteYes) require.NoError(t, err, "failed to submit votes") - // Wait a few blocks for the gov to pass and to verify if the state index increment - err = testutil.WaitForBlocks(ctx, 20, dymension, rollapp1) - require.NoError(t, err) + height, err := dymension.Height(ctx) + require.NoError(t, err, "error fetching height") + + _, err = cosmos.PollForProposalStatus(ctx, dymension.CosmosChain, height, height+20, propTx.ProposalID, cosmos.ProposalStatusPassed) + require.NoError(t, err, "proposal status did not change to passed") // Check if rollapp1 has frozen or not rollappParams, err := dymension.QueryRollappParams(ctx, rollapp1.Config().ChainID) @@ -1480,8 +1413,6 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { require.Equal(t, fmt.Sprint(targetIndex), latestIndex.StateIndex.Index, "rollapp state index still increment") // Compose an IBC transfer and send from dymension -> rollapp - transferAmount := math.NewInt(1_000_000) - transferData := ibc.WalletData{ Address: rollapp1UserAddr, Denom: dymension.Config().Denom, @@ -1491,6 +1422,7 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { // Confirm IBC Transfer not working between Dymension <-> rollapp1 _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) require.Error(t, err) + require.Equal(t, true, strings.Contains(err.Error(), "status Frozen")) transferData = ibc.WalletData{ Address: dymensionUserAddr, @@ -1510,8 +1442,7 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { require.NoError(t, err) // Wait a few blocks - err = testutil.WaitForBlocks(ctx, 40, dymension) - require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 20, dymension) // Get updated dym hub ibc denom balance dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, rollapp1IbcDenom) @@ -1525,9 +1456,6 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, rollapp2IndexLater.StateIndex.Index > rollapp2Index.StateIndex.Index, "Another rollapp got freeze") - err = testutil.WaitForBlocks(ctx, 20, dymension) - require.NoError(t, err) - // Get the IBC denom rollapp2IbcDenom := GetIBCDenom(channsRollApp2Dym.Counterparty.PortID, channsRollApp2Dym.Counterparty.ChannelID, rollapp2.Config().Denom) dymToRollapp2IbcDenom := GetIBCDenom(channsRollApp2Dym.PortID, channsRollApp2Dym.ChannelID, dymension.Config().Denom) @@ -1549,13 +1477,7 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channDymRollApp2.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - rollappHeight, err = rollapp2.GetNode().Height(ctx) - require.NoError(t, err) - - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) + testutil.WaitForBlocks(ctx, 10, dymension) rollapp2UserUpdateBal, err := rollapp2.GetBalance(ctx, rollapp2UserAddr, dymToRollapp2IbcDenom) require.NoError(t, err) @@ -1572,11 +1494,11 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { require.NoError(t, err) require.NotEmpty(t, tx.TxHash, "tx is nil") - rollappHeight, err = rollapp2.Height(ctx) + rollapp2Height, err := rollapp2.Height(ctx) require.NoError(t, err) // wait until the packet is finalized - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollapp2Height, 300) require.NoError(t, err) require.True(t, isFinalized) diff --git a/tests/ibc_grace_period_test.go b/tests/ibc_grace_period_test.go index f011fbc6..6d63599f 100644 --- a/tests/ibc_grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -6,7 +6,6 @@ import ( "strings" "testing" - "cosmossdk.io/math" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" @@ -47,7 +46,7 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { dymensionGenesisKV, cosmos.GenesisKV{ Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: "20", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), }, ) @@ -178,15 +177,9 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -198,8 +191,6 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) // Compose an IBC transfer and send from rollapp -> dymension - transferAmount := math.NewInt(1_000_000) - rollApp1Channel, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) require.NoError(t, err) require.Len(t, rollApp1Channel, 1) @@ -228,27 +219,18 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferDataDymToRollApp, ibc.TransferOptions{}) require.NoError(t, err) - // Assert balance was updated on the hub - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferDataDymToRollApp.Amount)) - // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymensionIBCDenom, math.NewInt(0)) - err = r1.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferDataDymToRollApp.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymensionIBCDenom, zeroBal) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + err = r1.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) + testutil.WaitForBlocks(ctx, 10, dymension) // Assert balance was updated on the Rollapp testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferDataDymToRollApp.Amount)) @@ -263,6 +245,9 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // Assert balance was updated on the rollapp because transfer amount was deducted from wallet balance testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) @@ -275,9 +260,9 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { // Assert funds are waiting testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, math.NewInt(0)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) - rollappHeight, err = rollapp1.GetNode().Height(ctx) + err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) // Packet commitments exist @@ -286,7 +271,7 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { require.Equal(t, len(res.Commitments) > 0, true, "no packet commitments exist") // wait until the packet is finalized - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) @@ -299,6 +284,7 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { // No packet commitments should exist on rollapp anymore res, err = rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.NoError(t, err) require.Equal(t, len(res.Commitments) == 0, true, "packet commitments still exist") t.Cleanup( @@ -337,7 +323,7 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { dymensionGenesisKV, cosmos.GenesisKV{ Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: "20", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), }, ) @@ -468,15 +454,9 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -488,8 +468,6 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) // Compose an IBC transfer and send from rollapp -> dymension - transferAmount := math.NewInt(1_000_000) - rollApp1Channel, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) require.NoError(t, err) require.Len(t, rollApp1Channel, 1) @@ -518,27 +496,18 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferDataDymToRollApp, ibc.TransferOptions{}) require.NoError(t, err) - // Assert balance was updated on the hub - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferDataDymToRollApp.Amount)) - // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymensionIBCDenom, math.NewInt(0)) - - err = r1.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferDataDymToRollApp.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymensionIBCDenom, zeroBal) - rollappHeight, err := rollapp1.GetNode().Height(ctx) + err = r1.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) + testutil.WaitForBlocks(ctx, 10, dymension) // Assert balance was updated on the Rollapp testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferDataDymToRollApp.Amount)) @@ -553,6 +522,9 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // Assert balance was updated on the rollapp because transfer amount was deducted from wallet balance testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) @@ -565,18 +537,18 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { // Assert funds are waiting testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, math.NewInt(0)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) // Packet commitments exist res, err := rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) require.NoError(t, err) require.Equal(t, len(res.Commitments) > 0, true, "no packet commitments exist") - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - // wait until the packet is finalized - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) @@ -589,6 +561,7 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { // No packet commitments should exist on rollapp anymore res, err = rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.NoError(t, err) require.Equal(t, len(res.Commitments) == 0, true, "packet commitments still exist") t.Cleanup( @@ -627,7 +600,7 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { dymensionGenesisKV, cosmos.GenesisKV{ Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: "200", + Value: fmt.Sprint(200), }, ) @@ -717,11 +690,11 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -758,15 +731,9 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -778,8 +745,6 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) // Compose an IBC transfer and send from rollapp -> dymension - transferAmount := math.NewInt(1_000_000) - rollApp1Channel, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) require.NoError(t, err) require.Len(t, rollApp1Channel, 1) @@ -801,9 +766,6 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { err = r1.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - transferData := ibc.WalletData{ Address: dymensionUserAddr, Denom: rollapp1.Config().Denom, @@ -825,12 +787,12 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - // Assert funds are waiting testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, math.NewInt(0)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) // Packet commitments exist res, err := rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) @@ -854,6 +816,7 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { // No packet commitments should exist on rollapp anymore res, err = rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.NoError(t, err) require.Equal(t, len(res.Commitments) == 0, true, "packet commitments still exist") t.Cleanup( @@ -892,7 +855,7 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { dymensionGenesisKV, cosmos.GenesisKV{ Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: "200", + Value: fmt.Sprint(200), }, ) @@ -982,11 +945,11 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -1023,15 +986,9 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -1043,8 +1000,6 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) // Compose an IBC transfer and send from rollapp -> dymension - transferAmount := math.NewInt(1_000_000) - rollApp1Channel, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) require.NoError(t, err) require.Len(t, rollApp1Channel, 1) @@ -1066,9 +1021,6 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { err = r1.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - transferData := ibc.WalletData{ Address: dymensionUserAddr, Denom: rollapp1.Config().Denom, @@ -1078,6 +1030,9 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // Assert balance was updated on the rollapp because transfer amount was deducted from wallet balance testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) @@ -1090,21 +1045,18 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - // Assert funds are waiting testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, math.NewInt(0)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) // Packet commitments exist res, err := rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) require.NoError(t, err) require.Equal(t, len(res.Commitments) > 0, true, "no packet commitments exist") - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - // wait until the packet is finalized isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 600) require.NoError(t, err) @@ -1119,6 +1071,7 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { // No packet commitments should exist on rollapp anymore res, err = rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.NoError(t, err) require.Equal(t, len(res.Commitments) == 0, true, "packet commitments still exist") t.Cleanup( @@ -1157,7 +1110,7 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { dymensionGenesisKV, cosmos.GenesisKV{ Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: "20", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), }, ) @@ -1288,15 +1241,9 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -1308,8 +1255,6 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) // Compose an IBC transfer and send from rollapp -> dymension - transferAmount := math.NewInt(1_000_000) - rollApp1Channel, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) require.NoError(t, err) require.Len(t, rollApp1Channel, 1) @@ -1334,9 +1279,6 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { err = r2.StartRelayer(ctx, eRep, anotherIbcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - transferData := ibc.WalletData{ Address: rollapp1UserAddr, Denom: dymension.Config().Denom, @@ -1350,19 +1292,17 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - // Assert balance was updated on the hub because transfer amount was deducted from wallet balance - // Get the IBC denom for urax on rollapp dymTokenDenom := transfertypes.GetPrefixedDenom(rollApp1Channel[0].PortID, rollApp1Channel[0].ChannelID, dymension.Config().Denom) dymIBCDenom := transfertypes.ParseDenomTrace(dymTokenDenom).IBCDenom() - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - // Assert balance was updated on the hub because transfer amount was deducted from wallet balance testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) // Assert funds are waiting - testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymIBCDenom, math.NewInt(0)) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymIBCDenom, zeroBal) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) // Packet commitments exist res, err := dymension.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) @@ -1380,12 +1320,13 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { require.NoError(t, err) // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 600) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) t.Log("rollapp1UserAddr:", rollapp1UserAddr) t.Log("dymIBCDenom:", dymIBCDenom) + // Assert balance was updated on rollapp testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymIBCDenom, transferData.Amount) @@ -1395,6 +1336,7 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { // No packet commitments should exist on rollapp anymore res, err = rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.NoError(t, err) require.Equal(t, len(res.Commitments) == 0, true, "packet commitments still exist") t.Cleanup( @@ -1438,7 +1380,7 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { dymensionGenesisKV, cosmos.GenesisKV{ Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: "20", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), }, ) @@ -1569,15 +1511,9 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -1589,8 +1525,6 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) // Compose an IBC transfer and send from rollapp -> dymension - transferAmount := math.NewInt(1_000_000) - rollApp1Channel, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) require.NoError(t, err) require.Len(t, rollApp1Channel, 1) @@ -1615,9 +1549,6 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { err = r2.StartRelayer(ctx, eRep, anotherIbcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - transferData := ibc.WalletData{ Address: rollapp1UserAddr, Denom: dymension.Config().Denom, @@ -1631,19 +1562,17 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - // Assert balance was updated on the hub because transfer amount was deducted from wallet balance - // Get the IBC denom for urax on rollapp dymTokenDenom := transfertypes.GetPrefixedDenom(rollApp1Channel[0].PortID, rollApp1Channel[0].ChannelID, dymension.Config().Denom) dymIBCDenom := transfertypes.ParseDenomTrace(dymTokenDenom).IBCDenom() - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - // Assert balance was updated on the hub because transfer amount was deducted from wallet balance testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) // Assert funds are waiting - testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymIBCDenom, math.NewInt(0)) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, dymIBCDenom, zeroBal) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) // Packet commitments exist res, err := dymension.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) @@ -1676,6 +1605,7 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { // No packet commitments should exist on rollapp anymore res, err = rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", rollApp1Channel[0].ChannelID) + require.NoError(t, err) require.Equal(t, len(res.Commitments) == 0, true, "packet commitments still exist") t.Cleanup( @@ -1691,4 +1621,4 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { } }, ) -} \ No newline at end of file +} diff --git a/tests/ibc_pfm_test.go b/tests/ibc_pfm_test.go index 061f2395..3c2c545a 100644 --- a/tests/ibc_pfm_test.go +++ b/tests/ibc_pfm_test.go @@ -7,7 +7,6 @@ import ( "testing" "time" - "cosmossdk.io/math" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" @@ -139,9 +138,6 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, ibcPath) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) require.NoError(t, err) require.Len(t, channsDym, 2) @@ -191,15 +187,9 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, gaia) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser, gaiaUser := users[0], users[1], users[2] @@ -237,9 +227,6 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { firstHopIBCDenom := firstHopDenomTrace.IBCDenom() secondHopIBCDenom := secondHopDenomTrace.IBCDenom() - zeroBal := math.ZeroInt() - transferAmount := math.NewInt(100_000) - // Send packet from rollapp1 -> dym -> gaia transfer := ibc.WalletData{ Address: dymensionUserAddr, @@ -272,7 +259,8 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - err = testutil.WaitForBlocks(ctx, 20, dymension, gaia) + // wait until gaia receive transferAmount + err = testutil.WaitForBlocks(ctx, 10, dymension, gaia) require.NoError(t, err) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) @@ -398,9 +386,6 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, ibcPath) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) require.NoError(t, err) require.Len(t, channsDym, 2) @@ -450,15 +435,9 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, gaia) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser, gaiaUser := users[0], users[1], users[2] @@ -496,9 +475,6 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { firstHopIBCDenom := firstHopDenomTrace.IBCDenom() secondHopIBCDenom := secondHopDenomTrace.IBCDenom() - zeroBal := math.ZeroInt() - transferAmount := math.NewInt(100_000) - // Send packet from rollapp1 -> dym -> gaia transfer := ibc.WalletData{ Address: dymensionUserAddr, @@ -531,7 +507,8 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - err = testutil.WaitForBlocks(ctx, 20, dymension, gaia) + // wait until gaia receive transferAmount + err = testutil.WaitForBlocks(ctx, 10, dymension, gaia) require.NoError(t, err) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) @@ -602,7 +579,7 @@ func TestIBCTransferGaiaToRollApp_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) r2 := test.NewBuiltinRelayerFactory( @@ -649,9 +626,6 @@ func TestIBCTransferGaiaToRollApp_EVM(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) - require.NoError(t, err) - channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) require.NoError(t, err) require.Len(t, channsDym, 2) @@ -696,15 +670,9 @@ func TestIBCTransferGaiaToRollApp_EVM(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, gaia) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser, gaiaUser := users[0], users[1], users[2] @@ -743,9 +711,6 @@ func TestIBCTransferGaiaToRollApp_EVM(t *testing.T) { firstHopIBCDenom := firstHopDenomTrace.IBCDenom() secondHopIBCDenom := secondHopDenomTrace.IBCDenom() - zeroBal := math.ZeroInt() - transferAmount := math.NewInt(100_000) - // Send packet from gaia -> dym -> rollapp1 transfer := ibc.WalletData{ Address: dymensionUserAddr, @@ -770,6 +735,10 @@ func TestIBCTransferGaiaToRollApp_EVM(t *testing.T) { err = transferTx.Validate() require.NoError(t, err) + // wait until dymension receive transferAmount + err = testutil.WaitForBlocks(ctx, 10, dymension, gaia) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -778,9 +747,6 @@ func TestIBCTransferGaiaToRollApp_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - err = testutil.WaitForBlocks(ctx, 20, dymension, gaia) - require.NoError(t, err) - testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, gaia.Config().Denom, walletAmount.Sub(transferAmount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, secondHopIBCDenom, transferAmount) @@ -849,7 +815,7 @@ func TestIBCTransferGaiaToRollApp_Wasm(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "e2e-amd", "100:1000"), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), ).Build(t, client, "relayer", network) r2 := test.NewBuiltinRelayerFactory( @@ -896,9 +862,6 @@ func TestIBCTransferGaiaToRollApp_Wasm(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) - require.NoError(t, err) - channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) require.NoError(t, err) require.Len(t, channsDym, 2) @@ -943,15 +906,9 @@ func TestIBCTransferGaiaToRollApp_Wasm(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, gaia) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser, gaiaUser := users[0], users[1], users[2] @@ -990,9 +947,6 @@ func TestIBCTransferGaiaToRollApp_Wasm(t *testing.T) { firstHopIBCDenom := firstHopDenomTrace.IBCDenom() secondHopIBCDenom := secondHopDenomTrace.IBCDenom() - zeroBal := math.ZeroInt() - transferAmount := math.NewInt(100_000) - // Send packet from gaia -> dym -> rollapp1 transfer := ibc.WalletData{ Address: dymensionUserAddr, @@ -1017,6 +971,10 @@ func TestIBCTransferGaiaToRollApp_Wasm(t *testing.T) { err = transferTx.Validate() require.NoError(t, err) + // wait until dymension receive transferAmount + err = testutil.WaitForBlocks(ctx, 10, dymension, gaia) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1025,9 +983,6 @@ func TestIBCTransferGaiaToRollApp_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - err = testutil.WaitForBlocks(ctx, 20, dymension, gaia) - require.NoError(t, err) - testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, gaia.Config().Denom, walletAmount.Sub(transferAmount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, secondHopIBCDenom, transferAmount) diff --git a/tests/ibc_pfm_with_grace_period_test.go b/tests/ibc_pfm_with_grace_period_test.go index a0a8429b..d7faf319 100644 --- a/tests/ibc_pfm_with_grace_period_test.go +++ b/tests/ibc_pfm_with_grace_period_test.go @@ -7,7 +7,6 @@ import ( "testing" "time" - "cosmossdk.io/math" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" test "github.com/decentrio/rollup-e2e-testing" @@ -37,10 +36,13 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { dymintTomlOverrides["gas_prices"] = "0adym" dymintTomlOverrides["empty_blocks_max_time"] = "3s" - modifyGenesisKV := append(dymensionGenesisKV, cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: "60", - }) + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -163,9 +165,6 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, ibcPath) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) require.NoError(t, err) require.Len(t, channsDym, 2) @@ -215,15 +214,9 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, gaia) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser, gaiaUser := users[0], users[1], users[2] @@ -261,9 +254,6 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { firstHopIBCDenom := firstHopDenomTrace.IBCDenom() secondHopIBCDenom := secondHopDenomTrace.IBCDenom() - zeroBal := math.ZeroInt() - transferAmount := math.NewInt(100_000) - // Send packet from rollapp1 -> dym -> gaia transfer := ibc.WalletData{ Address: dymensionUserAddr, @@ -288,7 +278,7 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { err = transferTx.Validate() require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 20, rollapp1) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) rollAppBalance, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) @@ -313,7 +303,7 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - err = testutil.WaitForBlocks(ctx, 20, dymension, gaia) + err = testutil.WaitForBlocks(ctx, 10, dymension, gaia) require.NoError(t, err) gaiaBalance, err = gaia.GetBalance(ctx, gaiaUserAddr, secondHopIBCDenom) @@ -337,10 +327,12 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { dymintTomlOverrides["gas_prices"] = "0adym" dymintTomlOverrides["empty_blocks_max_time"] = "3s" - modifyGenesisKV := append(dymensionGenesisKV, cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: "60", - }) + modifyGenesisKV := append(dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -463,9 +455,6 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, ibcPath) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) require.NoError(t, err) require.Len(t, channsDym, 2) @@ -515,15 +504,9 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, gaia) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser, gaiaUser := users[0], users[1], users[2] @@ -561,9 +544,6 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { firstHopIBCDenom := firstHopDenomTrace.IBCDenom() secondHopIBCDenom := secondHopDenomTrace.IBCDenom() - zeroBal := math.ZeroInt() - transferAmount := math.NewInt(100_000) - // Send packet from rollapp1 -> dym -> gaia transfer := ibc.WalletData{ Address: dymensionUserAddr, @@ -588,7 +568,7 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { err = transferTx.Validate() require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 20, rollapp1) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) rollAppBalance, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) @@ -613,7 +593,7 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - err = testutil.WaitForBlocks(ctx, 20, dymension, gaia) + err = testutil.WaitForBlocks(ctx, 10, dymension, gaia) require.NoError(t, err) gaiaBalance, err = gaia.GetBalance(ctx, gaiaUserAddr, secondHopIBCDenom) @@ -815,8 +795,6 @@ func TestIBCPFM_RollApp1ToRollApp2WithErc20(t *testing.T) { }, ) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) @@ -902,9 +880,6 @@ func TestIBCPFM_RollApp1ToRollApp2WithErc20(t *testing.T) { _, err = cosmos.PollForProposalStatus(ctx, rollapp2.CosmosChain, height, height+30, "1", cosmos.ProposalStatusPassed) require.NoError(t, err, "proposal status did not change to passed") - zeroBal := math.ZeroInt() - transferAmount := math.NewInt(100_000) - // Send packet from rollapp1 -> dym -> rollapp2 transfer := ibc.WalletData{ Address: dymensionUserAddr, diff --git a/tests/ibc_timeout_test.go b/tests/ibc_timeout_test.go index 6bdbf316..07f9ec32 100644 --- a/tests/ibc_timeout_test.go +++ b/tests/ibc_timeout_test.go @@ -5,7 +5,6 @@ import ( "fmt" "testing" - "cosmossdk.io/math" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" test "github.com/decentrio/rollup-e2e-testing" @@ -39,14 +38,15 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - const BLOCK_FINALITY_PERIOD = 10 + modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + Value: fmt.Sprint(10), }, ) + // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -137,15 +137,9 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for user accounts to be created - err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -157,8 +151,6 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) // Compose an IBC transfer and send from rollapp -> dymension - transferAmount := math.NewInt(1_000_000) - channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) require.NoError(t, err) @@ -184,15 +176,16 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { // Compose an IBC transfer and send from Rollapp -> Hub _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // Assert balance was updated on the rollapp testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - // wait until the packet is finalized isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) @@ -208,7 +201,7 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { // Assert funds were returned to the sender after the timeout has occured testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, math.NewInt(0)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) channel, err = ibc.GetTransferChannel(ctx, r, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID) require.NoError(t, err) @@ -222,12 +215,14 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { // Compose an IBC transfer and send from Hub -> rollapp _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, options) require.NoError(t, err) - // Assert balance was updated on the rollapp - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0)) + + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) // According to delayedack module, we need the rollapp to have finalizedHeight > ibcClientLatestHeight // in order to trigger ibc timeout or else it will trigger callback @@ -244,7 +239,7 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { require.True(t, isFinalized) // Assert funds were returned to the sender after the timeout has occured - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) t.Cleanup( @@ -274,14 +269,15 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { dymintTomlOverrides["empty_blocks_max_time"] = "3s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - const BLOCK_FINALITY_PERIOD = 10 + modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + Value: fmt.Sprint(10), }, ) + // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -372,15 +368,9 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -392,8 +382,6 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) // Compose an IBC transfer and send from rollapp -> dymension - transferAmount := math.NewInt(1_000_000) - channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) require.NoError(t, err) @@ -443,7 +431,7 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { // Assert funds were returned to the sender after the timeout has occured testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, math.NewInt(0)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) channel, err = ibc.GetTransferChannel(ctx, r, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID) require.NoError(t, err) @@ -457,12 +445,14 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { // Compose an IBC transfer and send from Hub -> rollapp _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, options) require.NoError(t, err) - // Assert balance was updated on the rollapp - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0)) + + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) // According to delayedack module, we need the rollapp to have finalizedHeight > ibcClientLatestHeight // in order to trigger ibc timeout or else it will trigger callback @@ -479,7 +469,7 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { require.True(t, isFinalized) // Assert funds were returned to the sender after the timeout has occured - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(0)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) t.Cleanup( diff --git a/tests/ibc_transfer_test.go b/tests/ibc_transfer_test.go index 411fc56c..c1071c04 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -5,7 +5,6 @@ import ( "fmt" "testing" - "cosmossdk.io/math" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" @@ -113,15 +112,9 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -148,8 +141,6 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { triggerHubGenesisEvent(t, dymension, rollapp) // Compose an IBC transfer and send from dymension -> rollapp - transferAmount := math.NewInt(1_000_000) - transferData := ibc.WalletData{ Address: rollappUserAddr, Denom: dymension.Config().Denom, @@ -165,19 +156,12 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - err = r.StopRelayer(ctx, eRep) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + err = r.StopRelayer(ctx, eRep) require.NoError(t, err) - require.True(t, isFinalized) // Get the IBC denom dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) @@ -196,19 +180,17 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // Assert balance was updated on the hub testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) // wait until the packet is finalized - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) @@ -313,52 +295,11 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { }) require.NoError(t, err) - err = r.GeneratePath(ctx, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID, ibcPath) - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 30, dymension) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = r.CreateConnections(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension) - require.NoError(t, err) - - err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - require.NoError(t, err) - - // done := make(chan bool) - // go func() { - // err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - // require.NoError(t, err) - - // done <- true - // }() - - // select { - // case <-done: - // fmt.Println("Channel created") - // case <-time.After(1 * time.Minute): - // err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) - // require.NoError(t, err) - // } - - walletAmount := math.NewInt(1_000_000_000_000) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -385,8 +326,6 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { triggerHubGenesisEvent(t, dymension, rollapp) // Compose an IBC transfer and send from dymension -> rollapp - transferAmount := math.NewInt(1_000_000) - transferData := ibc.WalletData{ Address: rollappUserAddr, Denom: dymension.Config().Denom, @@ -401,20 +340,13 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) - require.NoError(t, err) - err = r.StopRelayer(ctx, eRep) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) - rollappHeight, err := rollapp1.GetNode().Height(ctx) + err = r.StopRelayer(ctx, eRep) require.NoError(t, err) - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - // Get the IBC denom dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -432,6 +364,9 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // Assert balance was updated on the hub testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) @@ -441,11 +376,8 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - // wait until the packet is finalized - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) diff --git a/tests/rollapp_genesis_event_test.go b/tests/rollapp_genesis_event_test.go index 503efc9d..3c73dc07 100644 --- a/tests/rollapp_genesis_event_test.go +++ b/tests/rollapp_genesis_event_test.go @@ -5,7 +5,6 @@ import ( "fmt" "testing" - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" @@ -117,15 +116,9 @@ func TestRollappGenesisEvent_EVM(t *testing.T) { CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] diff --git a/tests/setup.go b/tests/setup.go index fa5b2278..af6a767c 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -8,6 +8,7 @@ import ( "testing" "time" + "cosmossdk.io/math" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" "github.com/cosmos/cosmos-sdk/x/params/client/utils" "github.com/decentrio/rollup-e2e-testing/cosmos" @@ -40,10 +41,19 @@ type ForwardMetadata struct { RefundSequence *uint64 `json:"refund_sequence,omitempty"` } -const ibcPath = "dymension-demo" -const anotherIbcPath = "dymension-demo2" +const ( + ibcPath = "dymension-demo" + anotherIbcPath = "dymension-demo2" + BLOCK_FINALITY_PERIOD = 30 +) var ( + walletAmount = math.NewInt(1_000_000_000_000) + + transferAmount = math.NewInt(1_000_000) + + zeroBal = math.ZeroInt() + DymensionMainRepo = "ghcr.io/dymensionxyz/dymension" RollappEVMMainRepo = "ghcr.io/dymensionxyz/rollapp-evm" @@ -551,16 +561,13 @@ func CreateChannel(ctx context.Context, t *testing.T, r ibc.Relayer, eRep *testr err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 30, chainA) - require.NoError(t, err) - - r.UpdateClients(ctx, eRep, ibcPath) + err = testutil.WaitForBlocks(ctx, 20, chainA, chainB) require.NoError(t, err) err = r.CreateConnections(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 10, chainA) + err = testutil.WaitForBlocks(ctx, 10, chainA, chainB) require.NoError(t, err) err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) diff --git a/tests/tx_batch_finalization_test.go b/tests/tx_batch_finalization_test.go index e55b028c..7ecacd65 100644 --- a/tests/tx_batch_finalization_test.go +++ b/tests/tx_batch_finalization_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "cosmossdk.io/math" test "github.com/decentrio/rollup-e2e-testing" "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" @@ -43,7 +42,6 @@ func TestBatchFinalization_EVM(t *testing.T) { dymintTomlOverrides["gas_prices"] = "0adym" dymintTomlOverrides["empty_blocks_max_time"] = "3s" - const BLOCK_FINALITY_PERIOD = 50 modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -132,15 +130,9 @@ func TestBatchFinalization_EVM(t *testing.T) { }) require.NoError(t, err) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] @@ -186,7 +178,6 @@ func TestBatchFinalization_Wasm(t *testing.T) { dymintTomlOverrides["gas_prices"] = "0adym" dymintTomlOverrides["empty_blocks_max_time"] = "3s" - const BLOCK_FINALITY_PERIOD = 50 modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -275,15 +266,9 @@ func TestBatchFinalization_Wasm(t *testing.T) { }) require.NoError(t, err) - walletAmount := math.NewInt(1_000_000_000_000) - // Create some user accounts on both chains users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - // Wait a few blocks for relayer to start and for user accounts to be created - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // Get our Bech32 encoded user addresses dymensionUser, rollappUser := users[0], users[1] From ea487c219334f2430d77eb983516c6fa8cc265bb Mon Sep 17 00:00:00 2001 From: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Date: Mon, 6 May 2024 17:03:10 +0700 Subject: [PATCH 25/61] Add reusable workflow for each Rollapp type (#144) --- .../workflows/e2e-test-evm-workflow-call.yml | 63 +++++++++++++++++++ .../e2e-test-wasm-workflow-call.yaml | 57 +++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 .github/workflows/e2e-test-evm-workflow-call.yml create mode 100644 .github/workflows/e2e-test-wasm-workflow-call.yaml diff --git a/.github/workflows/e2e-test-evm-workflow-call.yml b/.github/workflows/e2e-test-evm-workflow-call.yml new file mode 100644 index 00000000..5ef259fa --- /dev/null +++ b/.github/workflows/e2e-test-evm-workflow-call.yml @@ -0,0 +1,63 @@ +on: + workflow_call: + inputs: + rollapp_evm_ci: + description: "CI run on Rollapp-EVM Repo" + required: false + type: string + default: "latest" + +jobs: + # e2e-tests-by runs the actual go test command to trigger the test. + rollapp-evm: + strategy: + matrix: + tests: + - "e2e-test-ibc-success-evm" + - "e2e-test-ibc-timeout-evm" + - "e2e-test-ibc-grace-period-evm" + - "e2e-test-eibc-corrupted-memo-evm" + - "e2e-test-eibc-excessive-fee-evm" + - "e2e-test-eibc-fulfillment-evm" + - "e2e-test-eibc-fulfill-no-balance-evm" + - "e2e-test-eibc-fulfillment-thirdparty-evm" + - "e2e-test-eibc-pfm-evm" + - "e2e-test-eibc-timeout-evm" + - "e2e-test-transfer-multi-hop-evm" + - "e2e-test-pfm-with-grace-period-evm" + - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20" + - "e2e-test-pfm-gaia-to-rollapp-evm" + - "e2e-test-batch-finalization-evm" + - "e2e-test-disconnection-evm" + - "e2e-test-rollapp-freeze-evm" + - "e2e-test-other-rollapp-not-affected-evm" + - "e2e-test-rollapp-genesis-event-evm" + - "e2e-test-delayedack-pending-packets-evm" + - "e2e-test-delayedack-relayer-down-evm" + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: dymensionxyz/e2e-tests + - name: Set up Go 1.21 + uses: actions/setup-go@v4 + with: + go-version: "1.21.4" + + - name: Download Tarball Artifact + uses: actions/download-artifact@v3 + with: + name: e2e + path: /tmp + + - name: Load Docker Image + run: | + docker image load -i /tmp/e2e.tar + docker image ls -a + + - name: Rollapp-EVM E2E Tests + run: make ${{ matrix.tests }} + env: + ROLLAPP_EVM_CI: ${{ inputs.rollapp_evm_ci }} + \ No newline at end of file diff --git a/.github/workflows/e2e-test-wasm-workflow-call.yaml b/.github/workflows/e2e-test-wasm-workflow-call.yaml new file mode 100644 index 00000000..49dac84d --- /dev/null +++ b/.github/workflows/e2e-test-wasm-workflow-call.yaml @@ -0,0 +1,57 @@ +on: + workflow_call: + inputs: + rollapp_wasm_ci: + description: "CI run on Rollapp-Wasm Repo" + required: false + type: string + default: "latest" + +jobs: + # e2e-tests-by runs the actual go test command to trigger the test. + rollapp-wasm: + strategy: + matrix: + tests: + - "e2e-test-ibc-success-wasm" + - "e2e-test-ibc-timeout-wasm" + - "e2e-test-ibc-grace-period-wasm" + - "e2e-test-eibc-fulfillment-wasm" + - "e2e-test-eibc-fulfillment-thirdparty-wasm" + - "e2e-test-eibc-pfm-wasm" + - "e2e-test-transfer-multi-hop-wasm" + - "e2e-test-pfm-with-grace-period-wasm" + - "e2e-test-pfm-gaia-to-rollapp-wasm" + - "e2e-test-batch-finalization-wasm" + - "e2e-test-disconnection-wasm" + - "e2e-test-rollapp-freeze-wasm" + - "e2e-test-other-rollapp-not-affected-wasm" + - "e2e-test-delayedack-pending-packets-wasm" + - "e2e-test-delayedack-relayer-down-wasm" + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: dymensionxyz/e2e-tests + - name: Set up Go 1.21 + uses: actions/setup-go@v4 + with: + go-version: "1.21.4" + + - name: Download Tarball Artifact + uses: actions/download-artifact@v3 + with: + name: e2e + path: /tmp + + - name: Load Docker Image + run: | + docker image load -i /tmp/e2e.tar + docker image ls -a + + - name: Rollapp-Wasm E2E Tests + run: make ${{ matrix.tests }} + env: + ROLLAPP_WASM_CI: ${{ inputs.rollapp_wasm_ci }} + \ No newline at end of file From bee4330861af14c6bfb6f20b00c785b9fb342fd0 Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Mon, 6 May 2024 19:44:26 +0700 Subject: [PATCH 26/61] [eibc] E2E for TestEIBCNotFulfillment (#127) Co-authored-by: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Co-authored-by: anhductn2001 --- .github/workflows/e2e-test-workflow-call.yml | 2 + .github/workflows/e2e_test.yml | 2 + Makefile | 6 + tests/eibc_not_fulfillment_test.go | 540 +++++++++++++++++++ tests_spec/eibc.md | 4 +- 5 files changed, 552 insertions(+), 2 deletions(-) create mode 100644 tests/eibc_not_fulfillment_test.go diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 9dcf87fc..b9d0da1a 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -33,6 +33,7 @@ jobs: - "e2e-test-eibc-fulfillment-thirdparty-evm" - "e2e-test-eibc-pfm-evm" - "e2e-test-eibc-timeout-evm" + - "e2e-test-eibc-not-fulfillment-evm" - "e2e-test-transfer-multi-hop-evm" - "e2e-test-pfm-with-grace-period-evm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20" @@ -83,6 +84,7 @@ jobs: - "e2e-test-eibc-fulfillment-wasm" - "e2e-test-eibc-fulfillment-thirdparty-wasm" - "e2e-test-eibc-pfm-wasm" + - "e2e-test-eibc-not-fulfillment-wasm" - "e2e-test-transfer-multi-hop-wasm" - "e2e-test-pfm-with-grace-period-wasm" - "e2e-test-pfm-gaia-to-rollapp-wasm" diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 2ab5833c..7ad27b2f 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -35,6 +35,7 @@ jobs: - "e2e-test-eibc-fulfillment-thirdparty-evm" - "e2e-test-eibc-pfm-evm" - "e2e-test-eibc-timeout-evm" + - "e2e-test-eibc-not-fulfillment-evm" - "e2e-test-transfer-multi-hop-evm" - "e2e-test-pfm-with-grace-period-evm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20" @@ -71,6 +72,7 @@ jobs: - "e2e-test-eibc-fulfillment-wasm" - "e2e-test-eibc-fulfillment-thirdparty-wasm" - "e2e-test-eibc-pfm-wasm" + - "e2e-test-eibc-not-fulfillment-wasm" - "e2e-test-transfer-multi-hop-wasm" - "e2e-test-pfm-with-grace-period-wasm" - "e2e-test-pfm-gaia-to-rollapp-wasm" diff --git a/Makefile b/Makefile index a9c65e6d..6eabf25f 100644 --- a/Makefile +++ b/Makefile @@ -108,6 +108,12 @@ e2e-test-rollapp-freeze-wasm: clean-e2e e2e-test-other-rollapp-not-affected-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestOtherRollappNotAffected_Wasm . +e2e-test-eibc-not-fulfillment-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCNotFulfillment_EVM . + +e2e-test-eibc-not-fulfillment-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCNotFulfillment_Wasm . + e2e-test-eibc-fulfillment-thirdparty-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_ThirdParty_Wasm . diff --git a/tests/eibc_not_fulfillment_test.go b/tests/eibc_not_fulfillment_test.go new file mode 100644 index 00000000..dc974c71 --- /dev/null +++ b/tests/eibc_not_fulfillment_test.go @@ -0,0 +1,540 @@ +package tests + +import ( + "context" + "fmt" + "testing" + + "cosmossdk.io/math" + transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" + + test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" +) + +// This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub +// that is not fulfilled by the market maker +func TestEIBCNotFulfillment_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + + dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 2, len(dymChannels)) + + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp2, 1) + + require.Len(t, dymChannels, 2) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channsRollApp1[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channsRollApp1[0].Counterparty.PortID, channsRollApp1[0].Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + var options ibc.TransferOptions + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + balance, err := dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + fmt.Println("Event:", eibcEvents[0]) + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + resp, err := dymension.QueryEIBCDemandOrders(ctx, "PENDING") + require.NoError(t, err) + require.Equal(t, 1, len(resp.DemandOrders)) + + // verify funds were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + // wait until packet finalization and verify funds + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + require.True(t, balance.Equal(transferData.Amount), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferData.Amount, balance)) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +func TestEIBCNotFulfillment_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + + dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 2, len(dymChannels)) + + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp2, 1) + + require.Len(t, dymChannels, 2) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channsRollApp1[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channsRollApp1[0].Counterparty.PortID, channsRollApp1[0].Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + var options ibc.TransferOptions + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + balance, err := dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + fmt.Println("Event:", eibcEvents[0]) + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + resp, err := dymension.QueryEIBCDemandOrders(ctx, "PENDING") + require.NoError(t, err) + require.Equal(t, 1, len(resp.DemandOrders)) + + // verify funds were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + // wait until packet finalization and verify funds + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + require.True(t, balance.Equal(transferData.Amount), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferData.Amount, balance)) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} diff --git a/tests_spec/eibc.md b/tests_spec/eibc.md index 5de0c225..d7c037f6 100644 --- a/tests_spec/eibc.md +++ b/tests_spec/eibc.md @@ -13,10 +13,10 @@ | 9 | Demand order is created upon AckError for rollapp token | Same as the case above | 🛑
(missing) |
  • send the ibc token from hub to rollapp
  • Same as the case above
| 🛑
(missing) | TO DO | | 10 | eibc shouldn’t work together with PFM | At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id.| 🛑
(missing)| Try to send RAX from rollapp to Dymension:
  • with both eibc and forward objects in memo.
  • Forward object could specify an address
The transfer should not be successful and RAX should be returned to rollapp’s wallet| 🛑
(missing) | TO DO | | 11 | Demand order fulfillment | eIBC pending order on the hub | ✅ |
  • fulfill the eIBC order
  • IBC Amount goes to the fulfiller upon finalization
  • Amount - Fee goes to the user
| ✅ | [eibc_fulfillment_test](../tests/eibc_fulfillment_test.go) | -| 12 | Demand order not fulfillment | eIBC pending order on the hub | 🛑
(missing) |
  • don’t fulfill the eIBC demand order
  • user gets the entire amount upon grace period
| 🛑
(missing) | TO DO | +| 12 | Demand order not fulfillment | eIBC pending order on the hub | ✅ |
  • don’t fulfill the eIBC demand order
  • user gets the entire amount upon grace period
| ✅ | [eibc_not_fulfillment_test](../tests/eibc_not_fulfillment_test.go#L25) | | 13 | Demand order with fee > amount fails | send eIBC order (rollapp to hub) from CLI with fee > total amount (use memo) | 🛑
(missing) | should return ack error from the hub | 🛑
(missing) | TO DO | | 14 | Demand order with invalid fee fails | send eIBC order (rollapp to hub) from CLI with invalid fee (i.e minus/letters etc) | 🛑
(missing) | should return ack error from the hub | 🛑
(missing) | TO DO | | 15 | Send eIBC order (rollapp to hub) from CLI with invalid fee (i.e minus/letters etc) | | |
  • send IBC order from rollapp to hub without specifying eIBC memo
  • eibc order shouldn’t be created
  • upon finalization period amount should be transferred to original sender
| ✅ | [ibc_transfer_test](../tests/ibc_transfer_test.go) | | 16 | Demand order for hub to rollapp transfer should be ignored | | |
  • send IBC order from hub to rollapp specifying eIBC memo
  • eibc order shouldn’t be created
| 🛑
(missing) | TO DO | | 17 | Demand order fulfillment from one rollapp, no fulfillment from other rollapp |
  • eIBC order pending on the hub coming from rollapp
  • eIBC order pending on the hub coming from rollapp 2
| 🛑
(missing) |
  • fulfill the order coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TO DO | -| 18 | Demand order fulfillment in 2 different rollapps | Same as the case above | 🛑
(missing) |
  • fulfill the order coming from rollapp 1
  • fulfill the order coming from rollapp 2
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 2
  • market maker gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TO DO | \ No newline at end of file +| 18 | Demand order fulfillment in 2 different rollapps | Same as the case above | 🛑
(missing) |
  • fulfill the order coming from rollapp 1
  • fulfill the order coming from rollapp 2
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 2
  • market maker gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TO DO | From 52024e92570c782592cbcd62bd92ffab686cdf19 Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Mon, 6 May 2024 19:52:47 +0700 Subject: [PATCH 27/61] [Feat]: E2E test for finalize block (#83) Co-authored-by: Trinity Co-authored-by: anhductn2001 Co-authored-by: ducnt131 <62016666+anhductn2001@users.noreply.github.com> --- .github/workflows/e2e-test-workflow-call.yml | 6 + .github/workflows/e2e_test.yml | 6 + Makefile | 39 +- tests/ibc_finalize_block_test.go | 1029 ++++++++++++++++++ tests/setup.go | 20 + 5 files changed, 1093 insertions(+), 7 deletions(-) create mode 100644 tests/ibc_finalize_block_test.go diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index b9d0da1a..a090774b 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -44,6 +44,9 @@ jobs: - "e2e-test-rollapp-freeze-evm" - "e2e-test-other-rollapp-not-affected-evm" - "e2e-test-rollapp-genesis-event-evm" + - "e2e-test-dym-finalize-block-on-recv-packet-evm" + - "e2e-test-dym-finalize-block-on-timeout-packet-evm" + - "e2e-test-dym-finalize-block-on-ack-packet-evm" - "e2e-test-delayedack-pending-packets-evm" - "e2e-test-delayedack-relayer-down-evm" fail-fast: false @@ -93,6 +96,9 @@ jobs: - "e2e-test-fullnode-sync-wasm" - "e2e-test-rollapp-freeze-wasm" - "e2e-test-other-rollapp-not-affected-wasm" + - "e2e-test-dym-finalize-block-on-recv-packet-wasm" + - "e2e-test-dym-finalize-block-on-timeout-packet-wasm" + - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - "e2e-test-delayedack-pending-packets-wasm" - "e2e-test-delayedack-relayer-down-wasm" fail-fast: false diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 7ad27b2f..be06cbff 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -46,6 +46,9 @@ jobs: - "e2e-test-rollapp-freeze-evm" - "e2e-test-other-rollapp-not-affected-evm" - "e2e-test-rollapp-genesis-event-evm" + - "e2e-test-dym-finalize-block-on-recv-packet-evm" + - "e2e-test-dym-finalize-block-on-timeout-packet-evm" + - "e2e-test-dym-finalize-block-on-ack-packet-evm" - "e2e-test-delayedack-pending-packets-evm" - "e2e-test-delayedack-relayer-down-evm" fail-fast: false @@ -81,6 +84,9 @@ jobs: - "e2e-test-fullnode-sync-wasm" - "e2e-test-rollapp-freeze-wasm" - "e2e-test-other-rollapp-not-affected-wasm" + - "e2e-test-dym-finalize-block-on-recv-packet-wasm" + - "e2e-test-dym-finalize-block-on-timeout-packet-wasm" + - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - "e2e-test-delayedack-pending-packets-wasm" - "e2e-test-delayedack-relayer-down-wasm" fail-fast: false diff --git a/Makefile b/Makefile index 6eabf25f..66c061c1 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,15 @@ e2e-test-other-rollapp-not-affected-evm: clean-e2e e2e-test-rollapp-genesis-event-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollappGenesisEvent_EVM . +e2e-test-dym-finalize-block-on-recv-packet-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestDymFinalizeBlock_OnRecvPacket_EVM . + +e2e-test-dym-finalize-block-on-timeout-packet-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestDymFinalizeBlock_OnTimeOutPacket_EVM . + +e2e-test-dym-finalize-block-on-ack-packet-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestDymFinalizeBlock_OnAckPacket_EVM . + e2e-test-delayedack-pending-packets-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_NoFinalizedStates_EVM . @@ -117,6 +126,15 @@ e2e-test-eibc-not-fulfillment-wasm: clean-e2e e2e-test-eibc-fulfillment-thirdparty-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_ThirdParty_Wasm . +e2e-test-dym-finalize-block-on-recv-packet-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestDymFinalizeBlock_OnRecvPacket_Wasm . + +e2e-test-dym-finalize-block-on-timeout-packet-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestDymFinalizeBlock_OnTimeOutPacket_Wasm . + +e2e-test-dym-finalize-block-on-ack-packet-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestDymFinalizeBlock_OnAckPacket_Wasm . + e2e-test-pfm-gaia-to-rollapp-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferGaiaToRollApp_EVM . @@ -125,10 +143,9 @@ e2e-test-pfm-gaia-to-rollapp-wasm: clean-e2e e2e-test-delayedack-pending-packets-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_NoFinalizedStates_Wasm . - + e2e-test-delayedack-relayer-down-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_RelayerDown_Wasm . - # Executes all tests via rollup-e2e-testing e2e-test-all: e2e-test-ibc-success-evm \ @@ -137,7 +154,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-eibc-corrupted-memo-evm \ e2e-test-eibc-excessive-fee-evm \ e2e-test-eibc-fulfillment-evm \ - e2e-test-eibc-fulfill-no-balance-evm \ + e2e-test-eibc-fulfill-no-balance-evm \ e2e-test-eibc-fulfillment-thirdparty-evm \ e2e-test-eibc-pfm-evm \ e2e-test-eibc-timeout-evm \ @@ -148,7 +165,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-evm \ e2e-test-disconnection-evm \ e2e-test-rollapp-freeze-evm \ - e2e-test-other-rollapp-not-affected-evm \ + e2e-test-other-rollapp-not-affected-evm \ e2e-test-rollapp-genesis-event-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ @@ -162,10 +179,15 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-wasm \ e2e-test-disconnection-wasm \ e2e-test-rollapp-freeze-wasm \ - e2e-test-other-rollapp-not-affected-wasm \ + e2e-test-other-rollapp-not-affected-wasm \ + e2e-test-dym-finalize-block-on-recv-packet \ + e2e-test-dym-finalize-block-on-timeout-packet \ + e2e-test-dym-finalize-block-on-ack-packet\ e2e-test-delayedack-pending-packets-wasm \ e2e-test-delayedack-relayer-down-wasm + + .PHONY: clean-e2e \ e2e-test-all \ e2e-test-ibc-success-evm \ @@ -199,6 +221,9 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-wasm \ e2e-test-disconnection-wasm \ e2e-test-rollapp-freeze-wasm \ - e2e-test-other-rollapp-not-affected-wasm \ + e2e-test-other-rollapp-not-affected-wasm \ + e2e-test-dym-finalize-block-on-recv-packet \ + e2e-test-dym-finalize-block-on-timeout-packet \ + e2e-test-dym-finalize-block-on-ack-packet \ + e2e-test-other-rollapp-not-affected-wasm \ e2e-test-delayedack-pending-packets-wasm - diff --git a/tests/ibc_finalize_block_test.go b/tests/ibc_finalize_block_test.go new file mode 100644 index 00000000..83b5c5e3 --- /dev/null +++ b/tests/ibc_finalize_block_test.go @@ -0,0 +1,1029 @@ +package tests + +import ( + "bytes" + "context" + "fmt" + "testing" + + transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" + test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +// This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and ack failed. +// In this case, the destination's transfer param - "receive_enabled" was set false so this make ack failed. +func TestDymFinalizeBlock_OnRecvPacket_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + settlementLayer := "dymension" + nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollappId := "rollappevm_1234-1" + gasPrice := "0adym" + emptyBlocksMaxTimeRollapp := "3s" + configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) + + modifyGenesisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.transfer.params.receive_enabled", + Value: false, + }, + ) + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-test", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(modifyGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + // Compose an IBC transfer and send from rollapp -> dymension + ibcTx, err := dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + + dymensionHeight, err := dymension.Height(ctx) + require.NoError(t, err) + + ack, err := testutil.PollForAck(ctx, dymension, dymensionHeight, dymensionHeight+30, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that the ack contains error + require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) +} + +// This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and fail on ack. +// the packet with +func TestDymFinalizeBlock_OnAckPacket_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + settlementLayer := "dymension" + nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollappId := "rollappevm_1234-1" + gasPrice := "0adym" + emptyBlocksMaxTimeRollapp := "3s" + configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) + + // Create chain factory with dymension + numHubVals := 2 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + numVals := 1 + numFullNodes := 0 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + { + Name: "gaia", + Version: "v15.1.0", + ChainConfig: gaiaConfig, + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + gaia := chains[2].(*cosmos.CosmosChain) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + + r2 := test.NewBuiltinRelayerFactory( + ibc.CosmosRly, + zaptest.NewLogger(t), + relayer.CustomDockerImage(IBCRelayerImage, IBCRelayerVersion, "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddChain(gaia). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: gaia, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) + + // Start both relayers + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + channel0, err := ibc.GetTransferChannel(ctx, r1, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID) + require.NoError(t, err) + fmt.Println("channel: ", channel0) + channel1, err := ibc.GetTransferChannel(ctx, r2, eRep, dymension.Config().ChainID, gaia.Config().ChainID) + require.NoError(t, err) + fmt.Println("channel: ", channel1) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel0.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + dymensionHeight, err := dymension.Height(ctx) + require.NoError(t, err) + // Compose an IBC transfer and send from rollapp -> dymension + ibcTx, err := dymension.SendIBCTransfer(ctx, channel1.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was not change on the rollapp + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + + ack, err := testutil.PollForAck(ctx, dymension, dymensionHeight, dymensionHeight+50, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that the ack contains error + require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) +} + +// This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and timeout. +func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + settlementLayer := "dymension" + nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollappId := "rollappevm_1234-1" + gasPrice := "0adym" + emptyBlocksMaxTimeRollapp := "3s" + configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) + + // Create chain factory with dymension + numHubVals := 2 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + dymensionHeight, err := dymension.Height(ctx) + require.NoError(t, err) + + // Compose an IBC transfer and send from rollapp -> dymension + ibcTx, err := dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{Timeout: testutil.ImmediatelyTimeout()}) + require.NoError(t, err) + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + + got, err := testutil.PollForTimeout(ctx, dymension, dymensionHeight, dymensionHeight+30, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that we got the packet timeout + require.Equal(t, got.Packet.SourceChannel, channel.ChannelID) + + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) +} + +// This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and ack failed. +// In this case, the destination's transfer param - "receive_enabled" was set false so this make ack failed. +func TestDymFinalizeBlock_OnRecvPacket_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + settlementLayer := "dymension" + nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollappId := "rollappwasm_1234-1" + gasPrice := "0adym" + emptyBlocksMaxTimeRollapp := "3s" + configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) + + modifyGenesisKV := []cosmos.GenesisKV{ + { + Key: "app_state.transfer.params.receive_enabled", + Value: false, + }, + } + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-test", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappWasmGenesis(modifyGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + // Compose an IBC transfer and send from rollapp -> dymension + ibcTx, err := dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + + dymensionHeight, err := dymension.Height(ctx) + require.NoError(t, err) + + ack, err := testutil.PollForAck(ctx, dymension, dymensionHeight, dymensionHeight+30, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that the ack contains error + require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) +} + +// This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and fail on ack. +// the packet with +func TestDymFinalizeBlock_OnAckPacket_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + settlementLayer := "dymension" + nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollappId := "rollappwasm_1234-1" + gasPrice := "0adym" + emptyBlocksMaxTimeRollapp := "3s" + configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) + + // Create chain factory with dymension + numHubVals := 2 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + numVals := 1 + numFullNodes := 0 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + { + Name: "gaia", + Version: "v15.1.0", + ChainConfig: gaiaConfig, + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + gaia := chains[2].(*cosmos.CosmosChain) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + + r2 := test.NewBuiltinRelayerFactory( + ibc.CosmosRly, + zaptest.NewLogger(t), + relayer.CustomDockerImage(IBCRelayerImage, IBCRelayerVersion, "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddChain(gaia). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: gaia, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) + + // Start both relayers + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + channel0, err := ibc.GetTransferChannel(ctx, r1, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID) + require.NoError(t, err) + fmt.Println("channel: ", channel0) + channel1, err := ibc.GetTransferChannel(ctx, r2, eRep, dymension.Config().ChainID, gaia.Config().ChainID) + require.NoError(t, err) + fmt.Println("channel: ", channel1) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel0.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + dymensionHeight, err := dymension.Height(ctx) + require.NoError(t, err) + // Compose an IBC transfer and send from rollapp -> dymension + ibcTx, err := dymension.SendIBCTransfer(ctx, channel1.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was not change on the rollapp + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + + ack, err := testutil.PollForAck(ctx, dymension, dymensionHeight, dymensionHeight+50, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that the ack contains error + require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) +} + +// This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and timeout. +func TestDymFinalizeBlock_OnTimeOutPacket_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + settlementLayer := "dymension" + nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollappId := "rollappwasm_1234-1" + gasPrice := "0adym" + emptyBlocksMaxTimeRollapp := "3s" + configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) + + // Create chain factory with dymension + numHubVals := 2 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + dymensionHeight, err := dymension.Height(ctx) + require.NoError(t, err) + // Compose an IBC transfer and send from rollapp -> dymension + ibcTx, err := dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{Timeout: testutil.ImmediatelyTimeout()}) + require.NoError(t, err) + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + + got, err := testutil.PollForTimeout(ctx, dymension, dymensionHeight, dymensionHeight+30, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that we got the packet timeout + require.Equal(t, got.Packet.SourceChannel, channel.ChannelID) + + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) +} diff --git a/tests/setup.go b/tests/setup.go index af6a767c..10d615c4 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -438,6 +438,26 @@ func modifyRollappEVMGenesis(genesisKV []cosmos.GenesisKV) func(ibc.ChainConfig, } } +func modifyRollappWasmGenesis(genesisKV []cosmos.GenesisKV) func(ibc.ChainConfig, []byte) ([]byte, error) { + return func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { + g := make(map[string]interface{}) + if err := json.Unmarshal(inputGenBz, &g); err != nil { + return nil, fmt.Errorf("failed to unmarshal genesis file: %w", err) + } + + if err := dyno.Set(g, "10000000000", "app_state", "gov", "deposit_params", "min_deposit", 0, "amount"); err != nil { + return nil, fmt.Errorf("failed to set amount on gov min_deposit in genesis json: %w", err) + } + + outputGenBz, err := json.Marshal(g) + if err != nil { + return nil, fmt.Errorf("failed to marshal genesis bytes to json: %w", err) + } + + return cosmos.ModifyGenesis(genesisKV)(chainConfig, outputGenBz) + } +} + func modifyDymensionGenesis(genesisKV []cosmos.GenesisKV) func(ibc.ChainConfig, []byte) ([]byte, error) { return func(chainConfig ibc.ChainConfig, inputGenBz []byte) ([]byte, error) { g := make(map[string]interface{}) From 5a1892817ace36bd824cd4870faa8fc9b25681e9 Mon Sep 17 00:00:00 2001 From: lacsomot <153717732+lacsomot@users.noreply.github.com> Date: Tue, 7 May 2024 10:18:57 +0700 Subject: [PATCH 28/61] Update delayedack.md (#140) --- tests_spec/delayedack.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests_spec/delayedack.md b/tests_spec/delayedack.md index 34eff6a9..7c7efc3f 100644 --- a/tests_spec/delayedack.md +++ b/tests_spec/delayedack.md @@ -4,7 +4,7 @@ | No | Scenario | Pre-condition | Pre-condition check | Steps | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-------|-----------------|-----------------------|------------| -| 1 | IBC transfer from rollapp to hub succeeds when rollapp has NO FINALIZED STATES AT ALL | At least 2 rollapps running, Rollapp A and B. Rollapp B (our rollapp) has no finalized state. Rollapp B has height > Rollapp A height. Rollapp B has a channel-id different from the hub-channel-id and **no finalized state**| 🛑
(missing) || RollappPacket successfully created on the hub with pending status (can be checked by `dymd q delayedack packets-by-status pending`) | Partly solved
(lack query `packet commitment` left on the rollapp) | lacking | -| 2 | Rollapp token transfer should only be received on the hub upon rollapp finalized state (assume no eIBC packet, i.e no memo) | At least 2 rollapps running, Rollapp A and B. Rollapp B (our rollapp) is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id. | 🛑
(missing) || Rollapp tokens received on hub only after Rollapp B reaches finalized state. | Partly solved
(lack query `packet commitment` left on the rollapp) | [ibc_grace_period_test](../tests/ibc_grace_period_test.go) | -| 3 | DYM token transfer from hub to rollapp while relayer is down | - At least 2 rollapps running, Rollapp A and B - Rollapp B (our rollapp) is at finalized height < Rollapp A finalized height - Rollapp B (our rollapp) has a channel-id different than the hub-channel-id (i.e not both are channel-0)| 🛑
(missing) | - Validate relayer is down - Send rollapp tokens from rollapp to hub - Restart the relayer | Transfer should be picked up and recieved in the rollapp | Partly solved
(lack query `packet commitment` left on the rollapp) | lacking | +| 1 | IBC transfer from rollapp to hub succeeds when rollapp has NO FINALIZED STATES AT ALL | At least 2 rollapps running, Rollapp A and B. Rollapp B (our rollapp) has no finalized state. Rollapp B has height > Rollapp A height. Rollapp B has a channel-id different from the hub-channel-id and **no finalized state**| ✅ || RollappPacket successfully created on the hub with pending status (can be checked by `dymd q delayedack packets-by-status pending`) | ✅ | [TestDelayedAck_NoFinalizedStates_EVM](../tests/ibc_grace_period_test.go#604) [TestDelayedAck_NoFinalizedStates_Wasm](../tests/ibc_grace_period_test.go#869)| +| 2 | Rollapp token transfer should only be received on the hub upon rollapp finalized state (assume no eIBC packet, i.e no memo) | At least 2 rollapps running, Rollapp A and B. Rollapp B (our rollapp) is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id. | ✅ || Rollapp tokens received on hub only after Rollapp B reaches finalized state. | ✅ | [ibc_grace_period_test](../tests/ibc_grace_period_test.go) | +| 3 | DYM token transfer from hub to rollapp while relayer is down | - At least 2 rollapps running, Rollapp A and B - Rollapp B (our rollapp) is at finalized height < Rollapp A finalized height - Rollapp B (our rollapp) has a channel-id different than the hub-channel-id (i.e not both are channel-0)| ✅ | - Validate relayer is down - Send rollapp tokens from rollapp to hub - Restart the relayer | Transfer should be picked up and recieved in the rollapp | ✅ | [TestDelayedAck_RelayerDown_EVM](../tests/ibc_grace_period_test.go#1134) [TestDelayedAck_RelayerDown_Wasm](../tests/ibc_grace_period_test.go#1415)| From 31d24b8cb2dc5f91b4a7e479442e39ce1edac046 Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Wed, 8 May 2024 14:46:20 +0700 Subject: [PATCH 29/61] [PFM] e2e for rollapp1 to rollapp2 without register erc20 (#145) --- .../e2e-test-wasm-workflow-call.yaml | 1 + .github/workflows/e2e-test-workflow-call.yml | 1 + .github/workflows/e2e_test.yml | 1 + Makefile | 3 + tests/ibc_pfm_with_grace_period_test.go | 302 ++++++++++++++++++ tests_spec/pfm.md | 2 +- 6 files changed, 309 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-test-wasm-workflow-call.yaml b/.github/workflows/e2e-test-wasm-workflow-call.yaml index 49dac84d..b39529e3 100644 --- a/.github/workflows/e2e-test-wasm-workflow-call.yaml +++ b/.github/workflows/e2e-test-wasm-workflow-call.yaml @@ -28,6 +28,7 @@ jobs: - "e2e-test-other-rollapp-not-affected-wasm" - "e2e-test-delayedack-pending-packets-wasm" - "e2e-test-delayedack-relayer-down-wasm" + - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index a090774b..685be4ff 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -101,6 +101,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - "e2e-test-delayedack-pending-packets-wasm" - "e2e-test-delayedack-relayer-down-wasm" + - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index be06cbff..a9bc6102 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -89,6 +89,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - "e2e-test-delayedack-pending-packets-wasm" - "e2e-test-delayedack-relayer-down-wasm" + - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/Makefile b/Makefile index 66c061c1..00789d1f 100644 --- a/Makefile +++ b/Makefile @@ -102,6 +102,9 @@ e2e-test-pfm-with-grace-period-wasm: clean-e2e e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCPFM_RollApp1ToRollApp2WithErc20 . +e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestIBCPFM_RollApp1ToRollApp2WithOutErc20 . + e2e-test-batch-finalization-wasm: cd tests && go test -timeout=25m -race -v -run TestBatchFinalization_Wasm . diff --git a/tests/ibc_pfm_with_grace_period_test.go b/tests/ibc_pfm_with_grace_period_test.go index d7faf319..88b58886 100644 --- a/tests/ibc_pfm_with_grace_period_test.go +++ b/tests/ibc_pfm_with_grace_period_test.go @@ -944,3 +944,305 @@ func TestIBCPFM_RollApp1ToRollApp2WithErc20(t *testing.T) { require.NoError(t, err) require.Equal(t, 0, len(resp.Commitments)) } + +func TestIBCPFM_RollApp1ToRollApp2WithOutErc20(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + modifyGenesisKV := append(dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + channsDym, err := r1.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym, 2) + + rollapp1Chan, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, rollapp1Chan, 1) + + dymRollApp1Chan := rollapp1Chan[0].Counterparty + require.NotEmpty(t, dymRollApp1Chan.ChannelID) + + rollapp1DymChan := rollapp1Chan[0] + require.NotEmpty(t, rollapp1DymChan.ChannelID) + + rollapp2Chan, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, rollapp2Chan, 1) + + dymRollApp2Chan := rollapp2Chan[0].Counterparty + require.NotEmpty(t, dymRollApp2Chan.ChannelID) + + rollapp2DymChan := rollapp2Chan[0] + require.NotEmpty(t, rollapp2DymChan.ChannelID) + + // Start the relayer and set the cleanup function. + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer2: %s", err) + } + }, + ) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) + + // Get our Bech32 encoded user addresses + dymensionUser, rollapp1User, rollapp2User := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollapp1UserAddr := rollapp1User.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, rollapp2.Config().Denom, walletAmount) + + rollapp1Param := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: dymRollApp1Chan.ChannelID, + userKey: dymensionUser.KeyName(), + } + + rollapp2Param := rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: dymRollApp2Chan.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp1Param, rollapp2Param) + + t.Run("multihop rollapp1->dym->rollapp2, funds received on rollapp2 after grace period", func(t *testing.T) { + firstHopDenom := transfertypes.GetPrefixedDenom(dymRollApp1Chan.PortID, dymRollApp1Chan.ChannelID, rollapp1.Config().Denom) + secondHopDenom := transfertypes.GetPrefixedDenom(rollapp2DymChan.PortID, rollapp2DymChan.ChannelID, firstHopDenom) + + firstHopDenomTrace := transfertypes.ParseDenomTrace(firstHopDenom) + secondHopDenomTrace := transfertypes.ParseDenomTrace(secondHopDenom) + + firstHopIBCDenom := firstHopDenomTrace.IBCDenom() + secondHopIBCDenom := secondHopDenomTrace.IBCDenom() + + // Send packet from rollapp1 -> dym -> rollapp2 + transfer := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + firstHopMetadata := &PacketMetadata{ + Forward: &ForwardMetadata{ + Receiver: rollapp2UserAddr, + Channel: dymRollApp2Chan.ChannelID, + Port: dymRollApp2Chan.PortID, + Timeout: 5 * time.Minute, + }, + } + + memo, err := json.Marshal(firstHopMetadata) + require.NoError(t, err) + + transferTx, err := rollapp1.SendIBCTransfer(ctx, rollapp2DymChan.ChannelID, rollapp1User.KeyName(), transfer, ibc.TransferOptions{Memo: string(memo)}) + require.NoError(t, err) + err = transferTx.Validate() + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 20, rollapp1) + require.NoError(t, err) + + rollAppBalance, err := rollapp1.GetBalance(ctx, rollapp1UserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + + dymBalance, err := dymension.GetBalance(ctx, dymensionUserAddr, firstHopIBCDenom) + require.NoError(t, err) + + rollapp2UserBalance, err := rollapp2.GetBalance(ctx, rollapp2UserAddr, secondHopIBCDenom) + require.NoError(t, err) + + // Make sure that the transfer is not successful yet due to the grace period + require.True(t, rollAppBalance.Equal(walletAmount.Sub(transferAmount))) + require.True(t, dymBalance.Equal(zeroBal)) + require.True(t, rollapp2UserBalance.Equal(zeroBal)) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + err = testutil.WaitForBlocks(ctx, 20, dymension, rollapp2) + require.NoError(t, err) + + rollapp2UserBalance, err = rollapp2.GetBalance(ctx, rollapp2UserAddr, secondHopIBCDenom) + require.NoError(t, err) + require.True(t, rollapp2UserBalance.Equal(transferAmount)) + }) + // Check the commitment was deleted + resp, err := rollapp2.GetNode().QueryPacketCommitments(ctx, "transfer", rollapp2DymChan.ChannelID) + require.NoError(t, err) + require.Equal(t, 0, len(resp.Commitments)) +} diff --git a/tests_spec/pfm.md b/tests_spec/pfm.md index 541219d2..a3a953a0 100644 --- a/tests_spec/pfm.md +++ b/tests_spec/pfm.md @@ -6,5 +6,5 @@ | 2 | 3rd party chain to Rollapp | | |
  • transfer from 3rd party chain to rollapp
  • funds should be available on rollapp almost immediately
| 🛑
(missing) | TODO | | 3 | Rollapp to 3rd party chain with eIBC | | |
  • send PFM + eIBC memo should fail with ackError on hub
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TODO | | 4 | Rollapp to Rollapp - ERC20 registered | erc20 registered on rollapp2 for rollapp 1 IBC | ✅ |
  • send from rollapp 1 to rollapp 2 using PFM
  • rollapp token 1 should be available on the rollapp 2 after rollapp1 grace period is reached
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestIBCPFM_RollApp1ToRollApp2WithErc20](../tests/ibc_pfm_with_grace_period_test.go#L710)| -| 5 | Rollapp to Rollapp - ERC20 not registered | erc20 NOT registered on rollapp2 for rollapp 1 IBC | 🛑
(missing) |
  • send from rollapp 1 to rollapp 2 using PFM should fail
  • rollapp token 1 should return to rollapp1 after (rollapp1 grace period + rollapp2 grace period) is reached.
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TODO | +| 5 | Rollapp to Rollapp - ERC20 not registered | erc20 NOT registered on rollapp2 for rollapp 1 IBC | ✅ |
  • send from rollapp 1 to rollapp 2 using PFM should fail
  • rollapp token 1 should return to rollapp1 after (rollapp1 grace period + rollapp2 grace period) is reached.
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestIBCPFM_RollApp1ToRollApp2WithOutErc20](../tests/ibc_pfm_with_grace_period_test.go#L948) | | 6 | Rollapp to Rollapp + eIBC | | | send from rollapp 1 to rollapp 2 using PFM + eIBC should fail | 🛑
(missing) | TODO | From 46f5c8d00bf42a422ca610f9b81cb7db53494b7d Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Wed, 8 May 2024 14:52:26 +0700 Subject: [PATCH 30/61] [Fix] fix test `TestIBCPFM_RollApp1ToRollApp2WithErc20` (#147) --- tests/ibc_pfm_with_grace_period_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ibc_pfm_with_grace_period_test.go b/tests/ibc_pfm_with_grace_period_test.go index 88b58886..776e336a 100644 --- a/tests/ibc_pfm_with_grace_period_test.go +++ b/tests/ibc_pfm_with_grace_period_test.go @@ -904,7 +904,7 @@ func TestIBCPFM_RollApp1ToRollApp2WithErc20(t *testing.T) { err = transferTx.Validate() require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 20, rollapp1) + err = testutil.WaitForBlocks(ctx, 10, rollapp1) require.NoError(t, err) rollAppBalance, err := rollapp1.GetBalance(ctx, rollapp1UserAddr, rollapp1.Config().Denom) From a9c774da904561fea309ef4ef27c02af737e69ac Mon Sep 17 00:00:00 2001 From: Hoang Do Date: Wed, 8 May 2024 14:56:26 +0700 Subject: [PATCH 31/61] Feat: Add test demand order fulfillment in 2 different rollapps (#126) Co-authored-by: Trinity Co-authored-by: anhductn2001 --- .github/workflows/e2e-test-workflow-call.yml | 7 +- .github/workflows/e2e_test.yml | 1 + Makefile | 8 +- tests/eibc_fulfillment_test.go | 379 +++++++++++++++++++ 4 files changed, 390 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 685be4ff..227825a1 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -26,12 +26,13 @@ jobs: - "e2e-test-ibc-success-evm" - "e2e-test-ibc-timeout-evm" - "e2e-test-ibc-grace-period-evm" - - "e2e-test-eibc-corrupted-memo-evm" - - "e2e-test-eibc-excessive-fee-evm" - "e2e-test-eibc-fulfillment-evm" + - "e2e-test-eibc-fulfillment-evm-2-RAs" + - "e2e-test-eibc-pfm-evm" - "e2e-test-eibc-fulfill-no-balance-evm" + - "e2e-test-eibc-corrupted-memo-evm" + - "e2e-test-eibc-excessive-fee-evm" - "e2e-test-eibc-fulfillment-thirdparty-evm" - - "e2e-test-eibc-pfm-evm" - "e2e-test-eibc-timeout-evm" - "e2e-test-eibc-not-fulfillment-evm" - "e2e-test-transfer-multi-hop-evm" diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index a9bc6102..749b880c 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -28,6 +28,7 @@ jobs: - "e2e-test-ibc-success-evm" - "e2e-test-ibc-timeout-evm" - "e2e-test-ibc-grace-period-evm" + - "e2e-test-eibc-fulfillment-evm-2-RAs" - "e2e-test-eibc-corrupted-memo-evm" - "e2e-test-eibc-excessive-fee-evm" - "e2e-test-eibc-fulfillment-evm" diff --git a/Makefile b/Makefile index 00789d1f..5e9059f0 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,9 @@ e2e-test-ibc-success-evm: clean-e2e e2e-test-ibc-timeout-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferTimeout_EVM . +e2e-test-eibc-fulfillment-evm-2-RAs: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_two_rollapps . + e2e-test-ibc-grace-period-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCGracePeriodCompliance_EVM . @@ -157,6 +160,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-eibc-corrupted-memo-evm \ e2e-test-eibc-excessive-fee-evm \ e2e-test-eibc-fulfillment-evm \ + e2e-test-eibc-fulfillment-evm-2-RAs \ e2e-test-eibc-fulfill-no-balance-evm \ e2e-test-eibc-fulfillment-thirdparty-evm \ e2e-test-eibc-pfm-evm \ @@ -196,6 +200,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ e2e-test-ibc-grace-period-evm \ + e2e-test-eibc-fulfillment-evm-2-RAs \ e2e-test-eibc-corrupted-memo-evm \ e2e-test-eibc-excessive-fee-evm \ e2e-test-eibc-fulfillment-evm \ @@ -210,7 +215,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-evm \ e2e-test-disconnection-evm \ e2e-test-rollapp-freeze-evm \ - e2e-test-other-rollapp-not-affected-evm \ + e2e-test-other-rollapp-not-affected-evm \ e2e-test-rollapp-genesis-event-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ @@ -228,5 +233,4 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-dym-finalize-block-on-recv-packet \ e2e-test-dym-finalize-block-on-timeout-packet \ e2e-test-dym-finalize-block-on-ack-packet \ - e2e-test-other-rollapp-not-affected-wasm \ e2e-test-delayedack-pending-packets-wasm diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 7cebe48a..3ab90957 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -622,6 +622,385 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { ) } +func TestEIBCFulfillment_two_rollapps(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, rollapp2) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, rollapp2) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser, rollapp2User := users[0], users[1], users[2], users[3] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, rollapp2.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + dymChannel_ra1, err := r1.GetChannels(ctx, eRep, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 1, len(dymChannel_ra1)) + channDymRollApp1 := dymChannel_ra1[0].Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + dymChannel_ra2, err := r2.GetChannels(ctx, eRep, rollapp2.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 1, len(dymChannel_ra2)) + channDymRollApp2 := dymChannel_ra2[0].Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + rollapp1_params := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + } + rollapp2_params := rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp1_params, rollapp2_params) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + transferDataRollapp1 := ibc.WalletData{ + Address: marketMakerAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + transferDataRollapp2 := ibc.WalletData{ + Address: marketMakerAddr, + Denom: rollapp2.Config().Denom, + Amount: transferAmount, + } + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel_ra1[0].Counterparty.PortID, dymChannel_ra1[0].Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // Get the IBC denom for Rollapp 2's token on Hub + rollapp2TokenDenom := transfertypes.GetPrefixedDenom(dymChannel_ra2[0].Counterparty.PortID, dymChannel_ra2[0].Counterparty.ChannelID, rollapp2.Config().Denom) + rollapp2IBCDenom := transfertypes.ParseDenomTrace(rollapp2TokenDenom).IBCDenom() + + var options ibc.TransferOptions + // market maker needs to have funds on the hub first to be able to fulfill incoming demand order + _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + _, err = rollapp2.SendIBCTransfer(ctx, dymChannel_ra2[0].ChannelID, rollapp2UserAddr, transferDataRollapp2, options) + require.NoError(t, err) + rollapp2Height, err := rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized on Rollapp 1 + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // Wait until the packet is finalized on Rollapp 2 + isFinalizedRollapp2, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollapp2Height, 300) + require.NoError(t, err) + require.True(t, isFinalizedRollapp2) + + expMmBalanceRollappDenom := transferDataRollapp1.Amount + balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after preconditions:", balance) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // Precondition funds check on Hub for Rollapp 2 + balanceRollapp2, err := dymension.GetBalance(ctx, marketMakerAddr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after preconditions for", rollapp2IBCDenom, ":", balance) + require.True(t, balanceRollapp2.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balanceRollapp2)) + // end of preconditions + + transferDataRollapp1 = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Send funds from Rollapp 2 to Hub and set eIBC specific memo + transferDataRollapp2 = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp2.Config().Denom, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + _, err = rollapp2.SendIBCTransfer(ctx, dymChannel_ra2[0].ChannelID, rollapp2UserAddr, transferDataRollapp2, options) + require.NoError(t, err) + rollapp2Height, err = rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + zeroBalance := math.NewInt(0) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer from rollapp 2 to dym hub:", balance) + require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) + + _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + if len(eibcEvents) < 2 { + panic("There wasn't enought eibc events registered within the specified block range on the hub") + } + fmt.Println("Events:", eibcEvents[0], eibcEvents[1]) + + // fulfill demand orders + for _, eibcEvent := range eibcEvents { + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvent.ID, marketMakerAddr) + require.NoError(t, err) + fmt.Println(txhash) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmountWithoutFee), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance for ibc denom from rollapp 2 of dymensionUserAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmountWithoutFee), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub((transferAmountWithoutFee)) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 200) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferDataRollapp1.Amount) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollapp2Height, 200) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + // This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub // with third party ibc token that is fulfilled by the market maker func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { From ea03315e10128c8e67a47b45c0d7a767ccadbb08 Mon Sep 17 00:00:00 2001 From: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Date: Wed, 8 May 2024 16:10:46 +0700 Subject: [PATCH 32/61] chore: Update tests to workflows (#149) --- .github/workflows/e2e-test-evm-workflow-call.yml | 5 +++++ .github/workflows/e2e-test-wasm-workflow-call.yaml | 4 ++++ Makefile | 12 ++++++------ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e-test-evm-workflow-call.yml b/.github/workflows/e2e-test-evm-workflow-call.yml index 5ef259fa..94fc5082 100644 --- a/.github/workflows/e2e-test-evm-workflow-call.yml +++ b/.github/workflows/e2e-test-evm-workflow-call.yml @@ -16,6 +16,7 @@ jobs: - "e2e-test-ibc-success-evm" - "e2e-test-ibc-timeout-evm" - "e2e-test-ibc-grace-period-evm" + - "e2e-test-eibc-fulfillment-evm-2-RAs" - "e2e-test-eibc-corrupted-memo-evm" - "e2e-test-eibc-excessive-fee-evm" - "e2e-test-eibc-fulfillment-evm" @@ -23,6 +24,7 @@ jobs: - "e2e-test-eibc-fulfillment-thirdparty-evm" - "e2e-test-eibc-pfm-evm" - "e2e-test-eibc-timeout-evm" + - "e2e-test-eibc-not-fulfillment-evm" - "e2e-test-transfer-multi-hop-evm" - "e2e-test-pfm-with-grace-period-evm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20" @@ -32,6 +34,9 @@ jobs: - "e2e-test-rollapp-freeze-evm" - "e2e-test-other-rollapp-not-affected-evm" - "e2e-test-rollapp-genesis-event-evm" + - "e2e-test-dym-finalize-block-on-recv-packet-evm" + - "e2e-test-dym-finalize-block-on-timeout-packet-evm" + - "e2e-test-dym-finalize-block-on-ack-packet-evm" - "e2e-test-delayedack-pending-packets-evm" - "e2e-test-delayedack-relayer-down-evm" fail-fast: false diff --git a/.github/workflows/e2e-test-wasm-workflow-call.yaml b/.github/workflows/e2e-test-wasm-workflow-call.yaml index b39529e3..ae1b47d6 100644 --- a/.github/workflows/e2e-test-wasm-workflow-call.yaml +++ b/.github/workflows/e2e-test-wasm-workflow-call.yaml @@ -19,6 +19,7 @@ jobs: - "e2e-test-eibc-fulfillment-wasm" - "e2e-test-eibc-fulfillment-thirdparty-wasm" - "e2e-test-eibc-pfm-wasm" + - "e2e-test-eibc-not-fulfillment-wasm" - "e2e-test-transfer-multi-hop-wasm" - "e2e-test-pfm-with-grace-period-wasm" - "e2e-test-pfm-gaia-to-rollapp-wasm" @@ -26,6 +27,9 @@ jobs: - "e2e-test-disconnection-wasm" - "e2e-test-rollapp-freeze-wasm" - "e2e-test-other-rollapp-not-affected-wasm" + - "e2e-test-dym-finalize-block-on-recv-packet-wasm" + - "e2e-test-dym-finalize-block-on-timeout-packet-wasm" + - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - "e2e-test-delayedack-pending-packets-wasm" - "e2e-test-delayedack-relayer-down-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" diff --git a/Makefile b/Makefile index 5e9059f0..b5c66b7f 100644 --- a/Makefile +++ b/Makefile @@ -80,6 +80,12 @@ e2e-test-eibc-fulfillment-thirdparty-evm: clean-e2e e2e-test-delayedack-relayer-down-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_RelayerDown_EVM . +e2e-test-eibc-not-fulfillment-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCNotFulfillment_EVM . + +e2e-test-pfm-gaia-to-rollapp-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestIBCTransferGaiaToRollApp_EVM . + # Executes IBC tests via rollup-e2e-testing e2e-test-ibc-success-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferSuccess_Wasm . @@ -123,9 +129,6 @@ e2e-test-rollapp-freeze-wasm: clean-e2e e2e-test-other-rollapp-not-affected-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestOtherRollappNotAffected_Wasm . -e2e-test-eibc-not-fulfillment-evm: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestEIBCNotFulfillment_EVM . - e2e-test-eibc-not-fulfillment-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCNotFulfillment_Wasm . @@ -141,9 +144,6 @@ e2e-test-dym-finalize-block-on-timeout-packet-wasm: clean-e2e e2e-test-dym-finalize-block-on-ack-packet-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDymFinalizeBlock_OnAckPacket_Wasm . -e2e-test-pfm-gaia-to-rollapp-evm: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestIBCTransferGaiaToRollApp_EVM . - e2e-test-pfm-gaia-to-rollapp-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferGaiaToRollApp_Wasm . From 381172d5997906d52fbf1f406416235a63ec926f Mon Sep 17 00:00:00 2001 From: lacsomot <153717732+lacsomot@users.noreply.github.com> Date: Fri, 10 May 2024 09:37:26 +0700 Subject: [PATCH 33/61] Eibc invariant (#143) Co-authored-by: anhductn2001 --- .../workflows/e2e-test-evm-workflow-call.yml | 1 + .../e2e-test-wasm-workflow-call.yaml | 1 + .github/workflows/e2e-test-workflow-call.yml | 2 + .github/workflows/e2e_test.yml | 2 + Makefile | 14 +- go.mod | 2 +- go.sum | 4 +- tests/eibc_invariant_test.go | 713 ++++++++++++++++++ 8 files changed, 735 insertions(+), 4 deletions(-) create mode 100644 tests/eibc_invariant_test.go diff --git a/.github/workflows/e2e-test-evm-workflow-call.yml b/.github/workflows/e2e-test-evm-workflow-call.yml index 94fc5082..93c809a5 100644 --- a/.github/workflows/e2e-test-evm-workflow-call.yml +++ b/.github/workflows/e2e-test-evm-workflow-call.yml @@ -39,6 +39,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-evm" - "e2e-test-delayedack-pending-packets-evm" - "e2e-test-delayedack-relayer-down-evm" + - "e2e-test-eibc-invariant-evm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e-test-wasm-workflow-call.yaml b/.github/workflows/e2e-test-wasm-workflow-call.yaml index ae1b47d6..e3859955 100644 --- a/.github/workflows/e2e-test-wasm-workflow-call.yaml +++ b/.github/workflows/e2e-test-wasm-workflow-call.yaml @@ -32,6 +32,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - "e2e-test-delayedack-pending-packets-wasm" - "e2e-test-delayedack-relayer-down-wasm" + - "e2e-test-eibc-invariant-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" fail-fast: false runs-on: ubuntu-latest diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 227825a1..df5a60d2 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -50,6 +50,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-evm" - "e2e-test-delayedack-pending-packets-evm" - "e2e-test-delayedack-relayer-down-evm" + - "e2e-test-eibc-invariant-evm" fail-fast: false runs-on: ubuntu-latest steps: @@ -102,6 +103,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - "e2e-test-delayedack-pending-packets-wasm" - "e2e-test-delayedack-relayer-down-wasm" + - "e2e-test-eibc-invariant-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" fail-fast: false runs-on: ubuntu-latest diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 749b880c..061396c6 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -52,6 +52,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-evm" - "e2e-test-delayedack-pending-packets-evm" - "e2e-test-delayedack-relayer-down-evm" + - "e2e-test-eibc-invariant-evm" fail-fast: false runs-on: ubuntu-latest steps: @@ -90,6 +91,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - "e2e-test-delayedack-pending-packets-wasm" - "e2e-test-delayedack-relayer-down-wasm" + - "e2e-test-eibc-invariant-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" fail-fast: false runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index b5c66b7f..4582d31d 100644 --- a/Makefile +++ b/Makefile @@ -80,6 +80,9 @@ e2e-test-eibc-fulfillment-thirdparty-evm: clean-e2e e2e-test-delayedack-relayer-down-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_RelayerDown_EVM . +e2e-test-eibc-invariant-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCInvariant_EVM . + e2e-test-eibc-not-fulfillment-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCNotFulfillment_EVM . @@ -153,6 +156,9 @@ e2e-test-delayedack-pending-packets-wasm: clean-e2e e2e-test-delayedack-relayer-down-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_RelayerDown_Wasm . +e2e-test-eibc-invariant-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCInvariant_Wasm . + # Executes all tests via rollup-e2e-testing e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ @@ -174,6 +180,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-rollapp-freeze-evm \ e2e-test-other-rollapp-not-affected-evm \ e2e-test-rollapp-genesis-event-evm \ + e2e-test-eibc-invariant-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ e2e-test-ibc-grace-period-wasm \ @@ -191,7 +198,8 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-dym-finalize-block-on-timeout-packet \ e2e-test-dym-finalize-block-on-ack-packet\ e2e-test-delayedack-pending-packets-wasm \ - e2e-test-delayedack-relayer-down-wasm + e2e-test-delayedack-relayer-down-wasm \ + e2e-test-eibc-invariant-wasm @@ -217,6 +225,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-rollapp-freeze-evm \ e2e-test-other-rollapp-not-affected-evm \ e2e-test-rollapp-genesis-event-evm \ + e2e-test-eibc-invariant-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ e2e-test-ibc-grace-period-wasm \ @@ -233,4 +242,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-dym-finalize-block-on-recv-packet \ e2e-test-dym-finalize-block-on-timeout-packet \ e2e-test-dym-finalize-block-on-ack-packet \ + e2e-test-other-rollapp-not-affected-wasm \ + e2e-test-delayedack-pending-packets-wasm \ + e2e-test-eibc-invariant-wasm e2e-test-delayedack-pending-packets-wasm diff --git a/go.mod b/go.mod index 44e549e5..4fa4d163 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( cosmossdk.io/math v1.3.0 github.com/cosmos/cosmos-sdk v0.46.16 github.com/cosmos/ibc-go/v6 v6.2.1 - github.com/decentrio/rollup-e2e-testing v0.0.0-20240423082530-c894964c401d + github.com/decentrio/rollup-e2e-testing v0.0.0-20240508074709-e44fc219edcc github.com/dymensionxyz/dymension-rdk v1.1.0-beta github.com/dymensionxyz/dymension/v3 v3.1.0-rc01.0.20240404003005-53ccf8a922fd github.com/evmos/ethermint v0.22.0 diff --git a/go.sum b/go.sum index f3ab2208..826b6fb0 100644 --- a/go.sum +++ b/go.sum @@ -328,8 +328,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240423082530-c894964c401d h1:py4u2CvZAWg4uQ+m3ErDcqVoxgycZcKW1L2IPtNfVp4= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240423082530-c894964c401d/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240508074709-e44fc219edcc h1:EpkRv+EEhimbHgZVW80Vl856/avkzlZnXPX4ZT8BwHk= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240508074709-e44fc219edcc/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= diff --git a/tests/eibc_invariant_test.go b/tests/eibc_invariant_test.go new file mode 100644 index 00000000..82d70692 --- /dev/null +++ b/tests/eibc_invariant_test.go @@ -0,0 +1,713 @@ +package tests + +import ( + "context" + "fmt" + "strings" + "testing" + + "cosmossdk.io/math" + transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" + test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +func TestEIBCInvariant_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + const EPOCH_IDENTIFIER string = "minute" + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + cosmos.GenesisKV{ + Key: "app_state.delayedack.params.epoch_identifier", + Value: EPOCH_IDENTIFIER, + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + + require.Len(t, channsRollApp1, 1) + require.Len(t, channsRollApp2, 1) + require.Len(t, dymChannels, 2) + + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channsRollApp1[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channsRollApp2[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + newParams, err := dymension.QueryParam(ctx, "delayedack", "EpochIdentifier") + require.NoError(t, err) + require.Equal(t, EPOCH_IDENTIFIER, strings.ReplaceAll(newParams.Value, `"`, "")) + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + transferData := ibc.WalletData{ + Address: marketMakerAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount.MulRaw(10), + } + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channsRollApp1[0].Counterparty.PortID, channsRollApp1[0].Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + var options ibc.TransferOptions + // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + expMmBalanceRollappDenom := transferData.Amount + balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after preconditions:", balance) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // end of preconditions + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + // Send 5 ibc transfer + for i := 0; i < 5; i++ { + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + } + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + zeroBalance := math.NewInt(0) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + fmt.Println("Event:", eibcEvents[0]) + + // fulfill 2 demand order + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr) + require.NoError(t, err) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + txhash, err = dymension.FullfillDemandOrder(ctx, eibcEvents[3].ID, marketMakerAddr) + require.NoError(t, err) + eibcEvent = getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmount.MulRaw(2).Sub(eibcFee).Sub(eibcFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(transferAmountWithoutFee.MulRaw(2)) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferData.Amount.MulRaw(2)) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // Send 2 ibc transfer + for i := 0; i < 2; i++ { + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + } + + // Wait 1 epochs + ok, err := dymension.WaitUntilEpochEnds(ctx, "minute", 100) + require.NoError(t, err) + require.True(t, ok) + + // Run eibc variants + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "eibc", "demand-order-count") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "eibc", "underlying-packet-exist") + require.NoError(t, err) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +func TestEIBCInvariant_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + const EPOCH_IDENTIFIER string = "minute" + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + cosmos.GenesisKV{ + Key: "app_state.delayedack.params.epoch_identifier", + Value: EPOCH_IDENTIFIER, + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + + require.Len(t, channsRollApp1, 1) + require.Len(t, channsRollApp2, 1) + require.Len(t, dymChannels, 2) + + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channsRollApp1[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channsRollApp2[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + newParams, err := dymension.QueryParam(ctx, "delayedack", "EpochIdentifier") + require.NoError(t, err) + require.Equal(t, EPOCH_IDENTIFIER, strings.ReplaceAll(newParams.Value, `"`, "")) + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + transferData := ibc.WalletData{ + Address: marketMakerAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount.MulRaw(10), + } + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channsRollApp1[0].Counterparty.PortID, channsRollApp1[0].Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + var options ibc.TransferOptions + // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + expMmBalanceRollappDenom := transferData.Amount + balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after preconditions:", balance) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // end of preconditions + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + // Send 5 ibc transfer + for i := 0; i < 5; i++ { + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + } + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + zeroBalance := math.NewInt(0) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + fmt.Println("Event:", eibcEvents[0]) + + // fulfill 2 demand order + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr) + require.NoError(t, err) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + txhash, err = dymension.FullfillDemandOrder(ctx, eibcEvents[3].ID, marketMakerAddr) + require.NoError(t, err) + eibcEvent = getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmount.MulRaw(2).Sub(eibcFee).Sub(eibcFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(transferAmountWithoutFee.MulRaw(2)) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferData.Amount.MulRaw(2)) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // Send 2 ibc transfer + for i := 0; i < 2; i++ { + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + } + + // Wait 1 epochs + ok, err := dymension.WaitUntilEpochEnds(ctx, "minute", 100) + require.NoError(t, err) + require.True(t, ok) + + // Run eibc variants + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "eibc", "demand-order-count") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "eibc", "underlying-packet-exist") + require.NoError(t, err) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} From bec778b0f2a7536d8019e31dd173aafdf99acf36 Mon Sep 17 00:00:00 2001 From: Hoang Do Date: Fri, 10 May 2024 10:41:59 +0700 Subject: [PATCH 34/61] feat(eibc): ibc transfer from hub to rollapp should not have demand order (#133) --- .../workflows/e2e-test-evm-workflow-call.yml | 1 + .../e2e-test-wasm-workflow-call.yaml | 1 + .github/workflows/e2e-test-workflow-call.yml | 2 + .github/workflows/e2e_test.yml | 2 + Makefile | 6 + tests/eibc_fulfillment_test.go | 504 ++++++++++++++++++ tests/setup.go | 1 - tests_spec/eibc.md | 2 +- 8 files changed, 517 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-test-evm-workflow-call.yml b/.github/workflows/e2e-test-evm-workflow-call.yml index 93c809a5..bac01149 100644 --- a/.github/workflows/e2e-test-evm-workflow-call.yml +++ b/.github/workflows/e2e-test-evm-workflow-call.yml @@ -22,6 +22,7 @@ jobs: - "e2e-test-eibc-fulfillment-evm" - "e2e-test-eibc-fulfill-no-balance-evm" - "e2e-test-eibc-fulfillment-thirdparty-evm" + - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-evm" - "e2e-test-eibc-pfm-evm" - "e2e-test-eibc-timeout-evm" - "e2e-test-eibc-not-fulfillment-evm" diff --git a/.github/workflows/e2e-test-wasm-workflow-call.yaml b/.github/workflows/e2e-test-wasm-workflow-call.yaml index e3859955..8b480c8b 100644 --- a/.github/workflows/e2e-test-wasm-workflow-call.yaml +++ b/.github/workflows/e2e-test-wasm-workflow-call.yaml @@ -18,6 +18,7 @@ jobs: - "e2e-test-ibc-grace-period-wasm" - "e2e-test-eibc-fulfillment-wasm" - "e2e-test-eibc-fulfillment-thirdparty-wasm" + - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm" - "e2e-test-eibc-pfm-wasm" - "e2e-test-eibc-not-fulfillment-wasm" - "e2e-test-transfer-multi-hop-wasm" diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index df5a60d2..3b665223 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -27,6 +27,7 @@ jobs: - "e2e-test-ibc-timeout-evm" - "e2e-test-ibc-grace-period-evm" - "e2e-test-eibc-fulfillment-evm" + - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-evm" - "e2e-test-eibc-fulfillment-evm-2-RAs" - "e2e-test-eibc-pfm-evm" - "e2e-test-eibc-fulfill-no-balance-evm" @@ -87,6 +88,7 @@ jobs: - "e2e-test-ibc-timeout-wasm" - "e2e-test-ibc-grace-period-wasm" - "e2e-test-eibc-fulfillment-wasm" + - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm" - "e2e-test-eibc-fulfillment-thirdparty-wasm" - "e2e-test-eibc-pfm-wasm" - "e2e-test-eibc-not-fulfillment-wasm" diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 061396c6..39d312b2 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -32,6 +32,7 @@ jobs: - "e2e-test-eibc-corrupted-memo-evm" - "e2e-test-eibc-excessive-fee-evm" - "e2e-test-eibc-fulfillment-evm" + - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-evm" - "e2e-test-eibc-fulfill-no-balance-evm" - "e2e-test-eibc-fulfillment-thirdparty-evm" - "e2e-test-eibc-pfm-evm" @@ -75,6 +76,7 @@ jobs: - "e2e-test-ibc-timeout-wasm" - "e2e-test-ibc-grace-period-wasm" - "e2e-test-eibc-fulfillment-wasm" + - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm" - "e2e-test-eibc-fulfillment-thirdparty-wasm" - "e2e-test-eibc-pfm-wasm" - "e2e-test-eibc-not-fulfillment-wasm" diff --git a/Makefile b/Makefile index 4582d31d..793e41a0 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,12 @@ e2e-test-ibc-grace-period-evm: clean-e2e e2e-test-eibc-fulfillment-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_EVM . +e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_ignore_hub_to_RA_EVM . + +e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_ignore_hub_to_RA_Wasm . + e2e-test-eibc-pfm-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCPFM_EVM . diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 3ab90957..613d66ed 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -1789,6 +1789,510 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { ) } +func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, rollapp2) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, rollapp2) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser, rollapp2User := users[0], users[1], users[2], users[3] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, rollapp2.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + + dymChannel_ra1, err := r1.GetChannels(ctx, eRep, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 1, len(dymChannel_ra1)) + channDymRollApp1 := dymChannel_ra1[0] + require.NotEmpty(t, channDymRollApp1.ChannelID) + + dymChannel_ra2, err := r2.GetChannels(ctx, eRep, rollapp2.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 1, len(dymChannel_ra2)) + channDymRollApp2 := dymChannel_ra2[0].Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + rollapp1_params := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + } + + rollapp2_params := rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + } + + triggerHubGenesisEvent(t, dymension, rollapp1_params, rollapp2_params) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + // end of preconditions + + transferDataRollapp1 := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // set eIBC specific memo + options := ibc.TransferOptions{} + options.Memo = BuildEIbcMemo(eibcFee) + + // send fund from dymension to rollapp1 + _, err = dymension.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, dymensionUserAddr, transferDataRollapp1, options) + require.NoError(t, err) + + // get eIbc event + _, err = getEIbcEventsWithinBlockRange(ctx, dymension, 60, false) + // expect no eibc events created as ibc transfer from hub to rollapp is ignored + require.Error(t, err, "There wasn't a single 'eibc' event registered within the specified block range on the hub") + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, rollapp2) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, rollapp2) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser, rollapp2User := users[0], users[1], users[2], users[3] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, rollapp2.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + + dymChannel_ra1, err := r1.GetChannels(ctx, eRep, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 1, len(dymChannel_ra1)) + channDymRollApp1 := dymChannel_ra1[0] + require.NotEmpty(t, channDymRollApp1.ChannelID) + + dymChannel_ra2, err := r2.GetChannels(ctx, eRep, rollapp2.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 1, len(dymChannel_ra2)) + channDymRollApp2 := dymChannel_ra2[0].Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + rollapp1_params := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + } + + rollapp2_params := rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + } + + triggerHubGenesisEvent(t, dymension, rollapp1_params, rollapp2_params) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + // end of preconditions + + transferDataRollapp1 := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // set eIBC specific memo + options := ibc.TransferOptions{} + options.Memo = BuildEIbcMemo(eibcFee) + + // send fund from dymension to rollapp1 + _, err = dymension.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, dymensionUserAddr, transferDataRollapp1, options) + require.NoError(t, err) + + // get eIbc event + _, err = getEIbcEventsWithinBlockRange(ctx, dymension, 60, false) + // expect no eibc events created as ibc transfer from hub to rollapp is ignored + require.Error(t, err, "There wasn't a single 'eibc' event registered within the specified block range on the hub") + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + func getEibcEventFromTx(t *testing.T, dymension *dym_hub.DymHub, txhash string) *dymensiontesting.EibcEvent { txResp, err := dymension.GetTransaction(txhash) if err != nil { diff --git a/tests/setup.go b/tests/setup.go index 10d615c4..6fd79e16 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -140,7 +140,6 @@ var ( Key: "app_state.evm.params.evm_denom", Value: "urax", }, - { Key: "consensus_params.block.max_gas", Value: "40000000", diff --git a/tests_spec/eibc.md b/tests_spec/eibc.md index d7c037f6..865dd1ab 100644 --- a/tests_spec/eibc.md +++ b/tests_spec/eibc.md @@ -17,6 +17,6 @@ | 13 | Demand order with fee > amount fails | send eIBC order (rollapp to hub) from CLI with fee > total amount (use memo) | 🛑
(missing) | should return ack error from the hub | 🛑
(missing) | TO DO | | 14 | Demand order with invalid fee fails | send eIBC order (rollapp to hub) from CLI with invalid fee (i.e minus/letters etc) | 🛑
(missing) | should return ack error from the hub | 🛑
(missing) | TO DO | | 15 | Send eIBC order (rollapp to hub) from CLI with invalid fee (i.e minus/letters etc) | | |
  • send IBC order from rollapp to hub without specifying eIBC memo
  • eibc order shouldn’t be created
  • upon finalization period amount should be transferred to original sender
| ✅ | [ibc_transfer_test](../tests/ibc_transfer_test.go) | -| 16 | Demand order for hub to rollapp transfer should be ignored | | |
  • send IBC order from hub to rollapp specifying eIBC memo
  • eibc order shouldn’t be created
| 🛑
(missing) | TO DO | +| 16 | Demand order for hub to rollapp transfer should be ignored and not created | | |
  • send IBC order from hub to rollapp specifying eIBC memo
  • eibc order shouldn’t be created
| ✅ | [eibc_fulfillment_test](../tests/eibc_fulfillment_test.go#L1449) | | 17 | Demand order fulfillment from one rollapp, no fulfillment from other rollapp |
  • eIBC order pending on the hub coming from rollapp
  • eIBC order pending on the hub coming from rollapp 2
| 🛑
(missing) |
  • fulfill the order coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TO DO | | 18 | Demand order fulfillment in 2 different rollapps | Same as the case above | 🛑
(missing) |
  • fulfill the order coming from rollapp 1
  • fulfill the order coming from rollapp 2
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 2
  • market maker gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TO DO | From 36b60dc9d24db6d340004d6328bd1cc8b845149a Mon Sep 17 00:00:00 2001 From: lacsomot <153717732+lacsomot@users.noreply.github.com> Date: Fri, 10 May 2024 10:44:07 +0700 Subject: [PATCH 35/61] Rollapp invariants test (#148) Co-authored-by: anhductn2001 --- .../workflows/e2e-test-evm-workflow-call.yml | 1 + .../e2e-test-wasm-workflow-call.yaml | 1 + .github/workflows/e2e-test-workflow-call.yml | 2 + .github/workflows/e2e_test.yml | 2 + Makefile | 13 + tests/rollapp_invariant_test.go | 540 ++++++++++++++++++ 6 files changed, 559 insertions(+) create mode 100644 tests/rollapp_invariant_test.go diff --git a/.github/workflows/e2e-test-evm-workflow-call.yml b/.github/workflows/e2e-test-evm-workflow-call.yml index bac01149..f6faf307 100644 --- a/.github/workflows/e2e-test-evm-workflow-call.yml +++ b/.github/workflows/e2e-test-evm-workflow-call.yml @@ -41,6 +41,7 @@ jobs: - "e2e-test-delayedack-pending-packets-evm" - "e2e-test-delayedack-relayer-down-evm" - "e2e-test-eibc-invariant-evm" + - "e2e-test-rollapp-invariant-evm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e-test-wasm-workflow-call.yaml b/.github/workflows/e2e-test-wasm-workflow-call.yaml index 8b480c8b..69deb0f7 100644 --- a/.github/workflows/e2e-test-wasm-workflow-call.yaml +++ b/.github/workflows/e2e-test-wasm-workflow-call.yaml @@ -34,6 +34,7 @@ jobs: - "e2e-test-delayedack-pending-packets-wasm" - "e2e-test-delayedack-relayer-down-wasm" - "e2e-test-eibc-invariant-wasm" + - "e2e-test-rollapp-invariant-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" fail-fast: false runs-on: ubuntu-latest diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 3b665223..152f5c79 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -51,6 +51,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-evm" - "e2e-test-delayedack-pending-packets-evm" - "e2e-test-delayedack-relayer-down-evm" + - "e2e-test-rollapp-invariant-evm" - "e2e-test-eibc-invariant-evm" fail-fast: false runs-on: ubuntu-latest @@ -105,6 +106,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - "e2e-test-delayedack-pending-packets-wasm" - "e2e-test-delayedack-relayer-down-wasm" + - "e2e-test-rollapp-invariant-wasm" - "e2e-test-eibc-invariant-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" fail-fast: false diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 39d312b2..00ea3766 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -53,6 +53,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-evm" - "e2e-test-delayedack-pending-packets-evm" - "e2e-test-delayedack-relayer-down-evm" + - "e2e-test-rollapp-invariant-evm" - "e2e-test-eibc-invariant-evm" fail-fast: false runs-on: ubuntu-latest @@ -93,6 +94,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - "e2e-test-delayedack-pending-packets-wasm" - "e2e-test-delayedack-relayer-down-wasm" + - "e2e-test-rollapp-invariant-wasm" - "e2e-test-eibc-invariant-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" fail-fast: false diff --git a/Makefile b/Makefile index 793e41a0..f2602528 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,9 @@ e2e-test-eibc-fulfillment-thirdparty-evm: clean-e2e e2e-test-delayedack-relayer-down-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_RelayerDown_EVM . +e2e-test-rollapp-invariant-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestRollappInvariant_EVM . + e2e-test-eibc-invariant-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCInvariant_EVM . @@ -162,6 +165,9 @@ e2e-test-delayedack-pending-packets-wasm: clean-e2e e2e-test-delayedack-relayer-down-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_RelayerDown_Wasm . +e2e-test-rollapp-invariant-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestRollappInvariant_Wasm . + e2e-test-eibc-invariant-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCInvariant_Wasm . @@ -186,6 +192,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-rollapp-freeze-evm \ e2e-test-other-rollapp-not-affected-evm \ e2e-test-rollapp-genesis-event-evm \ + e2e-test-rollapp-invariant-evm \ e2e-test-eibc-invariant-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ @@ -204,6 +211,8 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-dym-finalize-block-on-timeout-packet \ e2e-test-dym-finalize-block-on-ack-packet\ e2e-test-delayedack-pending-packets-wasm \ + e2e-test-delayedack-relayer-down-wasm \ + e2e-test-rollapp-invariant-wasm e2e-test-delayedack-relayer-down-wasm \ e2e-test-eibc-invariant-wasm @@ -231,6 +240,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-rollapp-freeze-evm \ e2e-test-other-rollapp-not-affected-evm \ e2e-test-rollapp-genesis-event-evm \ + e2e-test-rollapp-invariant-evm \ e2e-test-eibc-invariant-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ @@ -244,6 +254,9 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-wasm \ e2e-test-disconnection-wasm \ e2e-test-rollapp-freeze-wasm \ + e2e-test-other-rollapp-not-affected-wasm \ + e2e-test-delayedack-pending-packets-wasm \ + e2e-test-rollapp-invariant-wasm \ e2e-test-other-rollapp-not-affected-wasm \ e2e-test-dym-finalize-block-on-recv-packet \ e2e-test-dym-finalize-block-on-timeout-packet \ diff --git a/tests/rollapp_invariant_test.go b/tests/rollapp_invariant_test.go new file mode 100644 index 00000000..eab80221 --- /dev/null +++ b/tests/rollapp_invariant_test.go @@ -0,0 +1,540 @@ +package tests + +import ( + "context" + "fmt" + "testing" + + test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +func TestRollappInvariant_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + + require.Len(t, channsRollApp1, 1) + require.Len(t, channsRollApp2, 1) + require.Len(t, dymChannels, 2) + + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channsRollApp1[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channsRollApp2[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // wait a few blocks + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // wait one more time as test spec requires that + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // loop for the pending states + for { + res, err := dymension.QueryRollappState(ctx, rollapp1.Config().ChainID, false) + require.NoError(t, err) + + if res.StateInfo.Status == "PENDING" { + break + } + } + + // Run eibc variants + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "rollapp-state-index") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "rollapp-count") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "block-height-to-finalization-queue") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "rollapp-by-eip155-key") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "rollapp-finalized-state") + require.NoError(t, err) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +func TestRollappInvariant_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + + require.Len(t, channsRollApp1, 1) + require.Len(t, channsRollApp2, 1) + require.Len(t, dymChannels, 2) + + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channsRollApp1[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channsRollApp2[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // wait a few blocks + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // wait one more time as test spec requires that + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // loop for the pending states + for { + res, err := dymension.QueryRollappState(ctx, rollapp1.Config().ChainID, false) + require.NoError(t, err) + + if res.StateInfo.Status == "PENDING" { + break + } + } + + // Run eibc variants + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "rollapp-state-index") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "rollapp-count") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "block-height-to-finalization-queue") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "rollapp-by-eip155-key") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "rollapp-finalized-state") + require.NoError(t, err) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} From ff46f60e6a14a878a2c71a566429a60f88b12d8e Mon Sep 17 00:00:00 2001 From: lacsomot <153717732+lacsomot@users.noreply.github.com> Date: Fri, 10 May 2024 17:10:54 +0700 Subject: [PATCH 36/61] Add TestSequencerInvariant and CI (#151) Co-authored-by: anhductn2001 --- .../workflows/e2e-test-evm-workflow-call.yml | 1 + .../e2e-test-wasm-workflow-call.yaml | 1 + .github/workflows/e2e-test-workflow-call.yml | 2 + .github/workflows/e2e_test.yml | 2 + Makefile | 11 +- clean.sh | 1 + go.mod | 2 +- go.sum | 4 +- tests/sequencer_invariant_test.go | 546 ++++++++++++++++++ 9 files changed, 566 insertions(+), 4 deletions(-) create mode 100644 tests/sequencer_invariant_test.go diff --git a/.github/workflows/e2e-test-evm-workflow-call.yml b/.github/workflows/e2e-test-evm-workflow-call.yml index f6faf307..bc351fbd 100644 --- a/.github/workflows/e2e-test-evm-workflow-call.yml +++ b/.github/workflows/e2e-test-evm-workflow-call.yml @@ -40,6 +40,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-evm" - "e2e-test-delayedack-pending-packets-evm" - "e2e-test-delayedack-relayer-down-evm" + - "e2e-test-sequencer-invariant-evm" - "e2e-test-eibc-invariant-evm" - "e2e-test-rollapp-invariant-evm" fail-fast: false diff --git a/.github/workflows/e2e-test-wasm-workflow-call.yaml b/.github/workflows/e2e-test-wasm-workflow-call.yaml index 69deb0f7..8c28f2a9 100644 --- a/.github/workflows/e2e-test-wasm-workflow-call.yaml +++ b/.github/workflows/e2e-test-wasm-workflow-call.yaml @@ -36,6 +36,7 @@ jobs: - "e2e-test-eibc-invariant-wasm" - "e2e-test-rollapp-invariant-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" + - "e2e-test-sequencer-invariant-wasm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 152f5c79..10889ed3 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -51,6 +51,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-evm" - "e2e-test-delayedack-pending-packets-evm" - "e2e-test-delayedack-relayer-down-evm" + - "e2e-test-sequencer-invariant-evm" - "e2e-test-rollapp-invariant-evm" - "e2e-test-eibc-invariant-evm" fail-fast: false @@ -109,6 +110,7 @@ jobs: - "e2e-test-rollapp-invariant-wasm" - "e2e-test-eibc-invariant-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" + - "e2e-test-sequencer-invariant-wasm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 00ea3766..139bdfff 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -53,6 +53,7 @@ jobs: - "e2e-test-dym-finalize-block-on-ack-packet-evm" - "e2e-test-delayedack-pending-packets-evm" - "e2e-test-delayedack-relayer-down-evm" + - "e2e-test-sequencer-invariant-evm" - "e2e-test-rollapp-invariant-evm" - "e2e-test-eibc-invariant-evm" fail-fast: false @@ -97,6 +98,7 @@ jobs: - "e2e-test-rollapp-invariant-wasm" - "e2e-test-eibc-invariant-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" + - "e2e-test-sequencer-invariant-wasm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/Makefile b/Makefile index f2602528..32f2c40d 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,9 @@ e2e-test-eibc-fulfillment-thirdparty-evm: clean-e2e e2e-test-delayedack-relayer-down-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_RelayerDown_EVM . +e2e-test-sequencer-invariant-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestSequencerInvariant_EVM . + e2e-test-rollapp-invariant-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollappInvariant_EVM . @@ -165,6 +168,9 @@ e2e-test-delayedack-pending-packets-wasm: clean-e2e e2e-test-delayedack-relayer-down-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_RelayerDown_Wasm . +e2e-test-sequencer-invariant-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestSequencerInvariant_Wasm . + e2e-test-rollapp-invariant-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollappInvariant_Wasm . @@ -192,6 +198,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-rollapp-freeze-evm \ e2e-test-other-rollapp-not-affected-evm \ e2e-test-rollapp-genesis-event-evm \ + e2e-test-sequencer-invariant-evm \ e2e-test-rollapp-invariant-evm \ e2e-test-eibc-invariant-evm \ e2e-test-ibc-success-wasm \ @@ -212,7 +219,8 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-dym-finalize-block-on-ack-packet\ e2e-test-delayedack-pending-packets-wasm \ e2e-test-delayedack-relayer-down-wasm \ - e2e-test-rollapp-invariant-wasm + e2e-test-sequencer-invariant-wasm \ + e2e-test-rollapp-invariant-wasm \ e2e-test-delayedack-relayer-down-wasm \ e2e-test-eibc-invariant-wasm @@ -240,6 +248,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-rollapp-freeze-evm \ e2e-test-other-rollapp-not-affected-evm \ e2e-test-rollapp-genesis-event-evm \ + e2e-test-sequencer-invariant-evm \ e2e-test-rollapp-invariant-evm \ e2e-test-eibc-invariant-evm \ e2e-test-ibc-success-wasm \ diff --git a/clean.sh b/clean.sh index 879bda03..027d0011 100644 --- a/clean.sh +++ b/clean.sh @@ -3,5 +3,6 @@ rm -rf /tmp/relayer* rm -rf /tmp/rollapp* rm -rf /tmp/dym* +rm -rf /tmp/sequencer* echo "Clean success!!" diff --git a/go.mod b/go.mod index 4fa4d163..f8d804ba 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( cosmossdk.io/math v1.3.0 github.com/cosmos/cosmos-sdk v0.46.16 github.com/cosmos/ibc-go/v6 v6.2.1 - github.com/decentrio/rollup-e2e-testing v0.0.0-20240508074709-e44fc219edcc + github.com/decentrio/rollup-e2e-testing v0.0.0-20240510065640-e2f6cde97a45 github.com/dymensionxyz/dymension-rdk v1.1.0-beta github.com/dymensionxyz/dymension/v3 v3.1.0-rc01.0.20240404003005-53ccf8a922fd github.com/evmos/ethermint v0.22.0 diff --git a/go.sum b/go.sum index 826b6fb0..99c9648b 100644 --- a/go.sum +++ b/go.sum @@ -328,8 +328,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240508074709-e44fc219edcc h1:EpkRv+EEhimbHgZVW80Vl856/avkzlZnXPX4ZT8BwHk= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240508074709-e44fc219edcc/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240510065640-e2f6cde97a45 h1:wmgyQI+YE0UJIP+S3W8Yx2QmbnhuvgiTUDJZ5ExU6CY= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240510065640-e2f6cde97a45/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= diff --git a/tests/sequencer_invariant_test.go b/tests/sequencer_invariant_test.go new file mode 100644 index 00000000..f9499a54 --- /dev/null +++ b/tests/sequencer_invariant_test.go @@ -0,0 +1,546 @@ +package tests + +import ( + "context" + "fmt" + "testing" + + test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +func TestSequencerInvariant_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + _, _, err = rollapp1.GetNode().ExecInit(ctx, "sequencer1", "/var/cosmos-chain/sequencer1") + require.NoError(t, err) + + command := append([]string{rollapp1.GetNode().Chain.Config().Bin}, "dymint", "show-sequencer", "--home", "/var/cosmos-chain/sequencer1") + pub1, _, err := rollapp1.GetNode().Exec(ctx, command, nil) + require.NoError(t, err) + + _, _, err = rollapp1.GetNode().ExecInit(ctx, "sequencer2", "/var/cosmos-chain/sequencer2") + require.NoError(t, err) + + command = append([]string{rollapp1.GetNode().Chain.Config().Bin}, "dymint", "show-sequencer", "--home", "/var/cosmos-chain/sequencer2") + pub2, _, err := rollapp1.GetNode().Exec(ctx, command, nil) + require.NoError(t, err) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, dymension, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, sequencer1, sequencer2, rollappUser := users[0], users[1], users[2], users[3], users[4] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + command = []string{} + command = append(command, "sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, "{\"Moniker\":\"myrollapp-sequencer\",\"Identity\":\"\",\"Website\":\"\",\"SecurityContact\":\"\",\"Details\":\"\"}", "1000000000adym", + "--broadcast-mode", "block") + + _, err = dymension.GetNode().ExecTx(ctx, sequencer1.KeyName(), command...) + require.NoError(t, err) + + command = []string{} + command = append(command, "sequencer", "create-sequencer", string(pub2), rollapp1.Config().ChainID, "{\"Moniker\":\"myrollapp-sequencer\",\"Identity\":\"\",\"Website\":\"\",\"SecurityContact\":\"\",\"Details\":\"\"}", "1000000000adym", + "--broadcast-mode", "block") + + _, err = dymension.GetNode().ExecTx(ctx, sequencer2.KeyName(), command...) + require.NoError(t, err) + + res, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, len(res.Sequencers), 3, "should have 3 sequences") + + err = dymension.Unbond(ctx, sequencer1.KeyName(), "") + require.NoError(t, err) + + queryGetSequencerResponse, err := dymension.QueryShowSequencer(ctx, sequencer1.FormattedAddress()) + require.NoError(t, err) + require.Equal(t, queryGetSequencerResponse.Sequencer.Status, "OPERATING_STATUS_UNBONDING") + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + + require.Len(t, channsRollApp1, 1) + require.Len(t, channsRollApp2, 1) + require.Len(t, dymChannels, 2) + + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channsRollApp1[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channsRollApp2[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // Run eibc variants + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "sequencer", "sequencers-count") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "sequencer", "sequencers-per-rollapp") + require.NoError(t, err) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +func TestSequencerInvariant_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + _, _, err = rollapp1.GetNode().ExecInit(ctx, "sequencer1", "/var/cosmos-chain/sequencer1") + require.NoError(t, err) + + command := append([]string{rollapp1.GetNode().Chain.Config().Bin}, "dymint", "show-sequencer", "--home", "/var/cosmos-chain/sequencer1") + pub1, _, err := rollapp1.GetNode().Exec(ctx, command, nil) + require.NoError(t, err) + + _, _, err = rollapp1.GetNode().ExecInit(ctx, "sequencer2", "/var/cosmos-chain/sequencer2") + require.NoError(t, err) + + command = append([]string{rollapp1.GetNode().Chain.Config().Bin}, "dymint", "show-sequencer", "--home", "/var/cosmos-chain/sequencer2") + pub2, _, err := rollapp1.GetNode().Exec(ctx, command, nil) + require.NoError(t, err) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, dymension, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, sequencer1, sequencer2, rollappUser := users[0], users[1], users[2], users[3], users[4] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + command = []string{} + command = append(command, "sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, "{\"Moniker\":\"myrollapp-sequencer\",\"Identity\":\"\",\"Website\":\"\",\"SecurityContact\":\"\",\"Details\":\"\"}", "1000000000adym", + "--broadcast-mode", "block") + + _, err = dymension.GetNode().ExecTx(ctx, sequencer1.KeyName(), command...) + require.NoError(t, err) + + command = []string{} + command = append(command, "sequencer", "create-sequencer", string(pub2), rollapp1.Config().ChainID, "{\"Moniker\":\"myrollapp-sequencer\",\"Identity\":\"\",\"Website\":\"\",\"SecurityContact\":\"\",\"Details\":\"\"}", "1000000000adym", + "--broadcast-mode", "block") + + _, err = dymension.GetNode().ExecTx(ctx, sequencer2.KeyName(), command...) + require.NoError(t, err) + + res, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, len(res.Sequencers), 3, "should have 3 sequences") + + err = dymension.Unbond(ctx, sequencer1.KeyName(), "") + require.NoError(t, err) + + queryGetSequencerResponse, err := dymension.QueryShowSequencer(ctx, sequencer1.FormattedAddress()) + require.NoError(t, err) + require.Equal(t, queryGetSequencerResponse.Sequencer.Status, "OPERATING_STATUS_UNBONDING") + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + + require.Len(t, channsRollApp1, 1) + require.Len(t, channsRollApp2, 1) + require.Len(t, dymChannels, 2) + + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channsRollApp1[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channsRollApp2[0].Counterparty.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // Run eibc variants + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "sequencer", "sequencers-count") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "sequencer", "sequencers-per-rollapp") + require.NoError(t, err) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} From 50cb0a88bb6fb372f8fe6c45832fe3162cab6832 Mon Sep 17 00:00:00 2001 From: Hoang Do Date: Mon, 13 May 2024 12:00:04 +0700 Subject: [PATCH 37/61] Chore(spec): update test spec to reflect main branch (#150) --- tests_spec/delayedack.md | 7 +++---- tests_spec/eibc.md | 16 ++++++++-------- tests_spec/pfm.md | 2 +- tests_spec/rollapp_genesis.md | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/tests_spec/delayedack.md b/tests_spec/delayedack.md index 7c7efc3f..a4e18f1f 100644 --- a/tests_spec/delayedack.md +++ b/tests_spec/delayedack.md @@ -4,7 +4,6 @@ | No | Scenario | Pre-condition | Pre-condition check | Steps | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-------|-----------------|-----------------------|------------| -| 1 | IBC transfer from rollapp to hub succeeds when rollapp has NO FINALIZED STATES AT ALL | At least 2 rollapps running, Rollapp A and B. Rollapp B (our rollapp) has no finalized state. Rollapp B has height > Rollapp A height. Rollapp B has a channel-id different from the hub-channel-id and **no finalized state**| ✅ || RollappPacket successfully created on the hub with pending status (can be checked by `dymd q delayedack packets-by-status pending`) | ✅ | [TestDelayedAck_NoFinalizedStates_EVM](../tests/ibc_grace_period_test.go#604) [TestDelayedAck_NoFinalizedStates_Wasm](../tests/ibc_grace_period_test.go#869)| -| 2 | Rollapp token transfer should only be received on the hub upon rollapp finalized state (assume no eIBC packet, i.e no memo) | At least 2 rollapps running, Rollapp A and B. Rollapp B (our rollapp) is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id. | ✅ || Rollapp tokens received on hub only after Rollapp B reaches finalized state. | ✅ | [ibc_grace_period_test](../tests/ibc_grace_period_test.go) | -| 3 | DYM token transfer from hub to rollapp while relayer is down | - At least 2 rollapps running, Rollapp A and B - Rollapp B (our rollapp) is at finalized height < Rollapp A finalized height - Rollapp B (our rollapp) has a channel-id different than the hub-channel-id (i.e not both are channel-0)| ✅ | - Validate relayer is down - Send rollapp tokens from rollapp to hub - Restart the relayer | Transfer should be picked up and recieved in the rollapp | ✅ | [TestDelayedAck_RelayerDown_EVM](../tests/ibc_grace_period_test.go#1134) [TestDelayedAck_RelayerDown_Wasm](../tests/ibc_grace_period_test.go#1415)| - +| 1 | IBC transfer from rollapp to hub succeeds when rollapp has NO FINALIZED STATES AT ALL | At least 2 rollapps running, Rollapp A and B. Rollapp B (our rollapp) has no finalized state. Rollapp B has height > Rollapp A height. Rollapp B has a channel-id different from the hub-channel-id and **no finalized state**| ✅ || RollappPacket successfully created on the hub with pending status (can be checked by `dymd q delayedack packets-by-status pending`) | ✅ | [TestDelayedAck_NoFinalizedStates_EVM](../tests/ibc_grace_period_test.go#577) [TestDelayedAck_NoFinalizedStates_Wasm](../tests/ibc_grace_period_test.go#832)| +| 2 | Rollapp token transfer should only be received on the hub upon rollapp finalized state (assume no eIBC packet, i.e no memo) | At least 2 rollapps running, Rollapp A and B. Rollapp B (our rollapp) is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id. | ✅ || Rollapp tokens received on hub only after Rollapp B reaches finalized state. | ✅ | [TestIBCGracePeriodCompliance_EVM](../tests/ibc_grace_period_test.go#24) [TestIBCGracePeriodCompliance_Wasm](../tests/ibc_grace_period_test.go#301)| +| 3 | DYM token transfer from hub to rollapp while relayer is down | - At least 2 rollapps running, Rollapp A and B - Rollapp B (our rollapp) is at finalized height < Rollapp A finalized height - Rollapp B (our rollapp) has a channel-id different than the hub-channel-id (i.e not both are channel-0)| ✅ | - Validate relayer is down - Send rollapp tokens from rollapp to hub - Restart the relayer | Transfer should be picked up and recieved in the rollapp | ✅ | [TestDelayedAck_RelayerDown_EVM](../tests/ibc_grace_period_test.go#1087) [TestDelayedAck_RelayerDown_Wasm](../tests/ibc_grace_period_test.go#1357)| diff --git a/tests_spec/eibc.md b/tests_spec/eibc.md index 865dd1ab..fcb8eb20 100644 --- a/tests_spec/eibc.md +++ b/tests_spec/eibc.md @@ -2,21 +2,21 @@ | No | Scenario | Pre-condition | Pre-condition check | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-----------------|-----------------------|------------| -| 1 | Rollapp token Demand order is created upon memo submission and fulfilled |At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id. | 🛑
(missing) | Demand order for Rollapp tokens created and fulfilled upon memo submission. | Partly solved
(lack query `packet commitment` left on the rollapp) | [eibc_fulfillment_test](../tests/eibc_fulfillment_test.go) | -| 2 | DYM Demand order is created upon memo submission and fulfilled | Same as the case above | 🛑
(missing) | Timeout triggered for EIBC transaction from hub to rollapp due to non-finalization. | Partly solved
(lack query `packet commitment` left on the rollapp) | [eibc_fulfillment_test](../tests/eibc_fulfillment_test.go) | -| 3 | 3rd party token (i.e blumbus) Demand order is created upon memo submission and fulfilled | Same as the case above | 🛑
(missing) |
  • Eibc demand order created
  • Fulfill the eibc demand order
  • Verify the originator gets the funds minus the fee right away
  • Verify the fulfiller gets the full amount after the grace period is finalized
  • No packet commitment left on the rollapp (i.e. ack received). Can be queried using the CLI rollapp-evm q ibc channel packet-commitments transfer \
| 🛑
(missing) | TO DO | -| 4 | DYM ibc transfer timeout | Same as the case above | 🛑
(missing) |
  • send **dym** from dymension to rollapp
  • set minimum packet timeout (i.e. 1ms) so that the packet is not relayed before it is picked by a relayer
  • sender should get funds back after grace period.
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
  • demand order is created with correct ibc denom and fee
  • demand order can get fulfilled
  • upon timeout the funds should go to the fulfiller
| Partly solved
(lack query `packet commitment` left on the rollapp) | [ibc_timeout_test](../tests/ibc_timeout_test.go) | -| 5 | Rollapp token ibc-transfer timeout | Same as the case above | 🛑
(missing) |
  • send rollapp IBC denom from dymension to rollapp
  • Same as the case above
| Partly solved
(lack query `packet commitment` left on the rollapp) | [ibc_timeout_test](../tests/ibc_timeout_test.go) | +| 1 | Rollapp token Demand order is created upon memo submission and fulfilled |At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id. | ✅ | Demand order for Rollapp tokens created and fulfilled upon memo submission. | ✅ | [TestEIBCFulfillment_EVM](../tests/ibc_grace_period_test.go#28) [TestEIBCFulfillment_Wasm](../tests/eibc_fulfillment_test.go#322) | +| 2 | DYM Demand order is created upon memo submission and fulfilled | Same as the case above | ✅ | Timeout triggered for EIBC transaction from hub to rollapp due to non-finalization. | ✅ | [TestEIBCTimeoutHubToRollapp](../tests/eibc_timeout_test.go#24) | +| 3 | 3rd party token (i.e blumbus) Demand order is created upon memo submission and fulfilled | Same as the case above | ✅ |
  • Eibc demand order created
  • Fulfill the eibc demand order
  • Verify the originator gets the funds minus the fee right away
  • Verify the fulfiller gets the full amount after the grace period is finalized
  • No packet commitment left on the rollapp (i.e. ack received). Can be queried using the CLI rollapp-evm q ibc channel packet-commitments transfer \
| ✅ | [TestEIBCFulfillment_ThirdParty_EVM](../tests/eibc_fulfillment_test.go#1006) [TestEIBCFulfillment_ThirdParty_Wasm](../tests/eibc_fulfillment_test.go#1405)| +| 4 | DYM ibc transfer timeout | Same as the case above | ✅ |
  • send **dym** from dymension to rollapp
  • set minimum packet timeout (i.e. 1ms) so that the packet is not relayed before it is picked by a relayer
  • sender should get funds back after grace period.
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
  • demand order is created with correct ibc denom and fee
  • demand order can get fulfilled
  • upon timeout the funds should go to the fulfiller
| | [TestIBCTransferTimeout_EVM](../tests/ibc_timeout_test.go#25) [TestIBCTransferTimeout_Wasm](../tests/ibc_timeout_test.go#256) | +| 5 | Rollapp token ibc-transfer timeout | Same as the case above | ✅ |
  • send rollapp IBC denom from dymension to rollapp
  • Same as the case above
| | [TestIBCTransferTimeout_EVM](../tests/ibc_timeout_test.go#25) [TestIBCTransferTimeout_Wasm](../tests/ibc_timeout_test.go#256) | | 6 | 3rd party token Demand order is created upon timeout and fulfilled | Same as the case above | 🛑
(missing) |
  • send 3rd party IBC denom from dymension to rollapp
  • the amount returned should be smaller by a 0.15% fee
  • market maker is able to fulfill it
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
  • upon timeout the funds should go to the fulfiller
| 🛑
(missing) | TO DO | | 7 | Demand order is created upon AckError for dym |
  • IBC which exists on the evm-rollapp but doesn’t have erc20
  • At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id.
| 🛑
(missing) |
  • send the DYM token from hub to rollapp
  • fulfiller the order with the IBC denom
  • ack error returned from the rollapp
  • eibc ack error demand order is created with correct denom and correct data
  • eibc managed to get fulfilled
  • upon ack error the funds should go to the fulfiller
| 🛑
(missing) | TO DO | | 8 | Demand order is created upon AckError for 3rd party token | Same as the case above | 🛑
(missing) |
  • send the ibc token from hub to rollapp
  • Same as the case above
| 🛑
(missing) | TO DO | | 9 | Demand order is created upon AckError for rollapp token | Same as the case above | 🛑
(missing) |
  • send the ibc token from hub to rollapp
  • Same as the case above
| 🛑
(missing) | TO DO | | 10 | eibc shouldn’t work together with PFM | At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id.| 🛑
(missing)| Try to send RAX from rollapp to Dymension:
  • with both eibc and forward objects in memo.
  • Forward object could specify an address
The transfer should not be successful and RAX should be returned to rollapp’s wallet| 🛑
(missing) | TO DO | -| 11 | Demand order fulfillment | eIBC pending order on the hub | ✅ |
  • fulfill the eIBC order
  • IBC Amount goes to the fulfiller upon finalization
  • Amount - Fee goes to the user
| ✅ | [eibc_fulfillment_test](../tests/eibc_fulfillment_test.go) | -| 12 | Demand order not fulfillment | eIBC pending order on the hub | ✅ |
  • don’t fulfill the eIBC demand order
  • user gets the entire amount upon grace period
| ✅ | [eibc_not_fulfillment_test](../tests/eibc_not_fulfillment_test.go#L25) | +| 11 | Demand order fulfillment | eIBC pending order on the hub | ✅ |
  • fulfill the eIBC order
  • IBC Amount goes to the fulfiller upon finalization
  • Amount - Fee goes to the user
| ✅ | [TestEIBCFulfillment_EVM](../tests/ibc_grace_period_test.go#28) [TestEIBCFulfillment_Wasm](../tests/eibc_fulfillment_test.go#322) | +| 12 | Demand order not fulfillment | eIBC pending order on the hub | ✅ |
  • don’t fulfill the eIBC demand order
  • user gets the entire amount upon grace period
| ✅ | [TestEIBCNotFulfillment_EVM](../tests/eibc_not_fulfillment_test.go#L25) [TestEIBCNotFulfillment_Wasm](../tests/eibc_not_fulfillment_test.go#L285) | | 13 | Demand order with fee > amount fails | send eIBC order (rollapp to hub) from CLI with fee > total amount (use memo) | 🛑
(missing) | should return ack error from the hub | 🛑
(missing) | TO DO | | 14 | Demand order with invalid fee fails | send eIBC order (rollapp to hub) from CLI with invalid fee (i.e minus/letters etc) | 🛑
(missing) | should return ack error from the hub | 🛑
(missing) | TO DO | | 15 | Send eIBC order (rollapp to hub) from CLI with invalid fee (i.e minus/letters etc) | | |
  • send IBC order from rollapp to hub without specifying eIBC memo
  • eibc order shouldn’t be created
  • upon finalization period amount should be transferred to original sender
| ✅ | [ibc_transfer_test](../tests/ibc_transfer_test.go) | | 16 | Demand order for hub to rollapp transfer should be ignored and not created | | |
  • send IBC order from hub to rollapp specifying eIBC memo
  • eibc order shouldn’t be created
| ✅ | [eibc_fulfillment_test](../tests/eibc_fulfillment_test.go#L1449) | | 17 | Demand order fulfillment from one rollapp, no fulfillment from other rollapp |
  • eIBC order pending on the hub coming from rollapp
  • eIBC order pending on the hub coming from rollapp 2
| 🛑
(missing) |
  • fulfill the order coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TO DO | -| 18 | Demand order fulfillment in 2 different rollapps | Same as the case above | 🛑
(missing) |
  • fulfill the order coming from rollapp 1
  • fulfill the order coming from rollapp 2
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 2
  • market maker gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TO DO | +| 18 | Demand order fulfillment in 2 different rollapps | Same as the case above | ✅ |
  • fulfill the order coming from rollapp 1
  • fulfill the order coming from rollapp 2
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 2
  • market maker gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestEIBCFulfillment_two_rollapps](../tests/eibc_fulfillment_test.go#625) | diff --git a/tests_spec/pfm.md b/tests_spec/pfm.md index a3a953a0..1a600dd6 100644 --- a/tests_spec/pfm.md +++ b/tests_spec/pfm.md @@ -2,7 +2,7 @@ | No | Scenario | Pre-condition | Pre-condition check | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-----------------|-----------------------|------------| -| 1 | Rollapp to 3rd party chain | | |
  • Try to send RAX from rollapp to an external chain, eibc should be switched off
  • RAX should be available on a 3rd party chain after rollapp grace period is reached
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| Partly solved
(lack query `packet commitment` left on the rollapp) | [test_pfm_with_grace_period](../tests/ibc_pfm_with_grace_period_test.go) | +| 1 | Rollapp to 3rd party chain | | |
  • Try to send RAX from rollapp to an external chain, eibc should be switched off
  • RAX should be available on a 3rd party chain after rollapp grace period is reached
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TODO | | 2 | 3rd party chain to Rollapp | | |
  • transfer from 3rd party chain to rollapp
  • funds should be available on rollapp almost immediately
| 🛑
(missing) | TODO | | 3 | Rollapp to 3rd party chain with eIBC | | |
  • send PFM + eIBC memo should fail with ackError on hub
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TODO | | 4 | Rollapp to Rollapp - ERC20 registered | erc20 registered on rollapp2 for rollapp 1 IBC | ✅ |
  • send from rollapp 1 to rollapp 2 using PFM
  • rollapp token 1 should be available on the rollapp 2 after rollapp1 grace period is reached
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestIBCPFM_RollApp1ToRollApp2WithErc20](../tests/ibc_pfm_with_grace_period_test.go#L710)| diff --git a/tests_spec/rollapp_genesis.md b/tests_spec/rollapp_genesis.md index a80a956c..8e27c395 100644 --- a/tests_spec/rollapp_genesis.md +++ b/tests_spec/rollapp_genesis.md @@ -2,7 +2,7 @@ | No | Scenario | Pre-condition | Pre-condition check | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-----------------|-----------------------|------------| -| 1 | Rollapp genesis tokens on the hub upon channel creation |
  • Create relevant genesis accounts and metadata info
  • Upon channel creation, trigger genesis events in both rollapp and hub (special tx)
| 🛑
(missing) |
  • denometadata should be created
  • VFC should be created on hub (i.e erc20)
  • Rollapp tokens with relevant amount should be locked on the rollapp
  • genesis accounts should have the relevant balance on the hub
| 🛑
(missing) | TODO | +| 1 | Rollapp genesis tokens on the hub upon channel creation |
  • Create relevant genesis accounts and metadata info
  • Upon channel creation, trigger genesis events in both rollapp and hub (special tx)
| ✅ |
  • denometadata should be created
  • VFC should be created on hub (i.e erc20)
  • Rollapp tokens with relevant amount should be locked on the rollapp
  • genesis accounts should have the relevant balance on the hub
| ✅ | [TestRollappGenesisEvent_EVM](../tests/rollapp_genesis_event_test.go#24) | | 2 | Transfer rollapp genesis tokens on the hub | |🛑
(missing) |
  • should be able to transfer the tokens to a different address on the hub
  • should be able to import the erc20 rep and transfer it on the rollapp
| 🛑
(missing) | TODO | | 3 | Transfer rollapp tokens between hub ↔ rollapp BEFORE rollapp has any finalized state on the hub (and both events were triggered) |
  • Rollapp shouldn’t have any finalized state on the hub
  • Rollapp and hub genesis event were triggered
|🛑
(missing) |
  • transfer from hub to rollapp should work as expected
  • transfer from rollapp to hub should work as expected
  • transferring all the genesis tokens from hub to rollapp should work as expected
| 🛑
(missing) | TODO | | 4 | Transfer rollapp tokens between hub ↔ rollapp AFTER rollapp has any finalized state on the hub |
  • Rollapp should have any finalized state on the hub
  • Rollapp and hub genesis event were triggered
|🛑
(missing) |
  • transfer from hub to rollapp should work as expected
  • transfer from rollapp to hub should work as expected
  • transferring all the genesis tokens from hub to rollapp should work as expected
| 🛑
(missing) | TODO | From 7c17a62d3523da3b53f4e5044ade2295a9410a48 Mon Sep 17 00:00:00 2001 From: nguyen | decentrio <144610611+trinitys7@users.noreply.github.com> Date: Mon, 13 May 2024 15:40:54 +0700 Subject: [PATCH 38/61] Upgrade rollapp non state breaking (#153) --- .../workflows/e2e-test-evm-workflow-call.yml | 1 + .../e2e-test-wasm-workflow-call.yaml | 1 + .github/workflows/e2e-test-workflow-call.yml | 2 + .github/workflows/e2e_test.yml | 2 + Makefile | 37 +- tests/rollapp_upgrade_test.go | 417 ++++++++++++++++++ tests_spec/rollapp_upgrade.md | 2 +- 7 files changed, 445 insertions(+), 17 deletions(-) create mode 100644 tests/rollapp_upgrade_test.go diff --git a/.github/workflows/e2e-test-evm-workflow-call.yml b/.github/workflows/e2e-test-evm-workflow-call.yml index bc351fbd..a7492d37 100644 --- a/.github/workflows/e2e-test-evm-workflow-call.yml +++ b/.github/workflows/e2e-test-evm-workflow-call.yml @@ -43,6 +43,7 @@ jobs: - "e2e-test-sequencer-invariant-evm" - "e2e-test-eibc-invariant-evm" - "e2e-test-rollapp-invariant-evm" + - "e2e-test-rollapp-upgrade-non-state-breaking-evm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e-test-wasm-workflow-call.yaml b/.github/workflows/e2e-test-wasm-workflow-call.yaml index 8c28f2a9..19920c6e 100644 --- a/.github/workflows/e2e-test-wasm-workflow-call.yaml +++ b/.github/workflows/e2e-test-wasm-workflow-call.yaml @@ -37,6 +37,7 @@ jobs: - "e2e-test-rollapp-invariant-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" - "e2e-test-sequencer-invariant-wasm" + - "e2e-test-rollapp-upgrade-non-state-breaking-wasm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 10889ed3..a7d9d928 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -54,6 +54,7 @@ jobs: - "e2e-test-sequencer-invariant-evm" - "e2e-test-rollapp-invariant-evm" - "e2e-test-eibc-invariant-evm" + - "e2e-test-rollapp-upgrade-non-state-breaking-evm" fail-fast: false runs-on: ubuntu-latest steps: @@ -111,6 +112,7 @@ jobs: - "e2e-test-eibc-invariant-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" - "e2e-test-sequencer-invariant-wasm" + - "e2e-test-rollapp-upgrade-non-state-breaking-wasm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 139bdfff..63dcca37 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -56,6 +56,7 @@ jobs: - "e2e-test-sequencer-invariant-evm" - "e2e-test-rollapp-invariant-evm" - "e2e-test-eibc-invariant-evm" + - "e2e-test-rollapp-upgrade-non-state-breaking-evm" fail-fast: false runs-on: ubuntu-latest steps: @@ -99,6 +100,7 @@ jobs: - "e2e-test-eibc-invariant-wasm" - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" - "e2e-test-sequencer-invariant-wasm" + - "e2e-test-rollapp-upgrade-non-state-breaking-wasm" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/Makefile b/Makefile index 32f2c40d..cfdd5ad2 100644 --- a/Makefile +++ b/Makefile @@ -101,6 +101,9 @@ e2e-test-eibc-not-fulfillment-evm: clean-e2e e2e-test-pfm-gaia-to-rollapp-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferGaiaToRollApp_EVM . +e2e-test-rollapp-upgrade-non-state-breaking-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestRollappUpgradeNonStateBreaking_EVM . + # Executes IBC tests via rollup-e2e-testing e2e-test-ibc-success-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferSuccess_Wasm . @@ -177,6 +180,9 @@ e2e-test-rollapp-invariant-wasm: clean-e2e e2e-test-eibc-invariant-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCInvariant_Wasm . +e2e-test-rollapp-upgrade-non-state-breaking-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestRollappUpgradeNonStateBreaking_Wasm . + # Executes all tests via rollup-e2e-testing e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ @@ -184,9 +190,10 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-eibc-corrupted-memo-evm \ e2e-test-eibc-excessive-fee-evm \ e2e-test-eibc-fulfillment-evm \ - e2e-test-eibc-fulfillment-evm-2-RAs \ - e2e-test-eibc-fulfill-no-balance-evm \ + e2e-test-eibc-fulfillment-evm-2-RAs \ + e2e-test-eibc-fulfill-no-balance-evm \ e2e-test-eibc-fulfillment-thirdparty-evm \ + e2e-test-eibc-invariant-evm \ e2e-test-eibc-pfm-evm \ e2e-test-eibc-timeout-evm \ e2e-test-transfer-multi-hop-evm \ @@ -196,16 +203,17 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-evm \ e2e-test-disconnection-evm \ e2e-test-rollapp-freeze-evm \ - e2e-test-other-rollapp-not-affected-evm \ + e2e-test-other-rollapp-not-affected-evm \ e2e-test-rollapp-genesis-event-evm \ e2e-test-sequencer-invariant-evm \ e2e-test-rollapp-invariant-evm \ - e2e-test-eibc-invariant-evm \ + e2e-test-rollapp-upgrade-non-state-breaking-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ e2e-test-ibc-grace-period-wasm \ e2e-test-eibc-fulfillment-wasm \ e2e-test-eibc-fulfillment-thirdparty-wasm \ + e2e-test-eibc-invariant-wasm \ e2e-test-eibc-pfm-wasm \ e2e-test-transfer-multi-hop-wasm \ e2e-test-pfm-with-grace-period-wasm \ @@ -213,7 +221,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-wasm \ e2e-test-disconnection-wasm \ e2e-test-rollapp-freeze-wasm \ - e2e-test-other-rollapp-not-affected-wasm \ + e2e-test-other-rollapp-not-affected-wasm \ e2e-test-dym-finalize-block-on-recv-packet \ e2e-test-dym-finalize-block-on-timeout-packet \ e2e-test-dym-finalize-block-on-ack-packet\ @@ -221,10 +229,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-delayedack-relayer-down-wasm \ e2e-test-sequencer-invariant-wasm \ e2e-test-rollapp-invariant-wasm \ - e2e-test-delayedack-relayer-down-wasm \ - e2e-test-eibc-invariant-wasm - - + e2e-test-rollapp-upgrade-non-state-breaking-wasm .PHONY: clean-e2e \ e2e-test-all \ @@ -237,6 +242,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-eibc-fulfillment-evm \ e2e-test-eibc-fulfill-no-balance-evm \ e2e-test-eibc-fulfillment-thirdparty-evm \ + e2e-test-eibc-invariant-evm \ e2e-test-eibc-pfm-evm \ e2e-test-eibc-timeout-evm \ e2e-test-transfer-multi-hop-evm \ @@ -246,16 +252,17 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-evm \ e2e-test-disconnection-evm \ e2e-test-rollapp-freeze-evm \ - e2e-test-other-rollapp-not-affected-evm \ + e2e-test-other-rollapp-not-affected-evm \ e2e-test-rollapp-genesis-event-evm \ e2e-test-sequencer-invariant-evm \ e2e-test-rollapp-invariant-evm \ - e2e-test-eibc-invariant-evm \ + e2e-test-rollapp-upgrade-non-state-breaking-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ e2e-test-ibc-grace-period-wasm \ e2e-test-eibc-fulfillment-wasm \ e2e-test-eibc-fulfillment-thirdparty-wasm \ + e2e-test-eibc-invariant-wasm \ e2e-test-eibc-pfm-wasm \ e2e-test-transfer-multi-hop-wasm \ e2e-test-pfm-with-grace-period-wasm \ @@ -266,11 +273,9 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-other-rollapp-not-affected-wasm \ e2e-test-delayedack-pending-packets-wasm \ e2e-test-rollapp-invariant-wasm \ - e2e-test-other-rollapp-not-affected-wasm \ + e2e-test-other-rollapp-not-affected-wasm \ e2e-test-dym-finalize-block-on-recv-packet \ e2e-test-dym-finalize-block-on-timeout-packet \ e2e-test-dym-finalize-block-on-ack-packet \ - e2e-test-other-rollapp-not-affected-wasm \ - e2e-test-delayedack-pending-packets-wasm \ - e2e-test-eibc-invariant-wasm - e2e-test-delayedack-pending-packets-wasm + e2e-test-other-rollapp-not-affected-wasm \ + e2e-test-rollapp-upgrade-non-state-breaking-wasm diff --git a/tests/rollapp_upgrade_test.go b/tests/rollapp_upgrade_test.go new file mode 100644 index 00000000..52b36892 --- /dev/null +++ b/tests/rollapp_upgrade_test.go @@ -0,0 +1,417 @@ +package tests + +import ( + "context" + "fmt" + "testing" + + transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" + test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +// TestRollappUpgradeNonStateBreaking_EVM ensure that the non state breaking upgrade works properly. +func TestRollappUpgradeNonStateBreaking_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + // Create chain factory with dymension + numHubVals := 2 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + preUpgradeRollappEVMImage := ibc.DockerImage{ + Repository: "ghcr.io/decentrio/rollapp-evm", + Version: "pre-upgrade-non-state-breaking", + UidGid: "1025:1025", + } + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{preUpgradeRollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + // Switch to a new binary + err = rollapp1.StopAllNodes(ctx) + require.NoError(t, err, "error stopping node(s)") + + rollapp1.UpgradeVersion(ctx, client, "ghcr.io/decentrio/rollapp-evm", "post-upgrade-non-state-breaking") + + err = rollapp1.StartAllNodes(ctx) + require.NoError(t, err, "error starting node(s)") + + // Compose an IBC transfer and send from dymension -> rollapp + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from Hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + err = r.StopRelayer(ctx, eRep) + require.NoError(t, err) + + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // Assert funds were returned to the sender after the timeout has occured + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount) +} + +func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + // Create chain factory with dymension + numHubVals := 2 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + preUpgradeRollappWasmImage := ibc.DockerImage{ + Repository: "ghcr.io/decentrio/rollapp-wasm", + Version: "pre-upgrade-non-state-breaking", + UidGid: "1025:1025", + } + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{preUpgradeRollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + // Switch to a new binary + err = rollapp1.StopAllNodes(ctx) + require.NoError(t, err, "error stopping node(s)") + + rollapp1.UpgradeVersion(ctx, client, "ghcr.io/decentrio/rollapp-wasm", "post-upgrade-non-state-breaking") + + err = rollapp1.StartAllNodes(ctx) + require.NoError(t, err, "error starting node(s)") + + // Compose an IBC transfer and send from dymension -> rollapp + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from Hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + err = r.StopRelayer(ctx, eRep) + require.NoError(t, err) + + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // Assert funds were returned to the sender after the timeout has occured + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount) +} diff --git a/tests_spec/rollapp_upgrade.md b/tests_spec/rollapp_upgrade.md index 1b292341..85d69932 100644 --- a/tests_spec/rollapp_upgrade.md +++ b/tests_spec/rollapp_upgrade.md @@ -2,5 +2,5 @@ | No | Scenario | Pre-condition | Pre-condition check | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-----------------|-----------------------|------------| -| 1 | Test non state breaking binary upgrade | Running rollapp | 🛑
(missing) | Change to a new binary and rollapp should continue functioning with upgraded version | 🛑
(missing) | TODO | +| 1 | Test non state breaking binary upgrade | Running rollapp | ✅ | Change to a new binary and rollapp should continue functioning with upgraded version | ✅ | [TestRollappUpgradeNonStateBreaking_EVM](../tests/rollapp_upgrade_test.go#28) [TestRollappUpgradeNonStateBreaking_Wasm](../tests/rollapp_upgrade_test.go#220) | | 2 | Test upgrade which requires migration | Running rollapp and governor have enough tokens to vote for a governance proposal|🛑
(missing) | Vote for upgrade and rollapp should continue functioning with upgraded version | 🛑
(missing) | TODO | From 8d833273156e56935c5bda75dd4055d746d7ed8f Mon Sep 17 00:00:00 2001 From: Hoang Do Date: Mon, 13 May 2024 17:35:26 +0700 Subject: [PATCH 39/61] feat: eibc fulfillment on one rollapp and no fulfill on the other (#131) --- .../workflows/e2e-test-evm-workflow-call.yml | 1 + .../e2e-test-wasm-workflow-call.yaml | 1 + .github/workflows/e2e-test-workflow-call.yml | 2 + .github/workflows/e2e_test.yml | 2 + Makefile | 6 + tests/eibc_fulfillment_test.go | 744 +++++++++++++++++- tests_spec/eibc.md | 10 +- 7 files changed, 759 insertions(+), 7 deletions(-) diff --git a/.github/workflows/e2e-test-evm-workflow-call.yml b/.github/workflows/e2e-test-evm-workflow-call.yml index a7492d37..096cfc3e 100644 --- a/.github/workflows/e2e-test-evm-workflow-call.yml +++ b/.github/workflows/e2e-test-evm-workflow-call.yml @@ -16,6 +16,7 @@ jobs: - "e2e-test-ibc-success-evm" - "e2e-test-ibc-timeout-evm" - "e2e-test-ibc-grace-period-evm" + - "e2e-test-eibc-fulfillment-only-one-evm" - "e2e-test-eibc-fulfillment-evm-2-RAs" - "e2e-test-eibc-corrupted-memo-evm" - "e2e-test-eibc-excessive-fee-evm" diff --git a/.github/workflows/e2e-test-wasm-workflow-call.yaml b/.github/workflows/e2e-test-wasm-workflow-call.yaml index 19920c6e..bf7d790b 100644 --- a/.github/workflows/e2e-test-wasm-workflow-call.yaml +++ b/.github/workflows/e2e-test-wasm-workflow-call.yaml @@ -16,6 +16,7 @@ jobs: - "e2e-test-ibc-success-wasm" - "e2e-test-ibc-timeout-wasm" - "e2e-test-ibc-grace-period-wasm" + - "e2e-test-eibc-fulfillment-only-one-wasm" - "e2e-test-eibc-fulfillment-wasm" - "e2e-test-eibc-fulfillment-thirdparty-wasm" - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm" diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index a7d9d928..4be58bac 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -26,6 +26,7 @@ jobs: - "e2e-test-ibc-success-evm" - "e2e-test-ibc-timeout-evm" - "e2e-test-ibc-grace-period-evm" + - "e2e-test-eibc-fulfillment-only-one-evm" - "e2e-test-eibc-fulfillment-evm" - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-evm" - "e2e-test-eibc-fulfillment-evm-2-RAs" @@ -90,6 +91,7 @@ jobs: - "e2e-test-ibc-success-wasm" - "e2e-test-ibc-timeout-wasm" - "e2e-test-ibc-grace-period-wasm" + - "e2e-test-eibc-fulfillment-only-one-wasm" - "e2e-test-eibc-fulfillment-wasm" - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm" - "e2e-test-eibc-fulfillment-thirdparty-wasm" diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 63dcca37..b8dd3f0e 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -28,6 +28,7 @@ jobs: - "e2e-test-ibc-success-evm" - "e2e-test-ibc-timeout-evm" - "e2e-test-ibc-grace-period-evm" + - "e2e-test-eibc-fulfillment-only-one-evm" - "e2e-test-eibc-fulfillment-evm-2-RAs" - "e2e-test-eibc-corrupted-memo-evm" - "e2e-test-eibc-excessive-fee-evm" @@ -78,6 +79,7 @@ jobs: - "e2e-test-ibc-success-wasm" - "e2e-test-ibc-timeout-wasm" - "e2e-test-ibc-grace-period-wasm" + - "e2e-test-eibc-fulfillment-only-one-wasm" - "e2e-test-eibc-fulfillment-wasm" - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm" - "e2e-test-eibc-fulfillment-thirdparty-wasm" diff --git a/Makefile b/Makefile index cfdd5ad2..e938e3c5 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,9 @@ e2e-test-ibc-success-evm: clean-e2e e2e-test-ibc-timeout-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferTimeout_EVM . +e2e-test-eibc-fulfillment-only-one-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillOnOneRollApp_EVM . + e2e-test-eibc-fulfillment-evm-2-RAs: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_two_rollapps . @@ -111,6 +114,9 @@ e2e-test-ibc-success-wasm: clean-e2e e2e-test-ibc-timeout-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferTimeout_Wasm . +e2e-test-eibc-fulfillment-only-one-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillOnOneRollApp_Wasm . + e2e-test-eibc-fulfillment-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_Wasm . diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 613d66ed..f4c501c2 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -3,6 +3,7 @@ package tests import ( "context" "fmt" + "regexp" "strconv" "testing" @@ -23,6 +24,745 @@ import ( "github.com/decentrio/rollup-e2e-testing/testutil" ) +// TestEIBCFulfillOnOneRollApp tests the case where we have 2 rollapps running, we have pending eIBC packets from both rollapps. one of the packets is fulfilled by the market maker, the other packet is not fulfilled. The test verifies that the funds are transferred correctly and the market maker's balance is updated correctly (after grace period). +func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, rollapp2) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser, rollapp2User := users[0], users[1], users[2], users[3] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, rollapp2.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + dymChannel_ra1, err := r1.GetChannels(ctx, eRep, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 1, len(dymChannel_ra1)) + channDymRollApp1 := dymChannel_ra1[0].Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + dymChannel_ra2, err := r2.GetChannels(ctx, eRep, rollapp2.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 1, len(dymChannel_ra2)) + channDymRollApp2 := dymChannel_ra2[0].Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + rollapp1_params := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + } + + rollapp2_params := rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + } + + triggerHubGenesisEvent(t, dymension, rollapp1_params, rollapp2_params) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + transferDataRollapp1 := ibc.WalletData{ + Address: marketMakerAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel_ra1[0].Counterparty.PortID, dymChannel_ra1[0].Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // Get the IBC denom for Rollapp 2's token on Hub + rollapp2TokenDenom := transfertypes.GetPrefixedDenom(dymChannel_ra2[0].Counterparty.PortID, dymChannel_ra2[0].Counterparty.ChannelID, rollapp2.Config().Denom) + rollapp2IBCDenom := transfertypes.ParseDenomTrace(rollapp2TokenDenom).IBCDenom() + + var options ibc.TransferOptions + // market maker needs to have funds on the hub first to be able to fulfill incoming demand order + _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + rollapp2Height, err := rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized on Rollapps + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollapp2Height, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + expMmBalanceRollappDenom := transferDataRollapp1.Amount + balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after preconditions:", balance) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // end of preconditions + + transferDataRollapp1 = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + transferDataRollapp2 := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp2.Config().Denom, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + _, err = rollapp2.SendIBCTransfer(ctx, dymChannel_ra2[0].ChannelID, rollapp2UserAddr, transferDataRollapp2, options) + require.NoError(t, err) + zeroBalance := math.NewInt(0) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer from rollapp 2 to dym hub:", balance) + require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) + + _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer from rollapp 1 to dym hub:", balance) + require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + for i, eibcEvent := range eibcEvents { + fmt.Println(i, "EIBC Event:", eibcEvent) + } + + var fulfill_demand_order = false + // fulfill demand orders from rollapp 1 + for _, eibcEvent := range eibcEvents { + re := regexp.MustCompile(`^\d+`) + if re.ReplaceAllString(eibcEvent.Price, "") == rollappIBCDenom && eibcEvent.PacketStatus == "PENDING" { + fmt.Println("EIBC Event:", eibcEvent) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvent.ID, marketMakerAddr) + require.NoError(t, err) + fmt.Println(txhash) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + fulfill_demand_order = true + } + } + + require.Equal(t, true, fulfill_demand_order) + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmountWithoutFee), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + + // verify correct funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub((transferAmountWithoutFee)) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 200) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferDataRollapp1.Amount) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // user should have received funds upon grace period of IBC packet from rollapp 2 + err = testutil.WaitForBlocks(ctx, 30, rollapp2) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr for rollapp 2 ibc denom after grace period:", balance) + require.True(t, balance.Equal(transferDataRollapp2.Amount), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferDataRollapp2.Amount, balance)) + + // No packet commitments left + res, err := rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", dymChannel_ra1[0].ChannelID) + require.NoError(t, err) + require.Equal(t, len(res.Commitments) > 0, false, "packet commitments exist") + + res, err = rollapp2.GetNode().QueryPacketCommitments(ctx, "transfer", dymChannel_ra2[0].ChannelID) + require.NoError(t, err) + require.Equal(t, len(res.Commitments) > 0, false, "packet commitments exist") + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +// TestEIBCFulfillOnOneRollApp tests the case where we have 2 rollapps running, we have pending eIBC packets from both rollapps. one of the packets is fulfilled by the market maker, the other packet is not fulfilled. The test verifies that the funds are transferred correctly and the market maker's balance is updated correctly (after grace period). +func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, rollapp2) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser, rollapp2User := users[0], users[1], users[2], users[3] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, rollapp2.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + dymChannel_ra1, err := r1.GetChannels(ctx, eRep, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 1, len(dymChannel_ra1)) + channDymRollApp1 := dymChannel_ra1[0].Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + dymChannel_ra2, err := r2.GetChannels(ctx, eRep, rollapp2.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 1, len(dymChannel_ra2)) + channDymRollApp2 := dymChannel_ra2[0].Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + rollapp1_params := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + } + + rollapp2_params := rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + } + + triggerHubGenesisEvent(t, dymension, rollapp1_params, rollapp2_params) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + transferDataRollapp1 := ibc.WalletData{ + Address: marketMakerAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel_ra1[0].Counterparty.PortID, dymChannel_ra1[0].Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // Get the IBC denom for Rollapp 2's token on Hub + rollapp2TokenDenom := transfertypes.GetPrefixedDenom(dymChannel_ra2[0].Counterparty.PortID, dymChannel_ra2[0].Counterparty.ChannelID, rollapp2.Config().Denom) + rollapp2IBCDenom := transfertypes.ParseDenomTrace(rollapp2TokenDenom).IBCDenom() + + var options ibc.TransferOptions + // market maker needs to have funds on the hub first to be able to fulfill incoming demand order + _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + rollapp2Height, err := rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized on Rollapps + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollapp2Height, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + expMmBalanceRollappDenom := transferDataRollapp1.Amount + balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after preconditions:", balance) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // end of preconditions + + transferDataRollapp1 = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + transferDataRollapp2 := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp2.Config().Denom, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + _, err = rollapp2.SendIBCTransfer(ctx, dymChannel_ra2[0].ChannelID, rollapp2UserAddr, transferDataRollapp2, options) + require.NoError(t, err) + zeroBalance := math.NewInt(0) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer from rollapp 2 to dym hub:", balance) + require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) + + _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + for i, eibcEvent := range eibcEvents { + fmt.Println(i, "EIBC Event:", eibcEvent) + } + + var fulfill_demand_order = false + // fulfill demand orders from rollapp 1 + for _, eibcEvent := range eibcEvents { + re := regexp.MustCompile(`^\d+`) + if re.ReplaceAllString(eibcEvent.Price, "") == rollappIBCDenom && eibcEvent.PacketStatus == "PENDING" { + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvent.ID, marketMakerAddr) + require.NoError(t, err) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + fulfill_demand_order = true + } + } + + require.Equal(t, true, fulfill_demand_order) + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmountWithoutFee), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + + // verify correct funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub((transferAmountWithoutFee)) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 200) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferDataRollapp1.Amount) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // user should have received funds upon grace period of IBC packet from rollapp 2 + err = testutil.WaitForBlocks(ctx, 30, rollapp2) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr for rollapp 2 ibc denom after grace period:", balance) + require.True(t, balance.Equal(transferDataRollapp2.Amount), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferDataRollapp2.Amount, balance)) + + // No packet commitments left + res, err := rollapp1.GetNode().QueryPacketCommitments(ctx, "transfer", dymChannel_ra1[0].ChannelID) + require.NoError(t, err) + require.Equal(t, len(res.Commitments) > 0, false, "packet commitments exist") + + res, err = rollapp2.GetNode().QueryPacketCommitments(ctx, "transfer", dymChannel_ra2[0].ChannelID) + require.NoError(t, err) + require.Equal(t, len(res.Commitments) > 0, false, "packet commitments exist") + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + // This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub // that is fulfilled by the market maker func TestEIBCFulfillment_EVM(t *testing.T) { @@ -2023,7 +2763,7 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { require.NoError(t, err) // get eIbc event - _, err = getEIbcEventsWithinBlockRange(ctx, dymension, 60, false) + _, err = getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) // expect no eibc events created as ibc transfer from hub to rollapp is ignored require.Error(t, err, "There wasn't a single 'eibc' event registered within the specified block range on the hub") @@ -2275,7 +3015,7 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { require.NoError(t, err) // get eIbc event - _, err = getEIbcEventsWithinBlockRange(ctx, dymension, 60, false) + _, err = getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) // expect no eibc events created as ibc transfer from hub to rollapp is ignored require.Error(t, err, "There wasn't a single 'eibc' event registered within the specified block range on the hub") diff --git a/tests_spec/eibc.md b/tests_spec/eibc.md index fcb8eb20..b08dc92e 100644 --- a/tests_spec/eibc.md +++ b/tests_spec/eibc.md @@ -2,9 +2,9 @@ | No | Scenario | Pre-condition | Pre-condition check | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-----------------|-----------------------|------------| -| 1 | Rollapp token Demand order is created upon memo submission and fulfilled |At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id. | ✅ | Demand order for Rollapp tokens created and fulfilled upon memo submission. | ✅ | [TestEIBCFulfillment_EVM](../tests/ibc_grace_period_test.go#28) [TestEIBCFulfillment_Wasm](../tests/eibc_fulfillment_test.go#322) | +| 1 | Rollapp token Demand order is created upon memo submission and fulfilled |At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id. | ✅ | Demand order for Rollapp tokens created and fulfilled upon memo submission. | ✅ | [TestEIBCFulfillment_EVM](../tests/eibc_fulfillment_test.go#768) [TestEIBCFulfillment_Wasm](../tests/eibc_fulfillment_test.go#1062) | | 2 | DYM Demand order is created upon memo submission and fulfilled | Same as the case above | ✅ | Timeout triggered for EIBC transaction from hub to rollapp due to non-finalization. | ✅ | [TestEIBCTimeoutHubToRollapp](../tests/eibc_timeout_test.go#24) | -| 3 | 3rd party token (i.e blumbus) Demand order is created upon memo submission and fulfilled | Same as the case above | ✅ |
  • Eibc demand order created
  • Fulfill the eibc demand order
  • Verify the originator gets the funds minus the fee right away
  • Verify the fulfiller gets the full amount after the grace period is finalized
  • No packet commitment left on the rollapp (i.e. ack received). Can be queried using the CLI rollapp-evm q ibc channel packet-commitments transfer \
| ✅ | [TestEIBCFulfillment_ThirdParty_EVM](../tests/eibc_fulfillment_test.go#1006) [TestEIBCFulfillment_ThirdParty_Wasm](../tests/eibc_fulfillment_test.go#1405)| +| 3 | 3rd party token (i.e blumbus) Demand order is created upon memo submission and fulfilled | Same as the case above | ✅ |
  • Eibc demand order created
  • Fulfill the eibc demand order
  • Verify the originator gets the funds minus the fee right away
  • Verify the fulfiller gets the full amount after the grace period is finalized
  • No packet commitment left on the rollapp (i.e. ack received). Can be queried using the CLI rollapp-evm q ibc channel packet-commitments transfer \
| ✅ | [TestEIBCFulfillment_ThirdParty_EVM](../tests/eibc_fulfillment_test.go#1746) [TestEIBCFulfillment_ThirdParty_Wasm](../tests/eibc_fulfillment_test.go#2145)| | 4 | DYM ibc transfer timeout | Same as the case above | ✅ |
  • send **dym** from dymension to rollapp
  • set minimum packet timeout (i.e. 1ms) so that the packet is not relayed before it is picked by a relayer
  • sender should get funds back after grace period.
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
  • demand order is created with correct ibc denom and fee
  • demand order can get fulfilled
  • upon timeout the funds should go to the fulfiller
| | [TestIBCTransferTimeout_EVM](../tests/ibc_timeout_test.go#25) [TestIBCTransferTimeout_Wasm](../tests/ibc_timeout_test.go#256) | | 5 | Rollapp token ibc-transfer timeout | Same as the case above | ✅ |
  • send rollapp IBC denom from dymension to rollapp
  • Same as the case above
| | [TestIBCTransferTimeout_EVM](../tests/ibc_timeout_test.go#25) [TestIBCTransferTimeout_Wasm](../tests/ibc_timeout_test.go#256) | | 6 | 3rd party token Demand order is created upon timeout and fulfilled | Same as the case above | 🛑
(missing) |
  • send 3rd party IBC denom from dymension to rollapp
  • the amount returned should be smaller by a 0.15% fee
  • market maker is able to fulfill it
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
  • upon timeout the funds should go to the fulfiller
| 🛑
(missing) | TO DO | @@ -17,6 +17,6 @@ | 13 | Demand order with fee > amount fails | send eIBC order (rollapp to hub) from CLI with fee > total amount (use memo) | 🛑
(missing) | should return ack error from the hub | 🛑
(missing) | TO DO | | 14 | Demand order with invalid fee fails | send eIBC order (rollapp to hub) from CLI with invalid fee (i.e minus/letters etc) | 🛑
(missing) | should return ack error from the hub | 🛑
(missing) | TO DO | | 15 | Send eIBC order (rollapp to hub) from CLI with invalid fee (i.e minus/letters etc) | | |
  • send IBC order from rollapp to hub without specifying eIBC memo
  • eibc order shouldn’t be created
  • upon finalization period amount should be transferred to original sender
| ✅ | [ibc_transfer_test](../tests/ibc_transfer_test.go) | -| 16 | Demand order for hub to rollapp transfer should be ignored and not created | | |
  • send IBC order from hub to rollapp specifying eIBC memo
  • eibc order shouldn’t be created
| ✅ | [eibc_fulfillment_test](../tests/eibc_fulfillment_test.go#L1449) | -| 17 | Demand order fulfillment from one rollapp, no fulfillment from other rollapp |
  • eIBC order pending on the hub coming from rollapp
  • eIBC order pending on the hub coming from rollapp 2
| 🛑
(missing) |
  • fulfill the order coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TO DO | -| 18 | Demand order fulfillment in 2 different rollapps | Same as the case above | ✅ |
  • fulfill the order coming from rollapp 1
  • fulfill the order coming from rollapp 2
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 2
  • market maker gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestEIBCFulfillment_two_rollapps](../tests/eibc_fulfillment_test.go#625) | +| 16 | Demand order for hub to rollapp transfer should be ignored and not created | | |
  • send IBC order from hub to rollapp specifying eIBC memo
  • eibc order shouldn’t be created
| ✅ | [TestEIBCFulfillment_ignore_hub_to_RA_EVM](../tests/eibc_fulfillment_test.go#L2532) [TestEIBCFulfillment_ignore_hub_to_RA_Wasm](../tests/eibc_fulfillment_test.go#L2784) | +| 17 | Demand order fulfillment from one rollapp, no fulfillment from other rollapp |
  • eIBC order pending on the hub coming from rollapp
  • eIBC order pending on the hub coming from rollapp 2
| ✅ |
  • fulfill the order coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestEIBCFulfillOnOneRollApp_EVM](../tests/eibc_fulfillment_test.go#28) [TestEIBCFulfillOnOneRollApp_Wasm](../tests/eibc_fulfillment_test.go#397) | +| 18 | Demand order fulfillment in 2 different rollapps | Same as the case above | ✅ |
  • fulfill the order coming from rollapp 1
  • fulfill the order coming from rollapp 2
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 2
  • market maker gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestEIBCFulfillment_two_rollapps](../tests/eibc_fulfillment_test.go#1365) | From c6e6ba4840dfc8fd8ac0dcfd983cfbf34415725d Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Mon, 13 May 2024 17:37:00 +0700 Subject: [PATCH 40/61] [eibc] E2E testing for timeout and fulfilled (#130) --- .github/workflows/e2e-test-workflow-call.yml | 2 + .github/workflows/e2e_test.yml | 2 + Makefile | 10 +- tests/eibc_timeout_test.go | 759 ++++++++++++++++++- tests_spec/eibc.md | 2 +- 5 files changed, 767 insertions(+), 8 deletions(-) diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 4be58bac..0b60cd1f 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -36,6 +36,7 @@ jobs: - "e2e-test-eibc-excessive-fee-evm" - "e2e-test-eibc-fulfillment-thirdparty-evm" - "e2e-test-eibc-timeout-evm" + - "e2e-test-eibc-timeout_and_fulfill-evm" - "e2e-test-eibc-not-fulfillment-evm" - "e2e-test-transfer-multi-hop-evm" - "e2e-test-pfm-with-grace-period-evm" @@ -96,6 +97,7 @@ jobs: - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm" - "e2e-test-eibc-fulfillment-thirdparty-wasm" - "e2e-test-eibc-pfm-wasm" + - "e2e-test-eibc-timeout_and_fulfill-wasm" - "e2e-test-eibc-not-fulfillment-wasm" - "e2e-test-transfer-multi-hop-wasm" - "e2e-test-pfm-with-grace-period-wasm" diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index b8dd3f0e..159937bd 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -38,6 +38,7 @@ jobs: - "e2e-test-eibc-fulfillment-thirdparty-evm" - "e2e-test-eibc-pfm-evm" - "e2e-test-eibc-timeout-evm" + - "e2e-test-eibc-timeout_and_fulfill-evm" - "e2e-test-eibc-not-fulfillment-evm" - "e2e-test-transfer-multi-hop-evm" - "e2e-test-pfm-with-grace-period-evm" @@ -84,6 +85,7 @@ jobs: - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm" - "e2e-test-eibc-fulfillment-thirdparty-wasm" - "e2e-test-eibc-pfm-wasm" + - "e2e-test-eibc-timeout_and_fulfill-wasm" - "e2e-test-eibc-not-fulfillment-wasm" - "e2e-test-transfer-multi-hop-wasm" - "e2e-test-pfm-with-grace-period-wasm" diff --git a/Makefile b/Makefile index e938e3c5..b50af33e 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,14 @@ e2e-test-eibc-excessive-fee-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCFeeTooHigh . e2e-test-eibc-timeout-evm: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestEIBCTimeoutHubToRollapp . - + cd tests && go test -timeout=25m -race -v -run TestEIBCTimeoutDymToRollapp . + +e2e-test-eibc-timeout_and_fulfill-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCTimeoutFulFillDymToRollapp_Evm . + +e2e-test-eibc-timeout_and_fulfill-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestEIBCTimeoutFulFillDymToRollapp_Wasm . + e2e-test-transfer-multi-hop-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferMultiHop_EVM . diff --git a/tests/eibc_timeout_test.go b/tests/eibc_timeout_test.go index 5f77cb98..d3f5b21c 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -19,9 +19,9 @@ import ( "go.uber.org/zap/zaptest" ) -// This test case verifies the system's behavior when an eIBC packet is from hub to rollapp and it times out. +// This test case verifies the system's behavior when an eIBC packet is from dym to rollapp and it times out. // It verifies that new demand order is automatically created when that happens -func TestEIBCTimeoutHubToRollapp(t *testing.T) { +func TestEIBCTimeoutDymToRollapp(t *testing.T) { if testing.Short() { t.Skip() } @@ -182,13 +182,12 @@ func TestEIBCTimeoutHubToRollapp(t *testing.T) { Amount: transferAmount, } - // Compose an IBC transfer and send from Hub -> rollapp + // Compose an IBC transfer and send from dym -> rollapp _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, options) require.NoError(t, err) rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) - // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -222,7 +221,7 @@ func TestEIBCTimeoutHubToRollapp(t *testing.T) { } require.True(t, eibcEvent.IsFulfilled) - // wait a few blocks and verify sender received funds on the hub + // wait a few blocks and verify sender received funds on the dymension err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) @@ -260,3 +259,753 @@ func TestEIBCTimeoutHubToRollapp(t *testing.T) { }, ) } + +// TestEIBCTimeoutFulFillDymToRollapp test send 3rd party IBC denom from dymension to rollapp with timeout +// and full filled +func TestEIBCTimeoutFulFillDymToRollapp_Evm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlementLayer := "dymension" + nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1Id := "rollappevm_1-1" + gasPrice := "0adym" + emptyBlocksMaxTimeRollapp1 := "5s" + configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollapp1Id, gasPrice, emptyBlocksMaxTimeRollapp1) + + // setup config for rollapp 2 + rollapp2Id := "rollappevm_2-1" + emptyBlocksMaxTimeRollapp2 := "3s" // make sure rollapp 1 will have finalize height < rollapp 2 + configFileOverrides2 := overridesDymintToml(settlementLayer, nodeAddress, rollapp2Id, gasPrice, emptyBlocksMaxTimeRollapp2) + + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + numVals := 1 + numFullNodes := 0 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappevm_2-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + { + Name: "gaia", + Version: "v14.2.0", + ChainConfig: gaiaConfig, + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + }) + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + gaia := chains[3].(*cosmos.CosmosChain) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + // relayer for rollapp gaia + r3 := test.NewBuiltinRelayerFactory( + ibc.CosmosRly, + zaptest.NewLogger(t), + relayer.CustomDockerImage(IBCRelayerImage, IBCRelayerVersion, "100:1000"), + ).Build(t, client, "relayer3", network) + + const ibcPath = "ibc-path" + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddChain(gaia). + AddRelayer(r, "relayer"). + AddRelayer(r2, "relayer2"). + AddRelayer(r3, "relayer3"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: gaia, + Relayer: r3, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) + + channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym, 3) + + rollAppChan, err := r.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, rollAppChan, 1) + + dymRollAppChan := rollAppChan[0].Counterparty + require.NotEmpty(t, dymRollAppChan.ChannelID) + + rollappDymChan := rollAppChan[0] + require.NotEmpty(t, rollappDymChan.ChannelID) + + gaiaChan, err := r3.GetChannels(ctx, eRep, gaia.GetChainID()) + require.NoError(t, err) + require.Len(t, gaiaChan, 1) + + dymGaiaChan := gaiaChan[0].Counterparty + require.NotEmpty(t, dymGaiaChan.ChannelID) + + gaiaDymChan := gaiaChan[0] + require.NotEmpty(t, gaiaDymChan.ChannelID) + + // Start the relayer and set the cleanup function. + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = r3.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + t.Cleanup( + func() { + err := r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r3.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer2: %s", err) + } + }, + ) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, gaia, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, gaiaUser, marketMakerUser, rollappUser := users[0], users[1], users[2], users[3] + + dymensionUserAddr := dymensionUser.FormattedAddress() + gaianUserAddr := gaiaUser.FormattedAddress() + marketMakerAddr := marketMakerUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, gaia, gaianUserAddr, gaia.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + // global eibc fee in case of auto created orders is 0.0015 + numerator := math.NewInt(15) + denominator := math.NewInt(10000) + globalEIbcFee := transferAmount.Mul(numerator).Quo(denominator) + transferAmountWithoutFee := transferAmount.Sub(globalEIbcFee) + + // Set a short timeout for IBC transfer + options := ibc.TransferOptions{ + Timeout: &ibc.IBCTimeout{ + NanoSeconds: testutil.ImmediatelyTimeout().NanoSeconds, // 1 ms - this will cause the transfer to timeout before it is picked by a relayer + }, + } + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: dymRollAppChan.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + gaiaToDymTransferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: gaia.Config().Denom, + Amount: transferAmount, + } + + gaiaToMMTransferData := ibc.WalletData{ + Address: marketMakerAddr, + Denom: gaia.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from gaiai -> dym and market maker + _, err = gaia.SendIBCTransfer(ctx, gaiaDymChan.ChannelID, gaianUserAddr, gaiaToDymTransferData, ibc.TransferOptions{}) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, gaia, gaianUserAddr, gaia.Config().Denom, walletAmount.Sub(gaiaToDymTransferData.Amount)) + + _, err = gaia.SendIBCTransfer(ctx, gaiaDymChan.ChannelID, gaianUserAddr, gaiaToMMTransferData, ibc.TransferOptions{}) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, gaia, gaianUserAddr, gaia.Config().Denom, walletAmount.Sub(gaiaToDymTransferData.Amount).Sub(gaiaToMMTransferData.Amount)) + + // Get the IBC denom for gaia on dym + gaiaTokenDenom := transfertypes.GetPrefixedDenom(dymGaiaChan.PortID, dymGaiaChan.ChannelID, gaia.Config().Denom) + gaiaIBCDenom := transfertypes.ParseDenomTrace(gaiaTokenDenom).IBCDenom() + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, gaiaIBCDenom, gaiaToDymTransferData.Amount) + + dymToRollAppTransferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: gaiaIBCDenom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from dym -> rollapp + _, err = dymension.SendIBCTransfer(ctx, dymRollAppChan.ChannelID, dymensionUserAddr, dymToRollAppTransferData, options) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // Assert balance was updated on the dym + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, gaiaIBCDenom, zeroBal) + // Get the IBC denom of 3rd party token on roll app + dymensionTokenDenom := transfertypes.GetPrefixedDenom(rollappDymChan.PortID, rollappDymChan.ChannelID, gaiaIBCDenom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) + + // According to delayedack module, we need the rollapp to have finalizedHeight > ibcClientLatestHeight + // in order to trigger ibc timeout or else it will trigger callback + err = testutil.WaitForBlocks(ctx, 1, dymension, rollapp1) + require.NoError(t, err) + + // get eibc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + fmt.Println("Event:", eibcEvents[0]) + require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, gaiaIBCDenom)) + require.Equal(t, eibcEvents[0].Fee, fmt.Sprintf("%s%s", globalEIbcFee, gaiaIBCDenom)) + + // fulfill demand order + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr) + require.NoError(t, err) + fmt.Println(txhash) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + require.True(t, eibcEvent.IsFulfilled) + + // wait a few blocks and verify sender received funds on the dymension + err = testutil.WaitForBlocks(ctx, 3, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err := dymension.GetBalance(ctx, dymensionUserAddr, gaiaIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + expBalance := gaiaToDymTransferData.Amount.Sub(dymToRollAppTransferData.Amount).Add(transferAmountWithoutFee) + require.True(t, balance.Equal(expBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalance, balance)) + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expBalanceMarketMaker := gaiaToMMTransferData.Amount.Sub(transferAmountWithoutFee) + require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) + // wait until packet finalization and verify funds (incl. fee) were added to market maker's wallet address + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + expBalanceMarketMaker = expBalanceMarketMaker.Add(dymToRollAppTransferData.Amount) + require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) + + t.Cleanup( + func() { + err := r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) + // Check the commitment was deleted + resp, err := dymension.GetNode().QueryPacketCommitments(ctx, "transfer", dymRollAppChan.ChannelID) + require.NoError(t, err) + require.Equal(t, len(resp.Commitments) == 0, true, "packet commitments still exist") +} + +func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gasPrice := "0adym" + emptyBlocksMaxTimeRollapp1 := "5s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gasPrice, emptyBlocksMaxTimeRollapp1) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + emptyBlocksMaxTimeRollapp2 := "3s" // make sure rollapp 1 will have finalize height < rollapp 2 + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gasPrice, emptyBlocksMaxTimeRollapp2) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + numVals := 1 + numFullNodes := 0 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + { + Name: "gaia", + Version: "v14.2.0", + ChainConfig: gaiaConfig, + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + gaia := chains[3].(*cosmos.CosmosChain) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + // Relayer for gaia + r3 := test.NewBuiltinRelayerFactory( + ibc.CosmosRly, + zaptest.NewLogger(t), + relayer.CustomDockerImage(IBCRelayerImage, IBCRelayerVersion, "100:1000"), + ).Build(t, client, "relayer3", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddChain(gaia). + AddRelayer(r, "relayer1"). + AddRelayer(r2, "relayer2"). + AddRelayer(r3, "relayer3"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: gaia, + Relayer: r3, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) + + channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym, 3) + + rollAppChan, err := r.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, rollAppChan, 1) + + dymRollAppChan := rollAppChan[0].Counterparty + require.NotEmpty(t, dymRollAppChan.ChannelID) + + rollappDymChan := rollAppChan[0] + require.NotEmpty(t, rollappDymChan.ChannelID) + + gaiaChan, err := r3.GetChannels(ctx, eRep, gaia.GetChainID()) + require.NoError(t, err) + require.Len(t, gaiaChan, 1) + + dymGaiaChan := gaiaChan[0].Counterparty + require.NotEmpty(t, dymGaiaChan.ChannelID) + + gaiaDymChan := gaiaChan[0] + require.NotEmpty(t, gaiaDymChan.ChannelID) + + // Start the relayer and set the cleanup function. + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + err = r3.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + t.Cleanup( + func() { + err := r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r3.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer2: %s", err) + } + }, + ) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, gaia, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, gaiaUser, marketMakerUser, rollappUser := users[0], users[1], users[2], users[3] + + dymensionUserAddr := dymensionUser.FormattedAddress() + gaianUserAddr := gaiaUser.FormattedAddress() + marketMakerAddr := marketMakerUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, gaia, gaianUserAddr, gaia.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + // global eibc fee in case of auto created orders is 0.0015 + numerator := math.NewInt(15) + denominator := math.NewInt(10000) + globalEIbcFee := transferAmount.Mul(numerator).Quo(denominator) + transferAmountWithoutFee := transferAmount.Sub(globalEIbcFee) + + // Set a short timeout for IBC transfer + options := ibc.TransferOptions{ + Timeout: &ibc.IBCTimeout{ + NanoSeconds: testutil.ImmediatelyTimeout().NanoSeconds, // 1 ms - this will cause the transfer to timeout before it is picked by a relayer + }, + } + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: dymRollAppChan.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + gaiaToDymTransferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: gaia.Config().Denom, + Amount: transferAmount, + } + + gaiaToMMTransferData := ibc.WalletData{ + Address: marketMakerAddr, + Denom: gaia.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from gaiai -> dym and market maker + _, err = gaia.SendIBCTransfer(ctx, gaiaDymChan.ChannelID, gaianUserAddr, gaiaToDymTransferData, ibc.TransferOptions{}) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, gaia, gaianUserAddr, gaia.Config().Denom, walletAmount.Sub(gaiaToDymTransferData.Amount)) + + _, err = gaia.SendIBCTransfer(ctx, gaiaDymChan.ChannelID, gaianUserAddr, gaiaToMMTransferData, ibc.TransferOptions{}) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, gaia, gaianUserAddr, gaia.Config().Denom, walletAmount.Sub(gaiaToDymTransferData.Amount).Sub(gaiaToMMTransferData.Amount)) + + // Get the IBC denom for gaia on dym + gaiaTokenDenom := transfertypes.GetPrefixedDenom(dymGaiaChan.PortID, dymGaiaChan.ChannelID, gaia.Config().Denom) + gaiaIBCDenom := transfertypes.ParseDenomTrace(gaiaTokenDenom).IBCDenom() + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, gaiaIBCDenom, gaiaToDymTransferData.Amount) + + dymToRollAppTransferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: gaiaIBCDenom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from dym -> rollapp + _, err = dymension.SendIBCTransfer(ctx, dymRollAppChan.ChannelID, dymensionUserAddr, dymToRollAppTransferData, options) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // Assert balance was updated on the dym + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, gaiaIBCDenom, zeroBal) + // Get the IBC denom of 3rd party token on roll app + dymensionTokenDenom := transfertypes.GetPrefixedDenom(rollappDymChan.PortID, rollappDymChan.ChannelID, gaiaIBCDenom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) + + // According to delayedack module, we need the rollapp to have finalizedHeight > ibcClientLatestHeight + // in order to trigger ibc timeout or else it will trigger callback + err = testutil.WaitForBlocks(ctx, 1, dymension, rollapp1) + require.NoError(t, err) + + // get eibc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + fmt.Println("Event:", eibcEvents[0]) + require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, gaiaIBCDenom)) + require.Equal(t, eibcEvents[0].Fee, fmt.Sprintf("%s%s", globalEIbcFee, gaiaIBCDenom)) + + // fulfill demand order + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr) + require.NoError(t, err) + fmt.Println(txhash) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + require.True(t, eibcEvent.IsFulfilled) + + // wait a few blocks and verify sender received funds on the dymension + err = testutil.WaitForBlocks(ctx, 3, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err := dymension.GetBalance(ctx, dymensionUserAddr, gaiaIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + expBalance := gaiaToDymTransferData.Amount.Sub(dymToRollAppTransferData.Amount).Add(transferAmountWithoutFee) + require.True(t, balance.Equal(expBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalance, balance)) + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expBalanceMarketMaker := gaiaToMMTransferData.Amount.Sub(transferAmountWithoutFee) + require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) + // wait until packet finalization and verify funds (incl. fee) were added to market maker's wallet address + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + expBalanceMarketMaker = expBalanceMarketMaker.Add(dymToRollAppTransferData.Amount) + require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) + + t.Cleanup( + func() { + err := r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) + // Check the commitment was deleted + resp, err := dymension.GetNode().QueryPacketCommitments(ctx, "transfer", dymRollAppChan.ChannelID) + require.NoError(t, err) + require.Equal(t, len(resp.Commitments) == 0, true, "packet commitments still exist") +} diff --git a/tests_spec/eibc.md b/tests_spec/eibc.md index b08dc92e..441a4b76 100644 --- a/tests_spec/eibc.md +++ b/tests_spec/eibc.md @@ -7,7 +7,7 @@ | 3 | 3rd party token (i.e blumbus) Demand order is created upon memo submission and fulfilled | Same as the case above | ✅ |
  • Eibc demand order created
  • Fulfill the eibc demand order
  • Verify the originator gets the funds minus the fee right away
  • Verify the fulfiller gets the full amount after the grace period is finalized
  • No packet commitment left on the rollapp (i.e. ack received). Can be queried using the CLI rollapp-evm q ibc channel packet-commitments transfer \
| ✅ | [TestEIBCFulfillment_ThirdParty_EVM](../tests/eibc_fulfillment_test.go#1746) [TestEIBCFulfillment_ThirdParty_Wasm](../tests/eibc_fulfillment_test.go#2145)| | 4 | DYM ibc transfer timeout | Same as the case above | ✅ |
  • send **dym** from dymension to rollapp
  • set minimum packet timeout (i.e. 1ms) so that the packet is not relayed before it is picked by a relayer
  • sender should get funds back after grace period.
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
  • demand order is created with correct ibc denom and fee
  • demand order can get fulfilled
  • upon timeout the funds should go to the fulfiller
| | [TestIBCTransferTimeout_EVM](../tests/ibc_timeout_test.go#25) [TestIBCTransferTimeout_Wasm](../tests/ibc_timeout_test.go#256) | | 5 | Rollapp token ibc-transfer timeout | Same as the case above | ✅ |
  • send rollapp IBC denom from dymension to rollapp
  • Same as the case above
| | [TestIBCTransferTimeout_EVM](../tests/ibc_timeout_test.go#25) [TestIBCTransferTimeout_Wasm](../tests/ibc_timeout_test.go#256) | -| 6 | 3rd party token Demand order is created upon timeout and fulfilled | Same as the case above | 🛑
(missing) |
  • send 3rd party IBC denom from dymension to rollapp
  • the amount returned should be smaller by a 0.15% fee
  • market maker is able to fulfill it
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
  • upon timeout the funds should go to the fulfiller
| 🛑
(missing) | TO DO | +| 6 | 3rd party token Demand order is created upon timeout and fulfilled | Same as the case above | ✅ |
  • send 3rd party IBC denom from dymension to rollapp
  • the amount returned should be smaller by a 0.15% fee
  • market maker is able to fulfill it
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
  • upon timeout the funds should go to the fulfiller
| ✅ | [TestEIBCTimeoutAndFulFillDymToRollapp](../tests/eibc_timeout_test.go#L266) | | 7 | Demand order is created upon AckError for dym |
  • IBC which exists on the evm-rollapp but doesn’t have erc20
  • At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id.
| 🛑
(missing) |
  • send the DYM token from hub to rollapp
  • fulfiller the order with the IBC denom
  • ack error returned from the rollapp
  • eibc ack error demand order is created with correct denom and correct data
  • eibc managed to get fulfilled
  • upon ack error the funds should go to the fulfiller
| 🛑
(missing) | TO DO | | 8 | Demand order is created upon AckError for 3rd party token | Same as the case above | 🛑
(missing) |
  • send the ibc token from hub to rollapp
  • Same as the case above
| 🛑
(missing) | TO DO | | 9 | Demand order is created upon AckError for rollapp token | Same as the case above | 🛑
(missing) |
  • send the ibc token from hub to rollapp
  • Same as the case above
| 🛑
(missing) | TO DO | From d39e866a0b29c69e6ba78369ab4047b06e4c1f38 Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Wed, 15 May 2024 09:52:50 +0700 Subject: [PATCH 41/61] [Erc20] transfer from hub to rollapp without register (#154) --- .../workflows/e2e-test-evm-workflow-call.yml | 1 + .github/workflows/e2e-test-workflow-call.yml | 1 + .github/workflows/e2e_test.yml | 1 + Makefile | 5 + tests/erc20_ibc_transfer_test.go | 233 ++++++++++++++++++ tests_spec/erc20.md | 2 +- 6 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 tests/erc20_ibc_transfer_test.go diff --git a/.github/workflows/e2e-test-evm-workflow-call.yml b/.github/workflows/e2e-test-evm-workflow-call.yml index 096cfc3e..74fa243b 100644 --- a/.github/workflows/e2e-test-evm-workflow-call.yml +++ b/.github/workflows/e2e-test-evm-workflow-call.yml @@ -45,6 +45,7 @@ jobs: - "e2e-test-eibc-invariant-evm" - "e2e-test-rollapp-invariant-evm" - "e2e-test-rollapp-upgrade-non-state-breaking-evm" + - "e2e-test-erc20-hub-to-rollapp-without-register" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 0b60cd1f..b6595487 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -57,6 +57,7 @@ jobs: - "e2e-test-rollapp-invariant-evm" - "e2e-test-eibc-invariant-evm" - "e2e-test-rollapp-upgrade-non-state-breaking-evm" + - "e2e-test-erc20-hub-to-rollapp-without-register" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index 159937bd..f47577dd 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -59,6 +59,7 @@ jobs: - "e2e-test-rollapp-invariant-evm" - "e2e-test-eibc-invariant-evm" - "e2e-test-rollapp-upgrade-non-state-breaking-evm" + - "e2e-test-erc20-hub-to-rollapp-without-register" fail-fast: false runs-on: ubuntu-latest steps: diff --git a/Makefile b/Makefile index b50af33e..ee553ed0 100644 --- a/Makefile +++ b/Makefile @@ -109,6 +109,9 @@ e2e-test-eibc-not-fulfillment-evm: clean-e2e e2e-test-pfm-gaia-to-rollapp-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferGaiaToRollApp_EVM . + +e2e-test-erc20-hub-to-rollapp-without-register: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestERC20HubToRollAppWithoutRegister_EVM . e2e-test-rollapp-upgrade-non-state-breaking-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollappUpgradeNonStateBreaking_EVM . @@ -220,6 +223,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-sequencer-invariant-evm \ e2e-test-rollapp-invariant-evm \ e2e-test-rollapp-upgrade-non-state-breaking-evm \ + e2e-test-erc20-hub-to-rollapp-without-register \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ e2e-test-ibc-grace-period-wasm \ @@ -269,6 +273,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-sequencer-invariant-evm \ e2e-test-rollapp-invariant-evm \ e2e-test-rollapp-upgrade-non-state-breaking-evm \ + e2e-test-erc20-hub-to-rollapp-without-register \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ e2e-test-ibc-grace-period-wasm \ diff --git a/tests/erc20_ibc_transfer_test.go b/tests/erc20_ibc_transfer_test.go new file mode 100644 index 00000000..457e8cd4 --- /dev/null +++ b/tests/erc20_ibc_transfer_test.go @@ -0,0 +1,233 @@ +package tests + +import ( + "context" + "fmt" + "testing" + + transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" + test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp, emptyBlocksMaxTime) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + // Enable erc20 + modifyRollappGeneisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.erc20.params.enable_erc20", + Value: true, + }, + ) + modifyGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + ) + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(modifyRollappGeneisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r1, "relayer1"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + channel, err := ibc.GetTransferChannel(ctx, r1, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + // Start relayer + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + // Get the IBC denom of Hub on rollapp + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + balance, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(walletAmount.Sub(transferAmount)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds weren't added to receiver's address + balance, err = rollapp1.GetBalance(ctx, rollappUserAddr, dymensionIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of rollappUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + fmt.Println("Event:", eibcEvents[0]) + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + resp, err := dymension.QueryEIBCDemandOrders(ctx, "PENDING") + require.NoError(t, err) + require.Equal(t, 1, len(resp.DemandOrders)) + + // wait until packet finalization and verify funds + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = rollapp1.GetBalance(ctx, rollappUserAddr, dymensionIBCDenom) + require.NoError(t, err) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferData.Amount, balance)) + + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.True(t, balance.Equal(walletAmount), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferData.Amount, balance)) + + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} diff --git a/tests_spec/erc20.md b/tests_spec/erc20.md index 1b8f5b58..d8ed464b 100644 --- a/tests_spec/erc20.md +++ b/tests_spec/erc20.md @@ -2,6 +2,6 @@ | No | Scenario | Pre-condition | Pre-condition check | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-----------------|-----------------------|------------| -| 1 | Transfer IBC tokens from hub to rollapp before ERC20 registered |
  • evm rollapp running
  • no ERC20 for this token
| 🛑
(missing) |
  • transfer ibc token to the address on the rollapp
  • error can’t transfer funds
  • an eIBC demand order is created
  • if eibc not fulfilled, upon finalization the funds are returned to the user
| 🛑
(missing) | TODO | +| 1 | Transfer IBC tokens from hub to rollapp before ERC20 registered |
  • evm rollapp running
  • no ERC20 for this token
| ✅ |
  • transfer ibc token to the address on the rollapp
  • error can’t transfer funds
  • an eIBC demand order is created
  • if eibc not fulfilled, upon finalization the funds are returned to the user
| ✅ | [TestERC20HubToRollAppWithoutRegister](../tests/erc20_ibc_transfer_test.go#L21) | | 2 | Transfer IBC tokens from hub to rollapp after ERC20 registered |
  • evm rollapp is running
  • a permissioned tx with with denom-metadata is created for this IBC token
| 🛑
(missing) |
  • transfer ibc token to the metamask address on the rollapp
  • validate balance is displayed as expected
| 🛑
(blocking: no way to query erc20 balance via cli) | TODO | | 3 | Transfer IBC rollapp tokens from rollapp-evm back to the hub | Same as the case above | 🛑
(missing) |
  • convert tokens from erc20 to bank denom (cli command)
  • send them back to the hub
  • validate that the amount recieved in the hub is as expected
| 🛑
(blocking: no way to query erc20 balance via cli) | TODO | From 35892670531d30e2638ae6ab1d45467d91a42a9c Mon Sep 17 00:00:00 2001 From: nguyen | decentrio <144610611+trinitys7@users.noreply.github.com> Date: Wed, 15 May 2024 12:01:22 +0700 Subject: [PATCH 42/61] docs: add missing specs in readme (#172) --- tests_spec/delayedack.md | 6 +++--- tests_spec/eibc.md | 8 ++++---- tests_spec/hub_invariants.md | 6 +++--- tests_spec/pfm.md | 8 ++++---- tests_spec/rollapp_genesis.md | 6 +++--- tests_spec/rollapp_hardfork.md | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests_spec/delayedack.md b/tests_spec/delayedack.md index a4e18f1f..bae57a57 100644 --- a/tests_spec/delayedack.md +++ b/tests_spec/delayedack.md @@ -4,6 +4,6 @@ | No | Scenario | Pre-condition | Pre-condition check | Steps | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-------|-----------------|-----------------------|------------| -| 1 | IBC transfer from rollapp to hub succeeds when rollapp has NO FINALIZED STATES AT ALL | At least 2 rollapps running, Rollapp A and B. Rollapp B (our rollapp) has no finalized state. Rollapp B has height > Rollapp A height. Rollapp B has a channel-id different from the hub-channel-id and **no finalized state**| ✅ || RollappPacket successfully created on the hub with pending status (can be checked by `dymd q delayedack packets-by-status pending`) | ✅ | [TestDelayedAck_NoFinalizedStates_EVM](../tests/ibc_grace_period_test.go#577) [TestDelayedAck_NoFinalizedStates_Wasm](../tests/ibc_grace_period_test.go#832)| -| 2 | Rollapp token transfer should only be received on the hub upon rollapp finalized state (assume no eIBC packet, i.e no memo) | At least 2 rollapps running, Rollapp A and B. Rollapp B (our rollapp) is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id. | ✅ || Rollapp tokens received on hub only after Rollapp B reaches finalized state. | ✅ | [TestIBCGracePeriodCompliance_EVM](../tests/ibc_grace_period_test.go#24) [TestIBCGracePeriodCompliance_Wasm](../tests/ibc_grace_period_test.go#301)| -| 3 | DYM token transfer from hub to rollapp while relayer is down | - At least 2 rollapps running, Rollapp A and B - Rollapp B (our rollapp) is at finalized height < Rollapp A finalized height - Rollapp B (our rollapp) has a channel-id different than the hub-channel-id (i.e not both are channel-0)| ✅ | - Validate relayer is down - Send rollapp tokens from rollapp to hub - Restart the relayer | Transfer should be picked up and recieved in the rollapp | ✅ | [TestDelayedAck_RelayerDown_EVM](../tests/ibc_grace_period_test.go#1087) [TestDelayedAck_RelayerDown_Wasm](../tests/ibc_grace_period_test.go#1357)| +| 1 | IBC transfer from rollapp to hub succeeds when rollapp has NO FINALIZED STATES AT ALL | At least 2 rollapps running, Rollapp A and B. Rollapp B (our rollapp) has no finalized state. Rollapp B has height > Rollapp A height. Rollapp B has a channel-id different from the hub-channel-id and **no finalized state**| ✅ || RollappPacket successfully created on the hub with pending status (can be checked by `dymd q delayedack packets-by-status pending`) | ✅ | [TestDelayedAck_NoFinalizedStates_EVM](../tests/ibc_grace_period_test.go#L577) [TestDelayedAck_NoFinalizedStates_Wasm](../tests/ibc_grace_period_test.go#L832)| +| 2 | Rollapp token transfer should only be received on the hub upon rollapp finalized state (assume no eIBC packet, i.e no memo) | At least 2 rollapps running, Rollapp A and B. Rollapp B (our rollapp) is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id. | ✅ || Rollapp tokens received on hub only after Rollapp B reaches finalized state. | ✅ | [TestIBCGracePeriodCompliance_EVM](../tests/ibc_grace_period_test.go#L24) [TestIBCGracePeriodCompliance_Wasm](../tests/ibc_grace_period_test.go#L301)| +| 3 | DYM token transfer from hub to rollapp while relayer is down | - At least 2 rollapps running, Rollapp A and B - Rollapp B (our rollapp) is at finalized height < Rollapp A finalized height - Rollapp B (our rollapp) has a channel-id different than the hub-channel-id (i.e not both are channel-0)| ✅ | - Validate relayer is down - Send rollapp tokens from rollapp to hub - Restart the relayer | Transfer should be picked up and recieved in the rollapp | ✅ | [TestDelayedAck_RelayerDown_EVM](../tests/ibc_grace_period_test.go#L1087) [TestDelayedAck_RelayerDown_Wasm](../tests/ibc_grace_period_test.go#L1357)| diff --git a/tests_spec/eibc.md b/tests_spec/eibc.md index 441a4b76..a964c06f 100644 --- a/tests_spec/eibc.md +++ b/tests_spec/eibc.md @@ -2,7 +2,7 @@ | No | Scenario | Pre-condition | Pre-condition check | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-----------------|-----------------------|------------| -| 1 | Rollapp token Demand order is created upon memo submission and fulfilled |At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id. | ✅ | Demand order for Rollapp tokens created and fulfilled upon memo submission. | ✅ | [TestEIBCFulfillment_EVM](../tests/eibc_fulfillment_test.go#768) [TestEIBCFulfillment_Wasm](../tests/eibc_fulfillment_test.go#1062) | +| 1 | Rollapp token Demand order is created upon memo submission and fulfilled |At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id. | ✅ | Demand order for Rollapp tokens created and fulfilled upon memo submission. | ✅ | [TestEIBCFulfillment_EVM](../tests/eibc_fulfillment_test.go#L768) [TestEIBCFulfillment_Wasm](../tests/eibc_fulfillment_test.go#L1062) | | 2 | DYM Demand order is created upon memo submission and fulfilled | Same as the case above | ✅ | Timeout triggered for EIBC transaction from hub to rollapp due to non-finalization. | ✅ | [TestEIBCTimeoutHubToRollapp](../tests/eibc_timeout_test.go#24) | | 3 | 3rd party token (i.e blumbus) Demand order is created upon memo submission and fulfilled | Same as the case above | ✅ |
  • Eibc demand order created
  • Fulfill the eibc demand order
  • Verify the originator gets the funds minus the fee right away
  • Verify the fulfiller gets the full amount after the grace period is finalized
  • No packet commitment left on the rollapp (i.e. ack received). Can be queried using the CLI rollapp-evm q ibc channel packet-commitments transfer \
| ✅ | [TestEIBCFulfillment_ThirdParty_EVM](../tests/eibc_fulfillment_test.go#1746) [TestEIBCFulfillment_ThirdParty_Wasm](../tests/eibc_fulfillment_test.go#2145)| | 4 | DYM ibc transfer timeout | Same as the case above | ✅ |
  • send **dym** from dymension to rollapp
  • set minimum packet timeout (i.e. 1ms) so that the packet is not relayed before it is picked by a relayer
  • sender should get funds back after grace period.
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
  • demand order is created with correct ibc denom and fee
  • demand order can get fulfilled
  • upon timeout the funds should go to the fulfiller
| | [TestIBCTransferTimeout_EVM](../tests/ibc_timeout_test.go#25) [TestIBCTransferTimeout_Wasm](../tests/ibc_timeout_test.go#256) | @@ -11,11 +11,11 @@ | 7 | Demand order is created upon AckError for dym |
  • IBC which exists on the evm-rollapp but doesn’t have erc20
  • At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id.
| 🛑
(missing) |
  • send the DYM token from hub to rollapp
  • fulfiller the order with the IBC denom
  • ack error returned from the rollapp
  • eibc ack error demand order is created with correct denom and correct data
  • eibc managed to get fulfilled
  • upon ack error the funds should go to the fulfiller
| 🛑
(missing) | TO DO | | 8 | Demand order is created upon AckError for 3rd party token | Same as the case above | 🛑
(missing) |
  • send the ibc token from hub to rollapp
  • Same as the case above
| 🛑
(missing) | TO DO | | 9 | Demand order is created upon AckError for rollapp token | Same as the case above | 🛑
(missing) |
  • send the ibc token from hub to rollapp
  • Same as the case above
| 🛑
(missing) | TO DO | -| 10 | eibc shouldn’t work together with PFM | At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id.| 🛑
(missing)| Try to send RAX from rollapp to Dymension:
  • with both eibc and forward objects in memo.
  • Forward object could specify an address
The transfer should not be successful and RAX should be returned to rollapp’s wallet| 🛑
(missing) | TO DO | +| 10 | eibc shouldn’t work together with PFM | At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id.| ✅| Try to send RAX from rollapp to Dymension:
  • with both eibc and forward objects in memo.
  • Forward object could specify an address
The transfer should not be successful and RAX should be returned to rollapp’s wallet| ✅ | [TestEIBCPFM_EVM](../tests/eibc_pfm_test.go#26) [TestEIBCPFM_Wasm](../tests/eibc_pfm_test.go#303) | | 11 | Demand order fulfillment | eIBC pending order on the hub | ✅ |
  • fulfill the eIBC order
  • IBC Amount goes to the fulfiller upon finalization
  • Amount - Fee goes to the user
| ✅ | [TestEIBCFulfillment_EVM](../tests/ibc_grace_period_test.go#28) [TestEIBCFulfillment_Wasm](../tests/eibc_fulfillment_test.go#322) | | 12 | Demand order not fulfillment | eIBC pending order on the hub | ✅ |
  • don’t fulfill the eIBC demand order
  • user gets the entire amount upon grace period
| ✅ | [TestEIBCNotFulfillment_EVM](../tests/eibc_not_fulfillment_test.go#L25) [TestEIBCNotFulfillment_Wasm](../tests/eibc_not_fulfillment_test.go#L285) | -| 13 | Demand order with fee > amount fails | send eIBC order (rollapp to hub) from CLI with fee > total amount (use memo) | 🛑
(missing) | should return ack error from the hub | 🛑
(missing) | TO DO | -| 14 | Demand order with invalid fee fails | send eIBC order (rollapp to hub) from CLI with invalid fee (i.e minus/letters etc) | 🛑
(missing) | should return ack error from the hub | 🛑
(missing) | TO DO | +| 13 | Demand order with fee > amount fails | send eIBC order (rollapp to hub) from CLI with fee > total amount (use memo) | ✅ | should return ack error from the hub | ✅ |[TestEIBCCorruptedMemoNegative](../tests/eibc_corrupted_memo_test.go#L25) | +| 14 | Demand order with invalid fee fails | send eIBC order (rollapp to hub) from CLI with invalid fee (i.e minus/letters etc) | ✅ | should return ack error from the hub | ✅ | [TestEIBCCorruptedMemoNegative](../tests/eibc_corrupted_memo_test.go#L25) | | 15 | Send eIBC order (rollapp to hub) from CLI with invalid fee (i.e minus/letters etc) | | |
  • send IBC order from rollapp to hub without specifying eIBC memo
  • eibc order shouldn’t be created
  • upon finalization period amount should be transferred to original sender
| ✅ | [ibc_transfer_test](../tests/ibc_transfer_test.go) | | 16 | Demand order for hub to rollapp transfer should be ignored and not created | | |
  • send IBC order from hub to rollapp specifying eIBC memo
  • eibc order shouldn’t be created
| ✅ | [TestEIBCFulfillment_ignore_hub_to_RA_EVM](../tests/eibc_fulfillment_test.go#L2532) [TestEIBCFulfillment_ignore_hub_to_RA_Wasm](../tests/eibc_fulfillment_test.go#L2784) | | 17 | Demand order fulfillment from one rollapp, no fulfillment from other rollapp |
  • eIBC order pending on the hub coming from rollapp
  • eIBC order pending on the hub coming from rollapp 2
| ✅ |
  • fulfill the order coming from rollapp 1
  • user gets amount minus fee for demand order coming from rollapp 1
  • market maker gets amount upon grace period of IBC packet coming from rollapp 1
  • user gets amount upon grace period of IBC packet coming from rollapp 2
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestEIBCFulfillOnOneRollApp_EVM](../tests/eibc_fulfillment_test.go#28) [TestEIBCFulfillOnOneRollApp_Wasm](../tests/eibc_fulfillment_test.go#397) | diff --git a/tests_spec/hub_invariants.md b/tests_spec/hub_invariants.md index ebf7b525..c4666a10 100644 --- a/tests_spec/hub_invariants.md +++ b/tests_spec/hub_invariants.md @@ -2,6 +2,6 @@ | No | Scenario | Pre-condition | Pre-condition check | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-----------------|-----------------------|------------| -| 1 | eibc invariants |
  • At least x amount of eIBC are finalized
  • at least x amount of eIBC are pending
  • at least one epoch has passed since first eIBC message (for rollapp packet deletion. Epoch by default in that case is 1hr)
| 🛑
(missing) | run crisis for the eibc module and pass successfully | 🛑
(missing) | TODO | -| 2 | rollapp invariants |
  • At least 2 rollapps are registered
  • at least 1 is an evm rollapp
  • at least 2 grace periods has passed
  • a few states are in pending mode currently
| 🛑
(missing) | run crisis for the rollapp invariant and pass successfully | 🛑
(missing) | TODO | -| 3 | sequencer invariants |
  • multiple sequencers registered per rollapp
  • a few bonded, one unbonding and one bonded
| 🛑
(missing) | run crisis for the sequencer invariant and pass successfully | 🛑
(missing) | TODO | +| 1 | eibc invariants |
  • At least x amount of eIBC are finalized
  • at least x amount of eIBC are pending
  • at least one epoch has passed since first eIBC message (for rollapp packet deletion. Epoch by default in that case is 1hr)
| ✅ | run crisis for the eibc module and pass successfully | ✅ | [TestEIBCInvariant_EVM](../tests/eibc_invariant_test.go#L23) [TestEIBCInvariant_Wasm](../tests/eibc_invariant_test.go#L369)| +| 2 | rollapp invariants |
  • At least 2 rollapps are registered
  • at least 1 is an evm rollapp
  • at least 2 grace periods has passed
  • a few states are in pending mode currently
| ✅ | run crisis for the rollapp invariant and pass successfully | ✅ | [TestRollappInvariant_EVM](../tests/rollapp_invariant_test.go#L20) [TestEIBCInvariant_Wasm](../tests/rollapp_invariant_test.go#L281) | +| 3 | sequencer invariants |
  • multiple sequencers registered per rollapp
  • a few bonded, one unbonding and one bonded
| ✅ | run crisis for the sequencer invariant and pass successfully | ✅ | [TestSequencerInvariant_EVM](../tests/sequencer_invariant_test.go#L20) [TestSequencerInvariant_Wasm](../tests/sequencer_invariant_test.go#L284)| diff --git a/tests_spec/pfm.md b/tests_spec/pfm.md index 1a600dd6..2325acf0 100644 --- a/tests_spec/pfm.md +++ b/tests_spec/pfm.md @@ -2,9 +2,9 @@ | No | Scenario | Pre-condition | Pre-condition check | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-----------------|-----------------------|------------| -| 1 | Rollapp to 3rd party chain | | |
  • Try to send RAX from rollapp to an external chain, eibc should be switched off
  • RAX should be available on a 3rd party chain after rollapp grace period is reached
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TODO | -| 2 | 3rd party chain to Rollapp | | |
  • transfer from 3rd party chain to rollapp
  • funds should be available on rollapp almost immediately
| 🛑
(missing) | TODO | -| 3 | Rollapp to 3rd party chain with eIBC | | |
  • send PFM + eIBC memo should fail with ackError on hub
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| 🛑
(missing) | TODO | +| 1 | Rollapp to 3rd party chain | | |
  • Try to send RAX from rollapp to an external chain, eibc should be switched off
  • RAX should be available on a 3rd party chain after rollapp grace period is reached
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestIBCPFMWithGracePeriod_EVM](../tests/ibc_pfm_with_grace_period_test.go#L24) [TestIBCPFMWithGracePeriod_Wasm](../tests/ibc_pfm_with_grace_period_test.go#L315) | +| 2 | 3rd party chain to Rollapp | | |
  • transfer from 3rd party chain to rollapp
  • funds should be available on rollapp almost immediately
| ✅ | [TestIBCTransferGaiaToRollApp_EVM](../tests/ibc_pfm_test.go#L520) [TestIBCTransferGaiaToRollApp_Wasm](../tests/ibc_pfm_test.go#L7756)| +| 3 | Rollapp to 3rd party chain with eIBC | | |
  • send PFM + eIBC memo should fail with ackError on hub
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestEIBCPFM_EVM](../tests/eibc_pfm_test.go#26) [TestEIBCPFM_Wasm](../tests/eibc_pfm_test.go#303) | | 4 | Rollapp to Rollapp - ERC20 registered | erc20 registered on rollapp2 for rollapp 1 IBC | ✅ |
  • send from rollapp 1 to rollapp 2 using PFM
  • rollapp token 1 should be available on the rollapp 2 after rollapp1 grace period is reached
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestIBCPFM_RollApp1ToRollApp2WithErc20](../tests/ibc_pfm_with_grace_period_test.go#L710)| | 5 | Rollapp to Rollapp - ERC20 not registered | erc20 NOT registered on rollapp2 for rollapp 1 IBC | ✅ |
  • send from rollapp 1 to rollapp 2 using PFM should fail
  • rollapp token 1 should return to rollapp1 after (rollapp1 grace period + rollapp2 grace period) is reached.
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
| ✅ | [TestIBCPFM_RollApp1ToRollApp2WithOutErc20](../tests/ibc_pfm_with_grace_period_test.go#L948) | -| 6 | Rollapp to Rollapp + eIBC | | | send from rollapp 1 to rollapp 2 using PFM + eIBC should fail | 🛑
(missing) | TODO | +| 6 | Rollapp to Rollapp + eIBC | | | send from rollapp 1 to rollapp 2 using PFM + eIBC should fail | ✅ | [TestEIBCPFM_EVM](../tests/eibc_pfm_test.go#26) [TestEIBCPFM_Wasm](../tests/eibc_pfm_test.go#303) | diff --git a/tests_spec/rollapp_genesis.md b/tests_spec/rollapp_genesis.md index 8e27c395..6c3a441f 100644 --- a/tests_spec/rollapp_genesis.md +++ b/tests_spec/rollapp_genesis.md @@ -3,10 +3,10 @@ | No | Scenario | Pre-condition | Pre-condition check | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-----------------|-----------------------|------------| | 1 | Rollapp genesis tokens on the hub upon channel creation |
  • Create relevant genesis accounts and metadata info
  • Upon channel creation, trigger genesis events in both rollapp and hub (special tx)
| ✅ |
  • denometadata should be created
  • VFC should be created on hub (i.e erc20)
  • Rollapp tokens with relevant amount should be locked on the rollapp
  • genesis accounts should have the relevant balance on the hub
| ✅ | [TestRollappGenesisEvent_EVM](../tests/rollapp_genesis_event_test.go#24) | -| 2 | Transfer rollapp genesis tokens on the hub | |🛑
(missing) |
  • should be able to transfer the tokens to a different address on the hub
  • should be able to import the erc20 rep and transfer it on the rollapp
| 🛑
(missing) | TODO | +| 2 | Transfer rollapp genesis tokens on the hub | | |
  • should be able to transfer the tokens to a different address on the hub
  • should be able to import the erc20 rep and transfer it on the rollapp
| ✅ | every eibc test | | 3 | Transfer rollapp tokens between hub ↔ rollapp BEFORE rollapp has any finalized state on the hub (and both events were triggered) |
  • Rollapp shouldn’t have any finalized state on the hub
  • Rollapp and hub genesis event were triggered
|🛑
(missing) |
  • transfer from hub to rollapp should work as expected
  • transfer from rollapp to hub should work as expected
  • transferring all the genesis tokens from hub to rollapp should work as expected
| 🛑
(missing) | TODO | -| 4 | Transfer rollapp tokens between hub ↔ rollapp AFTER rollapp has any finalized state on the hub |
  • Rollapp should have any finalized state on the hub
  • Rollapp and hub genesis event were triggered
|🛑
(missing) |
  • transfer from hub to rollapp should work as expected
  • transfer from rollapp to hub should work as expected
  • transferring all the genesis tokens from hub to rollapp should work as expected
| 🛑
(missing) | TODO | +| 4 | Transfer rollapp tokens between hub ↔ rollapp AFTER rollapp has any finalized state on the hub |
  • Rollapp should have any finalized state on the hub
  • Rollapp and hub genesis event were triggered
|✅ |
  • transfer from hub to rollapp should work as expected
  • transfer from rollapp to hub should work as expected
  • transferring all the genesis tokens from hub to rollapp should work as expected
| ✅ | every ibc test | | 5 | Transfer from hub to rollapp after only hub side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event on the hub
  • try transferring tokens from hub to rollapp
  • ERC20 was registered on the rollapp for the hub
|🛑
(missing) |
  • Should fail as no tokens are locked in the escrow address on the rollapp side
| 🛑
(missing) | TODO | | 6 | Transfer from rollapp to hub after only hub side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event on the hub
  • try transferring tokens from rollapp to hub
|🛑
(missing) |
  • Should succeed
| 🛑
(missing) | TODO | -| 7 | Transfer from rollapp to hub after only rollapp side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event only on the rollapp
  • Try transferring from rollapp to hub
|🛑
(missing) |
  • Should fail as no tokens are locked in the escrow address on the rollapp side
|🛑
(missing) |
  • Should fail with ack error on validation
| 🛑
(missing) | TODO | +| 7 | Transfer from rollapp to hub after only rollapp side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event only on the rollapp
  • Try transferring from rollapp to hub
|🛑
(missing) |
  • Should fail as no tokens are locked in the escrow address on the rollapp side
  • Should fail with ack error on validation
| 🛑
(missing) | [TODO] | | 8 | Transfer from hub to rollapp from rollapp-genesis-account on the hub after only rollapp side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event only on the rollapp
  • Try transferring from hub to rollapp
|🛑
(missing) |
  • Should fail as there are no balances for those addresses on the hub
| 🛑
(missing) | TODO | \ No newline at end of file diff --git a/tests_spec/rollapp_hardfork.md b/tests_spec/rollapp_hardfork.md index 09b8dead..892f3e36 100644 --- a/tests_spec/rollapp_hardfork.md +++ b/tests_spec/rollapp_hardfork.md @@ -2,12 +2,12 @@ | No | Scenario | Pre-condition | Pre-condition check | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-----------------|-----------------------|------------| -| 1 | "Rollapp freeze - ability to freeze rollapp by submitting fraud proposal" |
  • Rollapp registered with a sequencer
  • rollapp has IBC connection to hub
  • previous ibc transfers were successful
  • some eIBC packets are in the pending queue
  • Rollapp have max sequencers = 1
| 🛑
(missing) |
  • Fraud proposal submitted for a specific height
  • proposal voted and passed
| 🛑
(missing) | TODO | -| 2 | "Rollapp freeze - can’t send IBC transfers" |
  • Rollapp registered with a sequencer
  • rollapp has IBC connection to hub
  • previous ibc transfers were successful
  • some eIBC packets are in the pending queue
  • Rollapp have max sequencers = 1
| 🛑
(missing) |
  • Send freeze gov proposal to rollapp.
  • Send ibc-transfer from rollapp to hub and vice versa
|
  • No ability to send ibc transfers from rollapp ↔ hub and vice versa
| 🛑
(missing) | +| 1 | "Rollapp freeze - ability to freeze rollapp by submitting fraud proposal" |
  • Rollapp registered with a sequencer
  • rollapp has IBC connection to hub
  • previous ibc transfers were successful
  • some eIBC packets are in the pending queue
  • Rollapp have max sequencers = 1
| ✅ |
  • Fraud proposal submitted for a specific height
  • proposal voted and passed
| ✅ | [TestRollAppFreeze_EVM](../tests/frozen_test.go#L35) [TestRollAppFreeze_Wasm](../tests/frozen_test.go#L352) | +| 2 | "Rollapp freeze - can’t send IBC transfers" |
  • Rollapp registered with a sequencer
  • rollapp has IBC connection to hub
  • previous ibc transfers were successful
  • some eIBC packets are in the pending queue
  • Rollapp have max sequencers = 1
| ✅ |
  • Send freeze gov proposal to rollapp.
  • Send ibc-transfer from rollapp to hub and vice versa
  • No ability to send ibc transfers from rollapp ↔ hub and vice versa
| ✅ | [TestRollAppFreeze_EVM](../tests/frozen_test.go#L35) [TestRollAppFreeze_Wasm](../tests/frozen_test.go#L352) | | 3 | "Rollapp freeze - can't fulfill pending eIBC packets" |
  • Rollapp registered with a sequencer
  • rollapp has IBC connection to hub
  • previous ibc transfers were successful
  • some eIBC packets are in the pending queue
  • Rollapp have max sequencers = 1
| 🛑
(missing) |
  • Send freeze gov proposal to rollapp
  • Send ibc-transfer from rollapp to hub including memo
|
  • eIBC transfers are discarded and failed
  • ibc demand order reverted
  • inability to fulfill eIBC transfer
| 🛑
(missing) | | 4 | "Rollapp freeze - state is not progressing" |
  • Rollapp registered with a sequencer
  • rollapp has IBC connection to hub
  • previous ibc transfers were successful
  • some eIBC packets are in the pending queue
  • Rollapp have max sequencers = 1
| 🛑
(missing) |
  • Send freeze gov proposal to rollapp
  • Rollapp state is not progressing
| 🛑
(missing) | TODO | | 5 | "Rollapp freeze - Sequencer slashed and jailed" |
  • Rollapp registered with a sequencer
  • rollapp has IBC connection to hub
  • previous ibc transfers were successful
  • some eIBC packets are in the pending queue
  • Rollapp have max sequencers = 1
| 🛑
(missing) |
  • Send freeze gov proposal to rollapp
  • Sequencer should be slashed with all the bond and jailed
  • Inability to register a new sequencer
| 🛑
(missing) | TODO | -| 6 | "Rollapp freeze - other rollapps are functioning as usual" |
  • Rollapp registered with a sequencer
  • rollapp has IBC connection to hub
  • previous ibc transfers were successful
  • some eIBC packets are in the pending queue
  • Rollapp have max sequencers = 1
  • rollapp2 has eIBC pending packets
| 🛑
(missing) |
  • Send freeze gov proposal to rollapp
  • rollapp2 eibc packets are finalized as expected
  • rollapp2 eibc packets can be fulfilled
  • rollapp2 ibc transfers are being transferred as expected
  • rollapp2 state is progressing as expected
| 🛑
(missing) | TODO | +| 6 | "Rollapp freeze - other rollapps are functioning as usual" |
  • Rollapp registered with a sequencer
  • rollapp has IBC connection to hub
  • previous ibc transfers were successful
  • some eIBC packets are in the pending queue
  • Rollapp have max sequencers = 1
  • rollapp2 has eIBC pending packets
| ✅ |
  • Send freeze gov proposal to rollapp
  • rollapp2 eibc packets are finalized as expected
  • rollapp2 eibc packets can be fulfilled
  • rollapp2 ibc transfers are being transferred as expected
  • rollapp2 state is progressing as expected
| ✅ | [TestOtherRollappNotAffected_EVM](../tests/frozen_test.go#L695) [TestOtherRollappNotAffected_Wasm](../tests/frozen_test.go#L1104) | | 7 | "Rollapp freeze - invariants are not broken" |
  • Rollapp registered with a sequencer
  • rollapp has IBC connection to hub
  • previous ibc transfers were successful
  • some eIBC packets are in the pending queue
  • Rollapp have max sequencers = 1
  • rollapp2 has eIBC pending packets
| 🛑
(missing) |
  • Send freeze gov proposal to rollapp
  • invariant broken for block-height-to-finalization-queue since it is unable to find finalization queues for reverted state infos
  • it should skip checking frozen rollapps (PR submitted)
| 🛑
(missing) | TODO | | 8 | "Rollapp freeze - pending acked ibc packet are rollbacked" |
  • Rollapp registered with a sequencer
  • rollapp has IBC connection to hub
  • previous ibc transfers were successful
  • some eIBC packets are in the pending queue
  • Rollapp have max sequencers = 1
  • Rollapp has eIBC pending packets
| 🛑
(missing) |
  • IBC transfer sent from hub to rollapp
  • Send freeze gov proposal to rollapp
  • Rollapp is frozen before ibc-transfer finalization
  • timeout is triggered in delayedack once the rollapp is frozen and funds are sent back to sender
| 🛑
(missing) | TODO | | 9 | "Rollapp freeze - pending on recv ibc packet are rollbacked" |
  • Rollapp registered with a sequencer
  • rollapp has IBC connection to hub
  • previous ibc transfers were successful
  • some eIBC packets are in the pending queue
  • Rollapp have max sequencers = 1
  • Rollapp has eIBC pending packets
| 🛑
(missing) |
  • IBC transfer sent from rollapp to hub
  • Send freeze gov proposal to rollapp
  • Rollapp is frozen before ibc-transfer finalization
  • timeout is triggered in delayedack once the rollapp is frozen and no transfer is made after finalization
| 🛑
(missing) | TODO | From 6ca12e6355bebd579c46aafab3f04b278e1e501b Mon Sep 17 00:00:00 2001 From: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Date: Wed, 15 May 2024 13:37:13 +0700 Subject: [PATCH 43/61] feat!: get all the test cases and add them to the CI matrix (#152) --- .../workflows/e2e-test-evm-workflow-call.yml | 71 ++++--- .../e2e-test-wasm-workflow-call.yaml | 62 +++--- .github/workflows/e2e-test-workflow-call.yml | 180 +++++++++--------- .github/workflows/e2e_test.yml | 134 ++++++------- Makefile | 17 +- build_tests_matrix/main.go | 166 ++++++++++++++++ run-e2e.sh | 10 + tests/eibc_corrupted_memo_test.go | 2 +- tests/eibc_fee_test.go | 2 +- tests/eibc_fulfillment_test.go | 2 +- tests/eibc_nobalance_test.go | 2 +- tests/eibc_timeout_test.go | 5 +- tests/ibc_pfm_with_grace_period_test.go | 4 +- 13 files changed, 405 insertions(+), 252 deletions(-) create mode 100644 build_tests_matrix/main.go create mode 100755 run-e2e.sh diff --git a/.github/workflows/e2e-test-evm-workflow-call.yml b/.github/workflows/e2e-test-evm-workflow-call.yml index 74fa243b..17541a7c 100644 --- a/.github/workflows/e2e-test-evm-workflow-call.yml +++ b/.github/workflows/e2e-test-evm-workflow-call.yml @@ -6,47 +6,45 @@ on: required: false type: string default: "latest" + test: + description: 'test name to run as standalone' + required: false + type: string + default: '' + test-exclusions: + description: 'Comma separated list of tests to skip' + required: false + type: string + default: '' # empty string means don't skip any test. jobs: + build-evm-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + with: + repository: dymensionxyz/e2e-tests + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + - id: set-matrix + run: | + output=$(go run build_tests_matrix/main.go) + echo "matrix=$output" >> $GITHUB_OUTPUT + env: + TEST_EXCLUSIONS: '${{ inputs.test-exclusions }}' + TEST_NAME: '${{ inputs.test }}' + ROLLAPP_TYPE: "EVM" + # e2e-tests-by runs the actual go test command to trigger the test. rollapp-evm: + needs: + - build-evm-matrix strategy: - matrix: - tests: - - "e2e-test-ibc-success-evm" - - "e2e-test-ibc-timeout-evm" - - "e2e-test-ibc-grace-period-evm" - - "e2e-test-eibc-fulfillment-only-one-evm" - - "e2e-test-eibc-fulfillment-evm-2-RAs" - - "e2e-test-eibc-corrupted-memo-evm" - - "e2e-test-eibc-excessive-fee-evm" - - "e2e-test-eibc-fulfillment-evm" - - "e2e-test-eibc-fulfill-no-balance-evm" - - "e2e-test-eibc-fulfillment-thirdparty-evm" - - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-evm" - - "e2e-test-eibc-pfm-evm" - - "e2e-test-eibc-timeout-evm" - - "e2e-test-eibc-not-fulfillment-evm" - - "e2e-test-transfer-multi-hop-evm" - - "e2e-test-pfm-with-grace-period-evm" - - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20" - - "e2e-test-pfm-gaia-to-rollapp-evm" - - "e2e-test-batch-finalization-evm" - - "e2e-test-disconnection-evm" - - "e2e-test-rollapp-freeze-evm" - - "e2e-test-other-rollapp-not-affected-evm" - - "e2e-test-rollapp-genesis-event-evm" - - "e2e-test-dym-finalize-block-on-recv-packet-evm" - - "e2e-test-dym-finalize-block-on-timeout-packet-evm" - - "e2e-test-dym-finalize-block-on-ack-packet-evm" - - "e2e-test-delayedack-pending-packets-evm" - - "e2e-test-delayedack-relayer-down-evm" - - "e2e-test-sequencer-invariant-evm" - - "e2e-test-eibc-invariant-evm" - - "e2e-test-rollapp-invariant-evm" - - "e2e-test-rollapp-upgrade-non-state-breaking-evm" - - "e2e-test-erc20-hub-to-rollapp-without-register" fail-fast: false + matrix: ${{ fromJSON(needs.build-evm-matrix.outputs.matrix) }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -69,7 +67,8 @@ jobs: docker image ls -a - name: Rollapp-EVM E2E Tests - run: make ${{ matrix.tests }} + run: make e2e-test test=${{ matrix.test }} env: ROLLAPP_EVM_CI: ${{ inputs.rollapp_evm_ci }} + \ No newline at end of file diff --git a/.github/workflows/e2e-test-wasm-workflow-call.yaml b/.github/workflows/e2e-test-wasm-workflow-call.yaml index bf7d790b..59c912e2 100644 --- a/.github/workflows/e2e-test-wasm-workflow-call.yaml +++ b/.github/workflows/e2e-test-wasm-workflow-call.yaml @@ -6,40 +6,44 @@ on: required: false type: string default: "latest" + test: + description: 'test name to run as standalone' + required: false + type: string + default: '' + test-exclusions: + description: 'Comma separated list of tests to skip' + required: false + type: string + default: '' # empty string means don't skip any test. jobs: + build-wasm-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + with: + repository: dymensionxyz/e2e-tests + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + - id: set-matrix + run: | + output=$(go run build_tests_matrix/main.go) + echo "matrix=$output" >> $GITHUB_OUTPUT + env: + TEST_EXCLUSIONS: '${{ inputs.test-exclusions }}' + TEST_NAME: '${{ inputs.test }}' + ROLLAPP_TYPE: "Wasm" # e2e-tests-by runs the actual go test command to trigger the test. rollapp-wasm: + needs: + - build-wasm-matrix strategy: - matrix: - tests: - - "e2e-test-ibc-success-wasm" - - "e2e-test-ibc-timeout-wasm" - - "e2e-test-ibc-grace-period-wasm" - - "e2e-test-eibc-fulfillment-only-one-wasm" - - "e2e-test-eibc-fulfillment-wasm" - - "e2e-test-eibc-fulfillment-thirdparty-wasm" - - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm" - - "e2e-test-eibc-pfm-wasm" - - "e2e-test-eibc-not-fulfillment-wasm" - - "e2e-test-transfer-multi-hop-wasm" - - "e2e-test-pfm-with-grace-period-wasm" - - "e2e-test-pfm-gaia-to-rollapp-wasm" - - "e2e-test-batch-finalization-wasm" - - "e2e-test-disconnection-wasm" - - "e2e-test-rollapp-freeze-wasm" - - "e2e-test-other-rollapp-not-affected-wasm" - - "e2e-test-dym-finalize-block-on-recv-packet-wasm" - - "e2e-test-dym-finalize-block-on-timeout-packet-wasm" - - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - - "e2e-test-delayedack-pending-packets-wasm" - - "e2e-test-delayedack-relayer-down-wasm" - - "e2e-test-eibc-invariant-wasm" - - "e2e-test-rollapp-invariant-wasm" - - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" - - "e2e-test-sequencer-invariant-wasm" - - "e2e-test-rollapp-upgrade-non-state-breaking-wasm" fail-fast: false + matrix: ${{ fromJSON(needs.build-wasm-matrix.outputs.matrix) }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -62,7 +66,7 @@ jobs: docker image ls -a - name: Rollapp-Wasm E2E Tests - run: make ${{ matrix.tests }} + run: make e2e-test test=${{ matrix.test }} env: ROLLAPP_WASM_CI: ${{ inputs.rollapp_wasm_ci }} \ No newline at end of file diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index b6595487..9ecde225 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -16,109 +16,68 @@ on: required: false type: string default: "latest" + relayer_ci: + description: "CI run on Relayer Repo" + required: false + type: string + default: "main-dym" + test: + description: 'test name to run as standalone' + required: false + type: string + default: '' + test-exclusions: + description: 'Comma separated list of tests to skip' + required: false + type: string + default: '' # empty string means don't skip any test. jobs: - # e2e-tests-by runs the actual go test command to trigger the test. - rollapp-evm: - strategy: - matrix: - tests: - - "e2e-test-ibc-success-evm" - - "e2e-test-ibc-timeout-evm" - - "e2e-test-ibc-grace-period-evm" - - "e2e-test-eibc-fulfillment-only-one-evm" - - "e2e-test-eibc-fulfillment-evm" - - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-evm" - - "e2e-test-eibc-fulfillment-evm-2-RAs" - - "e2e-test-eibc-pfm-evm" - - "e2e-test-eibc-fulfill-no-balance-evm" - - "e2e-test-eibc-corrupted-memo-evm" - - "e2e-test-eibc-excessive-fee-evm" - - "e2e-test-eibc-fulfillment-thirdparty-evm" - - "e2e-test-eibc-timeout-evm" - - "e2e-test-eibc-timeout_and_fulfill-evm" - - "e2e-test-eibc-not-fulfillment-evm" - - "e2e-test-transfer-multi-hop-evm" - - "e2e-test-pfm-with-grace-period-evm" - - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20" - - "e2e-test-pfm-gaia-to-rollapp-evm" - - "e2e-test-batch-finalization-evm" - - "e2e-test-disconnection-evm" - - "e2e-test-fullnode-sync-evm" - - "e2e-test-rollapp-freeze-evm" - - "e2e-test-other-rollapp-not-affected-evm" - - "e2e-test-rollapp-genesis-event-evm" - - "e2e-test-dym-finalize-block-on-recv-packet-evm" - - "e2e-test-dym-finalize-block-on-timeout-packet-evm" - - "e2e-test-dym-finalize-block-on-ack-packet-evm" - - "e2e-test-delayedack-pending-packets-evm" - - "e2e-test-delayedack-relayer-down-evm" - - "e2e-test-sequencer-invariant-evm" - - "e2e-test-rollapp-invariant-evm" - - "e2e-test-eibc-invariant-evm" - - "e2e-test-rollapp-upgrade-non-state-breaking-evm" - - "e2e-test-erc20-hub-to-rollapp-without-register" - fail-fast: false + build-evm-matrix: runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - uses: actions/checkout@v4 with: repository: dymensionxyz/e2e-tests - - name: Set up Go 1.21 - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: - go-version: "1.21.4" - - - name: Download Tarball Artifact - uses: actions/download-artifact@v3 + go-version: '1.21' + - id: set-matrix + run: | + output=$(go run build_tests_matrix/main.go) + echo "matrix=$output" >> $GITHUB_OUTPUT + env: + TEST_EXCLUSIONS: '${{ inputs.test-exclusions }}' + TEST_NAME: '${{ inputs.test }}' + ROLLAPP_TYPE: "EVM" + build-wasm-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 with: - name: e2e - path: /tmp - - - name: Load Docker Image + repository: dymensionxyz/e2e-tests + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + - id: set-matrix run: | - docker image load -i /tmp/e2e.tar - docker image ls -a - - - name: Rollapp-EVM E2E Tests - run: make ${{ matrix.tests }} + output=$(go run build_tests_matrix/main.go) + echo "matrix=$output" >> $GITHUB_OUTPUT env: - DYMENSION_CI: ${{ inputs.dymension_ci }} - ROLLAPP_EVM_CI: ${{ inputs.rollapp_evm_ci }} - ROLLAPP_WASM_CI: ${{ inputs.rollapp_wasm_ci }} - rollapp-wasm: + TEST_EXCLUSIONS: '${{ inputs.test-exclusions }}' + TEST_NAME: '${{ inputs.test }}' + ROLLAPP_TYPE: "Wasm" + # e2e-tests-by runs the actual go test command to trigger the test. + rollapp-evm: + needs: + - build-evm-matrix strategy: - matrix: - tests: - - "e2e-test-ibc-success-wasm" - - "e2e-test-ibc-timeout-wasm" - - "e2e-test-ibc-grace-period-wasm" - - "e2e-test-eibc-fulfillment-only-one-wasm" - - "e2e-test-eibc-fulfillment-wasm" - - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm" - - "e2e-test-eibc-fulfillment-thirdparty-wasm" - - "e2e-test-eibc-pfm-wasm" - - "e2e-test-eibc-timeout_and_fulfill-wasm" - - "e2e-test-eibc-not-fulfillment-wasm" - - "e2e-test-transfer-multi-hop-wasm" - - "e2e-test-pfm-with-grace-period-wasm" - - "e2e-test-pfm-gaia-to-rollapp-wasm" - - "e2e-test-batch-finalization-wasm" - - "e2e-test-disconnection-wasm" - - "e2e-test-fullnode-sync-wasm" - - "e2e-test-rollapp-freeze-wasm" - - "e2e-test-other-rollapp-not-affected-wasm" - - "e2e-test-dym-finalize-block-on-recv-packet-wasm" - - "e2e-test-dym-finalize-block-on-timeout-packet-wasm" - - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - - "e2e-test-delayedack-pending-packets-wasm" - - "e2e-test-delayedack-relayer-down-wasm" - - "e2e-test-rollapp-invariant-wasm" - - "e2e-test-eibc-invariant-wasm" - - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" - - "e2e-test-sequencer-invariant-wasm" - - "e2e-test-rollapp-upgrade-non-state-breaking-wasm" fail-fast: false + matrix: ${{ fromJSON(needs.build-evm-matrix.outputs.matrix) }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -140,9 +99,46 @@ jobs: docker image load -i /tmp/e2e.tar docker image ls -a - - name: Rollapp-Wasm E2E Tests - run: make ${{ matrix.tests }} + - name: Rollapp-EVM E2E Tests + run: make e2e-test test=${{ matrix.test }} env: DYMENSION_CI: ${{ inputs.dymension_ci }} ROLLAPP_EVM_CI: ${{ inputs.rollapp_evm_ci }} ROLLAPP_WASM_CI: ${{ inputs.rollapp_wasm_ci }} + RELAYER_CI: ${{ inputs.relayer_ci }} + + # e2e-tests-by runs the actual go test command to trigger the test. + rollapp-wasm: + needs: + - build-wasm-matrix + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.build-wasm-matrix.outputs.matrix) }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: dymensionxyz/e2e-tests + - name: Set up Go 1.21 + uses: actions/setup-go@v4 + with: + go-version: "1.21.4" + + - name: Download Tarball Artifact + uses: actions/download-artifact@v3 + with: + name: e2e + path: /tmp + + - name: Load Docker Image + run: | + docker image load -i /tmp/e2e.tar + docker image ls -a + + - name: Rollapp-Wasm E2E Tests + run: make e2e-test test=${{ matrix.test }} + env: + DYMENSION_CI: ${{ inputs.dymension_ci }} + ROLLAPP_EVM_CI: ${{ inputs.rollapp_evm_ci }} + ROLLAPP_WASM_CI: ${{ inputs.rollapp_wasm_ci }} + RELAYER_CI: ${{ inputs.relayer_ci }} \ No newline at end of file diff --git a/.github/workflows/e2e_test.yml b/.github/workflows/e2e_test.yml index f47577dd..77b45b18 100644 --- a/.github/workflows/e2e_test.yml +++ b/.github/workflows/e2e_test.yml @@ -20,93 +20,47 @@ permissions: packages: write jobs: - # e2e-tests-by runs the actual go test command to trigger the test. - rollapp-evm: - strategy: - matrix: - tests: - - "e2e-test-ibc-success-evm" - - "e2e-test-ibc-timeout-evm" - - "e2e-test-ibc-grace-period-evm" - - "e2e-test-eibc-fulfillment-only-one-evm" - - "e2e-test-eibc-fulfillment-evm-2-RAs" - - "e2e-test-eibc-corrupted-memo-evm" - - "e2e-test-eibc-excessive-fee-evm" - - "e2e-test-eibc-fulfillment-evm" - - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-evm" - - "e2e-test-eibc-fulfill-no-balance-evm" - - "e2e-test-eibc-fulfillment-thirdparty-evm" - - "e2e-test-eibc-pfm-evm" - - "e2e-test-eibc-timeout-evm" - - "e2e-test-eibc-timeout_and_fulfill-evm" - - "e2e-test-eibc-not-fulfillment-evm" - - "e2e-test-transfer-multi-hop-evm" - - "e2e-test-pfm-with-grace-period-evm" - - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20" - - "e2e-test-pfm-gaia-to-rollapp-evm" - - "e2e-test-batch-finalization-evm" - - "e2e-test-disconnection-evm" - - "e2e-test-fullnode-sync-evm" - - "e2e-test-rollapp-freeze-evm" - - "e2e-test-other-rollapp-not-affected-evm" - - "e2e-test-rollapp-genesis-event-evm" - - "e2e-test-dym-finalize-block-on-recv-packet-evm" - - "e2e-test-dym-finalize-block-on-timeout-packet-evm" - - "e2e-test-dym-finalize-block-on-ack-packet-evm" - - "e2e-test-delayedack-pending-packets-evm" - - "e2e-test-delayedack-relayer-down-evm" - - "e2e-test-sequencer-invariant-evm" - - "e2e-test-rollapp-invariant-evm" - - "e2e-test-eibc-invariant-evm" - - "e2e-test-rollapp-upgrade-non-state-breaking-evm" - - "e2e-test-erc20-hub-to-rollapp-without-register" - fail-fast: false + build-evm-matrix: runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - uses: actions/checkout@v4 with: repository: dymensionxyz/e2e-tests - - name: Set up Go 1.21 - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: - go-version: "1.21.4" - - - name: Rollapp-EVM E2E Tests + go-version: '1.21' + - id: set-matrix run: | - make ${{ matrix.tests }} - rollapp-wasm: + output=$(go run build_tests_matrix/main.go) + echo "matrix=$output" >> $GITHUB_OUTPUT + env: + ROLLAPP_TYPE: "EVM" + build-wasm-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + with: + repository: dymensionxyz/e2e-tests + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + - id: set-matrix + run: | + output=$(go run build_tests_matrix/main.go) + echo "matrix=$output" >> $GITHUB_OUTPUT + env: + ROLLAPP_TYPE: "Wasm" + # e2e-tests-by runs the actual go test command to trigger the test. + rollapp-evm: + needs: + - build-evm-matrix strategy: - matrix: - tests: - - "e2e-test-ibc-success-wasm" - - "e2e-test-ibc-timeout-wasm" - - "e2e-test-ibc-grace-period-wasm" - - "e2e-test-eibc-fulfillment-only-one-wasm" - - "e2e-test-eibc-fulfillment-wasm" - - "e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm" - - "e2e-test-eibc-fulfillment-thirdparty-wasm" - - "e2e-test-eibc-pfm-wasm" - - "e2e-test-eibc-timeout_and_fulfill-wasm" - - "e2e-test-eibc-not-fulfillment-wasm" - - "e2e-test-transfer-multi-hop-wasm" - - "e2e-test-pfm-with-grace-period-wasm" - - "e2e-test-pfm-gaia-to-rollapp-wasm" - - "e2e-test-batch-finalization-wasm" - - "e2e-test-disconnection-wasm" - - "e2e-test-fullnode-sync-wasm" - - "e2e-test-rollapp-freeze-wasm" - - "e2e-test-other-rollapp-not-affected-wasm" - - "e2e-test-dym-finalize-block-on-recv-packet-wasm" - - "e2e-test-dym-finalize-block-on-timeout-packet-wasm" - - "e2e-test-dym-finalize-block-on-ack-packet-wasm" - - "e2e-test-delayedack-pending-packets-wasm" - - "e2e-test-delayedack-relayer-down-wasm" - - "e2e-test-rollapp-invariant-wasm" - - "e2e-test-eibc-invariant-wasm" - - "e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20" - - "e2e-test-sequencer-invariant-wasm" - - "e2e-test-rollapp-upgrade-non-state-breaking-wasm" fail-fast: false + matrix: ${{ fromJSON(needs.build-evm-matrix.outputs.matrix) }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -117,5 +71,25 @@ jobs: with: go-version: "1.21.4" - - name: Rollapp-Wasm E2E Tests - run: make ${{ matrix.tests }} + - name: Rollapp-EVM E2E Tests + run: make e2e-test test=${{ matrix.test }} + + # e2e-tests-by runs the actual go test command to trigger the test. + rollapp-wasm: + needs: + - build-wasm-matrix + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.build-wasm-matrix.outputs.matrix) }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: dymensionxyz/e2e-tests + - name: Set up Go 1.21 + uses: actions/setup-go@v4 + with: + go-version: "1.21.4" + + - name: Rollapp-Wasm E2E Tests + run: make e2e-test test=${{ matrix.test }} \ No newline at end of file diff --git a/Makefile b/Makefile index ee553ed0..f6257a4f 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ clean-e2e: sh clean.sh +e2e-test: clean-e2e + ./run-e2e.sh $(test) + # Executes IBC tests via rollup-e2e-testing e2e-test-ibc-success-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferSuccess_EVM . @@ -18,7 +21,7 @@ e2e-test-eibc-fulfillment-only-one-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillOnOneRollApp_EVM . e2e-test-eibc-fulfillment-evm-2-RAs: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_two_rollapps . + cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_two_rollapps_EVM . e2e-test-ibc-grace-period-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCGracePeriodCompliance_EVM . @@ -36,16 +39,16 @@ e2e-test-eibc-pfm-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCPFM_EVM . e2e-test-eibc-fulfill-no-balance-evm: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestEIBCNoBalanceToFulfillOrder . + cd tests && go test -timeout=25m -race -v -run TestEIBCNoBalanceToFulfillOrder_EVM . e2e-test-eibc-corrupted-memo-evm: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestEIBCCorruptedMemoNegative . + cd tests && go test -timeout=25m -race -v -run TestEIBCCorruptedMemoNegative_EVM . e2e-test-eibc-excessive-fee-evm: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestEIBCFeeTooHigh . + cd tests && go test -timeout=25m -race -v -run TestEIBCFeeTooHigh_EVM . e2e-test-eibc-timeout-evm: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestEIBCTimeoutDymToRollapp . + cd tests && go test -timeout=25m -race -v -run TestEIBCTimeoutDymToRollapp_EVM . e2e-test-eibc-timeout_and_fulfill-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCTimeoutFulFillDymToRollapp_Evm . @@ -142,10 +145,10 @@ e2e-test-pfm-with-grace-period-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCPFMWithGracePeriod_Wasm . e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestIBCPFM_RollApp1ToRollApp2WithErc20 . + cd tests && go test -timeout=25m -race -v -run TestIBCPFM_RollApp1ToRollApp2WithErc20_EVM . e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestIBCPFM_RollApp1ToRollApp2WithOutErc20 . + cd tests && go test -timeout=25m -race -v -run TestIBCPFM_RollApp1ToRollApp2WithOutErc20_Wasm . e2e-test-batch-finalization-wasm: cd tests && go test -timeout=25m -race -v -run TestBatchFinalization_Wasm . diff --git a/build_tests_matrix/main.go b/build_tests_matrix/main.go new file mode 100644 index 00000000..e344273e --- /dev/null +++ b/build_tests_matrix/main.go @@ -0,0 +1,166 @@ +package main + +import ( + "encoding/json" + "fmt" + "go/ast" + "go/parser" + "go/token" + "io/fs" + "os" + "path/filepath" + "sort" + "strings" +) + +const ( + testNamePrefix = "Test" + testFileNameSuffix = "_test.go" + e2eTestDirectory = "tests" + // testExclusionsEnv is a comma separated list of test function names that will not be included + // in the results of this script. + testExclusionsEnv = "TEST_EXCLUSIONS" + // testNameEnv if provided returns a single test entry so that only one test is actually run. + testNameEnv = "TEST_NAME" +) + +// GithubActionTestMatrix represents +type GithubActionTestMatrix struct { + Include []TestPair `json:"include"` +} + +type TestPair struct { + Test string `json:"test"` +} + +func main() { + githubActionMatrix, err := getGithubActionMatrixForTests(e2eTestDirectory, getTestToRun(), getExcludedTestFunctions()) + if err != nil { + fmt.Printf("error generating github action json: %s", err) + os.Exit(1) + } + + ghBytes, err := json.Marshal(githubActionMatrix) + if err != nil { + fmt.Printf("error marshalling github action json: %s", err) + os.Exit(1) + } + fmt.Println(string(ghBytes)) +} + +// getTestToRun returns the specified test function to run if present. +// If specified, only this test will be run. +func getTestToRun() string { + testName, ok := os.LookupEnv(testNameEnv) + if !ok { + return "" + } + return testName +} + +// getExcludedTestFunctions returns a list of test functions that we don't want to run. +func getExcludedTestFunctions() []string { + exclusions, ok := os.LookupEnv(testExclusionsEnv) + if !ok { + return nil + } + return strings.Split(exclusions, ",") +} + +func contains(s string, items []string) bool { + for _, elem := range items { + if elem == s { + return true + } + } + return false +} + +func getRollappType() string { + rollapp, ok := os.LookupEnv("ROLLAPP_TYPE") + if !ok { + return "" + } + return rollapp +} + +// getGithubActionMatrixForTests returns a json string representing the contents that should go in the matrix +// field in a github action workflow. This string can be used with `fromJSON(str)` to dynamically build +// the workflow matrix to include all E2E tests under the e2eRootDirectory directory. +func getGithubActionMatrixForTests(e2eRootDirectory, testName string, excludedItems []string) (GithubActionTestMatrix, error) { + var testCases []string + fset := token.NewFileSet() + err := filepath.Walk(e2eRootDirectory, func(path string, info fs.FileInfo, err error) error { + if err != nil { + return fmt.Errorf("error walking e2e directory: %s", err) + } + + // only look at test files + if !strings.HasSuffix(path, testFileNameSuffix) { + return nil + } + + f, err := parser.ParseFile(fset, path, nil, 0) + if err != nil { + return fmt.Errorf("failed parsing file: %s", err) + } + + testCases, err = extractTestNames(f, excludedItems, testCases) + if err != nil { + return fmt.Errorf("failed extracting test suite name and test cases: %s", err) + } + + if testName != "" && contains(testName, testCases) { + testCases = []string{testName} + } + + return nil + }) + if err != nil { + return GithubActionTestMatrix{}, err + } + + gh := GithubActionTestMatrix{ + Include: []TestPair{}, + } + + for _, testCaseName := range testCases { + gh.Include = append(gh.Include, TestPair{ + Test: testCaseName, + }) + } + + // Sort the test cases by name so that the order is consistent. + sort.SliceStable(gh.Include, func(i, j int) bool { + return gh.Include[i].Test < gh.Include[j].Test + }) + + if testName != "" && len(gh.Include) != 1 { + return GithubActionTestMatrix{}, fmt.Errorf("expected exactly 1 test in the output matrix but got %d", len(gh.Include)) + } + + return gh, nil +} + +// extractTestNames extracts the name of all tests in the same file. +func extractTestNames(file *ast.File, excludedItems, testCases []string) ([]string, error) { + rollapp := getRollappType() + for _, d := range file.Decls { + if f, ok := d.(*ast.FuncDecl); ok { + functionName := f.Name.Name + if isTestFunction(f, rollapp) { + if contains(functionName, excludedItems) { + return testCases, nil + } + testCases = append(testCases, functionName) + } + } + } + return testCases, nil +} + +// isTestFunction returns true if the function name starts with "Test" and has no parameters. +// as test suite functions do not accept a *testing.T. +func isTestFunction(f *ast.FuncDecl, suffix string) bool { + return strings.HasPrefix(f.Name.Name, testNamePrefix) && strings.HasSuffix(f.Name.Name, suffix) +} diff --git a/run-e2e.sh b/run-e2e.sh new file mode 100755 index 00000000..0dc56b48 --- /dev/null +++ b/run-e2e.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -eo pipefail + +TEST="${1}" + +# run the test file directly, this allows log output to be streamed directly in the terminal sessions +# without needed to wait for the test to finish. +# it shouldn't take 30m, but the wasm test can be quite slow, so we can be generous. +cd tests && go test -timeout=25m -race -v -run ${TEST} . diff --git a/tests/eibc_corrupted_memo_test.go b/tests/eibc_corrupted_memo_test.go index 0d8373ec..4fd533d9 100644 --- a/tests/eibc_corrupted_memo_test.go +++ b/tests/eibc_corrupted_memo_test.go @@ -22,7 +22,7 @@ import ( // This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub // that has incorrect memo data -func TestEIBCCorruptedMemoNegative(t *testing.T) { +func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { if testing.Short() { t.Skip() } diff --git a/tests/eibc_fee_test.go b/tests/eibc_fee_test.go index 1c610c0c..76639961 100644 --- a/tests/eibc_fee_test.go +++ b/tests/eibc_fee_test.go @@ -22,7 +22,7 @@ import ( // This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub // that has set fee more than a packet amount -func TestEIBCFeeTooHigh(t *testing.T) { +func TestEIBCFeeTooHigh_EVM(t *testing.T) { if testing.Short() { t.Skip() } diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index f4c501c2..e947f3fb 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -1362,7 +1362,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { ) } -func TestEIBCFulfillment_two_rollapps(t *testing.T) { +func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { if testing.Short() { t.Skip() } diff --git a/tests/eibc_nobalance_test.go b/tests/eibc_nobalance_test.go index c15d78ea..945d967d 100644 --- a/tests/eibc_nobalance_test.go +++ b/tests/eibc_nobalance_test.go @@ -23,7 +23,7 @@ import ( // This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub // that is attempted to be fulfilled without having enough balance by the market maker // as a result, the IBC packet should be finalized without order fulfillment -func TestEIBCNoBalanceToFulfillOrder(t *testing.T) { +func TestEIBCNoBalanceToFulfillOrder_EVM(t *testing.T) { if testing.Short() { t.Skip() } diff --git a/tests/eibc_timeout_test.go b/tests/eibc_timeout_test.go index d3f5b21c..b98f3e82 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -21,7 +21,8 @@ import ( // This test case verifies the system's behavior when an eIBC packet is from dym to rollapp and it times out. // It verifies that new demand order is automatically created when that happens -func TestEIBCTimeoutDymToRollapp(t *testing.T) { + +func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { if testing.Short() { t.Skip() } @@ -262,7 +263,7 @@ func TestEIBCTimeoutDymToRollapp(t *testing.T) { // TestEIBCTimeoutFulFillDymToRollapp test send 3rd party IBC denom from dymension to rollapp with timeout // and full filled -func TestEIBCTimeoutFulFillDymToRollapp_Evm(t *testing.T) { +func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { if testing.Short() { t.Skip() } diff --git a/tests/ibc_pfm_with_grace_period_test.go b/tests/ibc_pfm_with_grace_period_test.go index 776e336a..c76fcc8b 100644 --- a/tests/ibc_pfm_with_grace_period_test.go +++ b/tests/ibc_pfm_with_grace_period_test.go @@ -603,7 +603,7 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { } // PFM with grace period rollApp1 to rollApp2 with Erc20 registed on rollApp2 -func TestIBCPFM_RollApp1ToRollApp2WithErc20(t *testing.T) { +func TestIBCPFM_RollApp1ToRollApp2WithErc20_EVM(t *testing.T) { if testing.Short() { t.Skip() } @@ -945,7 +945,7 @@ func TestIBCPFM_RollApp1ToRollApp2WithErc20(t *testing.T) { require.Equal(t, 0, len(resp.Commitments)) } -func TestIBCPFM_RollApp1ToRollApp2WithOutErc20(t *testing.T) { +func TestIBCPFM_RollApp1ToRollApp2WithOutErc20_Wasm(t *testing.T) { if testing.Short() { t.Skip() } From f7efdcee3236499ac7367e59a1a9ff845a0ffe94 Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Thu, 16 May 2024 16:56:28 +0700 Subject: [PATCH 44/61] rollapp-genesis: ibc transfer rollapp to hub when only rollapp side gone through genesis event (#175) --- Makefile | 6 + go.mod | 2 +- go.sum | 4 +- tests/rollapp_genesis_event_test.go | 324 ++++++++++++++++++++++++++++ tests_spec/rollapp_genesis.md | 4 +- 5 files changed, 335 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index f6257a4f..a775c090 100644 --- a/Makefile +++ b/Makefile @@ -119,6 +119,9 @@ e2e-test-erc20-hub-to-rollapp-without-register: clean-e2e e2e-test-rollapp-upgrade-non-state-breaking-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollappUpgradeNonStateBreaking_EVM . +e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_rollapp_evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestTransferRollAppTriggerGenesis_EVM . + # Executes IBC tests via rollup-e2e-testing e2e-test-ibc-success-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferSuccess_Wasm . @@ -201,6 +204,9 @@ e2e-test-eibc-invariant-wasm: clean-e2e e2e-test-rollapp-upgrade-non-state-breaking-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollappUpgradeNonStateBreaking_Wasm . +e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_rollapp_wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestTransferRollAppTriggerGenesis_Wasm . + # Executes all tests via rollup-e2e-testing e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ diff --git a/go.mod b/go.mod index f8d804ba..f56c1755 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( cosmossdk.io/math v1.3.0 github.com/cosmos/cosmos-sdk v0.46.16 github.com/cosmos/ibc-go/v6 v6.2.1 - github.com/decentrio/rollup-e2e-testing v0.0.0-20240510065640-e2f6cde97a45 + github.com/decentrio/rollup-e2e-testing v0.0.0-20240516084938-988198ff177f github.com/dymensionxyz/dymension-rdk v1.1.0-beta github.com/dymensionxyz/dymension/v3 v3.1.0-rc01.0.20240404003005-53ccf8a922fd github.com/evmos/ethermint v0.22.0 diff --git a/go.sum b/go.sum index 99c9648b..87e13076 100644 --- a/go.sum +++ b/go.sum @@ -328,8 +328,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240510065640-e2f6cde97a45 h1:wmgyQI+YE0UJIP+S3W8Yx2QmbnhuvgiTUDJZ5ExU6CY= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240510065640-e2f6cde97a45/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240516084938-988198ff177f h1:zSIExYUfmqZJhqhkq2GLsMxThu4Y8issfojrP6iC5PQ= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240516084938-988198ff177f/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= diff --git a/tests/rollapp_genesis_event_test.go b/tests/rollapp_genesis_event_test.go index 3c73dc07..91eec4cb 100644 --- a/tests/rollapp_genesis_event_test.go +++ b/tests/rollapp_genesis_event_test.go @@ -17,6 +17,7 @@ import ( "github.com/decentrio/rollup-e2e-testing/relayer" "github.com/decentrio/rollup-e2e-testing/testreporter" "github.com/decentrio/rollup-e2e-testing/testutil" + transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" ) // TestRollappGenesisEvent_EVM ensure that genesis event triggered in both rollapp evm and dymension hub @@ -190,3 +191,326 @@ func TestRollappGenesisEvent_EVM(t *testing.T) { require.Equal(t, "URAX", denommetadata.Symbol) require.Equal(t, fmt.Sprintf("%s %s", rollapp1.GetChainID(), rollapp1.Config().Denom), denommetadata.Name) } + +func TestTransferRollAppTriggerGenesis_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_1234-1", "0adym", "3s") + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + registerGenesisEventTriggerer(t, rollapp1.CosmosChain, rollappUser.KeyName(), rollappUserAddr, "hubgenesis", "GenesisTriggererAllowlist") + + _, err = rollapp1.Validators[0].ExecTx(ctx, rollappUserAddr, "hubgenesis", "genesis-event", dymension.GetChainID(), channel.ChannelID) + require.NoError(t, err) + + hubGenesisState, err := rollapp1.GetNode().QueryHubGenesisState(ctx) + require.NoError(t, err) + + escrowAddress, err := rollapp1.Validators[0].QueryEscrowAddress(ctx, channel.PortID, channel.ChannelID) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, rollapp1, escrowAddress, rollapp1.Config().Denom, hubGenesisState.GenesisTokens.AmountOf(rollapp1.Config().Denom)) + + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // Assert funds were returned to the sender after the timeout has occured + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) + + escrowAddress, err = rollapp1.Validators[0].QueryEscrowAddress(ctx, channel.PortID, channel.ChannelID) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, rollapp1, escrowAddress, rollapp1.Config().Denom, hubGenesisState.GenesisTokens.AmountOf(rollapp1.Config().Denom)) +} + +func TestTransferRollAppTriggerGenesis_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + modifyGenesisKV := []cosmos.GenesisKV{ + { + Key: "app_state.gov.voting_params.voting_period", + Value: "30s", + }, + } + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappWasmGenesis(modifyGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + registerGenesisEventTriggerer(t, rollapp1.CosmosChain, rollappUser.KeyName(), rollappUserAddr, "hubgenesis", "GenesisTriggererAllowlist") + + _, err = rollapp1.Validators[0].ExecTx(ctx, rollappUserAddr, "hubgenesis", "genesis-event", dymension.GetChainID(), channel.ChannelID) + require.NoError(t, err) + + hubGenesisState, err := rollapp1.GetNode().QueryHubGenesisState(ctx) + require.NoError(t, err) + + escrowAddress, err := rollapp1.Validators[0].QueryEscrowAddress(ctx, channel.PortID, channel.ChannelID) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, rollapp1, escrowAddress, rollapp1.Config().Denom, hubGenesisState.GenesisTokens.AmountOf(rollapp1.Config().Denom)) + + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // Assert funds were returned to the sender after the timeout has occured + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) + + escrowAddress, err = rollapp1.Validators[0].QueryEscrowAddress(ctx, channel.PortID, channel.ChannelID) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, rollapp1, escrowAddress, rollapp1.Config().Denom, hubGenesisState.GenesisTokens.AmountOf(rollapp1.Config().Denom)) +} diff --git a/tests_spec/rollapp_genesis.md b/tests_spec/rollapp_genesis.md index 6c3a441f..7fd70ad3 100644 --- a/tests_spec/rollapp_genesis.md +++ b/tests_spec/rollapp_genesis.md @@ -8,5 +8,5 @@ | 4 | Transfer rollapp tokens between hub ↔ rollapp AFTER rollapp has any finalized state on the hub |
  • Rollapp should have any finalized state on the hub
  • Rollapp and hub genesis event were triggered
|✅ |
  • transfer from hub to rollapp should work as expected
  • transfer from rollapp to hub should work as expected
  • transferring all the genesis tokens from hub to rollapp should work as expected
| ✅ | every ibc test | | 5 | Transfer from hub to rollapp after only hub side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event on the hub
  • try transferring tokens from hub to rollapp
  • ERC20 was registered on the rollapp for the hub
|🛑
(missing) |
  • Should fail as no tokens are locked in the escrow address on the rollapp side
| 🛑
(missing) | TODO | | 6 | Transfer from rollapp to hub after only hub side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event on the hub
  • try transferring tokens from rollapp to hub
|🛑
(missing) |
  • Should succeed
| 🛑
(missing) | TODO | -| 7 | Transfer from rollapp to hub after only rollapp side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event only on the rollapp
  • Try transferring from rollapp to hub
|🛑
(missing) |
  • Should fail as no tokens are locked in the escrow address on the rollapp side
  • Should fail with ack error on validation
| 🛑
(missing) | [TODO] | -| 8 | Transfer from hub to rollapp from rollapp-genesis-account on the hub after only rollapp side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event only on the rollapp
  • Try transferring from hub to rollapp
|🛑
(missing) |
  • Should fail as there are no balances for those addresses on the hub
| 🛑
(missing) | TODO | \ No newline at end of file +| 7 | Transfer from rollapp to hub after only rollapp side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event only on the rollapp
  • Try transferring from rollapp to hub
| ✅ |
  • Should fail as no tokens are locked in the escrow address on the rollapp side
  • Should fail with ack error on validation
| ✅ | [TestTransferRollAppTriggerGenesis_EVM](../tests/rollapp_genesis_event_test.go#L195) [TestTransferRollAppTriggerGenesis_Wasm](../tests/rollapp_genesis_event_test.go#L350) | +| 8 | Transfer from hub to rollapp from rollapp-genesis-account on the hub after only rollapp side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event only on the rollapp
  • Try transferring from hub to rollapp
|🛑
(missing) |
  • Should fail as there are no balances for those addresses on the hub
| 🛑
(missing) | TODO | From 13a602569ea5c44ab0afe0d401f318b529b5f0a5 Mon Sep 17 00:00:00 2001 From: Omri Date: Thu, 16 May 2024 12:38:16 +0200 Subject: [PATCH 45/61] changed tests priority in the spec --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ec3d8f72..d363cb95 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,10 @@ make e2e-test-ibc 3. [TestPFM](tests_spec/pfm.md) 4. [TestGenesisBridge](tests_spec/rollapp_genesis.md) 5. [TestERC20](tests_spec/erc20.md) -6. [TestHubInvariants](tests_spec/hub_invariants.md) -7. [TestRollappUpgrade](tests_spec/rollapp_upgrade.md) -8. [TestRollappHardfork](tests_spec/rollapp_hardfork.md) -9. [TestSequencer](tests_spec/sequencer.md) +6. [TestSequencer](tests_spec/sequencer.md) +7. [TestHubInvariants](tests_spec/hub_invariants.md) +8. [TestRollappUpgrade](tests_spec/rollapp_upgrade.md) +9. [TestRollappHardfork](tests_spec/rollapp_hardfork.md) ## Contributing From b0479305e395c8119c151b905efaf53c0effff90 Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Fri, 17 May 2024 13:31:35 +0700 Subject: [PATCH 46/61] [rollapp-genesis] ibc transfer when only hub side gone through genesis (#181) --- Makefile | 6 + tests/rollapp_genesis_event_test.go | 323 ++++++++++++++++++++++++++++ tests_spec/rollapp_genesis.md | 2 +- 3 files changed, 330 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a775c090..3179e55a 100644 --- a/Makefile +++ b/Makefile @@ -122,6 +122,9 @@ e2e-test-rollapp-upgrade-non-state-breaking-evm: clean-e2e e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_rollapp_evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestTransferRollAppTriggerGenesis_EVM . +e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_hub_evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestRollAppTransferHubTriggerGenesis_EVM . + # Executes IBC tests via rollup-e2e-testing e2e-test-ibc-success-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferSuccess_Wasm . @@ -207,6 +210,9 @@ e2e-test-rollapp-upgrade-non-state-breaking-wasm: clean-e2e e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_rollapp_wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestTransferRollAppTriggerGenesis_Wasm . +e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_hub_wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestRollAppTransferHubTriggerGenesis_Wasm . + # Executes all tests via rollup-e2e-testing e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ diff --git a/tests/rollapp_genesis_event_test.go b/tests/rollapp_genesis_event_test.go index 91eec4cb..da9f5e5e 100644 --- a/tests/rollapp_genesis_event_test.go +++ b/tests/rollapp_genesis_event_test.go @@ -514,3 +514,326 @@ func TestTransferRollAppTriggerGenesis_Wasm(t *testing.T) { require.NoError(t, err) testutil.AssertBalance(t, ctx, rollapp1, escrowAddress, rollapp1.Config().Denom, hubGenesisState.GenesisTokens.AmountOf(rollapp1.Config().Denom)) } + +func TestRollAppTransferHubTriggerGenesis_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_1234-1", "0adym", "3s") + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + rollapp_params := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp_params) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // Assert funds were returned to the sender after the timeout has occured + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount) + + t.Cleanup( + func() { + err := r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +func TestRollAppTransferHubTriggerGenesis_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + modifyGenesisKV := []cosmos.GenesisKV{ + { + Key: "app_state.gov.voting_params.voting_period", + Value: "30s", + }, + } + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappWasmGenesis(modifyGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + rollapp_params := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp_params) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // Assert funds were returned to the sender after the timeout has occured + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount) + + t.Cleanup( + func() { + err := r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} diff --git a/tests_spec/rollapp_genesis.md b/tests_spec/rollapp_genesis.md index 7fd70ad3..a6de5f93 100644 --- a/tests_spec/rollapp_genesis.md +++ b/tests_spec/rollapp_genesis.md @@ -7,6 +7,6 @@ | 3 | Transfer rollapp tokens between hub ↔ rollapp BEFORE rollapp has any finalized state on the hub (and both events were triggered) |
  • Rollapp shouldn’t have any finalized state on the hub
  • Rollapp and hub genesis event were triggered
|🛑
(missing) |
  • transfer from hub to rollapp should work as expected
  • transfer from rollapp to hub should work as expected
  • transferring all the genesis tokens from hub to rollapp should work as expected
| 🛑
(missing) | TODO | | 4 | Transfer rollapp tokens between hub ↔ rollapp AFTER rollapp has any finalized state on the hub |
  • Rollapp should have any finalized state on the hub
  • Rollapp and hub genesis event were triggered
|✅ |
  • transfer from hub to rollapp should work as expected
  • transfer from rollapp to hub should work as expected
  • transferring all the genesis tokens from hub to rollapp should work as expected
| ✅ | every ibc test | | 5 | Transfer from hub to rollapp after only hub side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event on the hub
  • try transferring tokens from hub to rollapp
  • ERC20 was registered on the rollapp for the hub
|🛑
(missing) |
  • Should fail as no tokens are locked in the escrow address on the rollapp side
| 🛑
(missing) | TODO | -| 6 | Transfer from rollapp to hub after only hub side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event on the hub
  • try transferring tokens from rollapp to hub
|🛑
(missing) |
  • Should succeed
| 🛑
(missing) | TODO | +| 6 | Transfer from rollapp to hub after only hub side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event on the hub
  • try transferring tokens from rollapp to hub
|✅|
  • Should succeed
| ✅ | [TestRollAppTransferHubTriggerGenesis_EVM](../tests/rollapp_genesis_event_test.go#L518) [TestRollAppTransferHubTriggerGenesis_Wasm](../tests/rollapp_genesis_event_test.go#L673) | | 7 | Transfer from rollapp to hub after only rollapp side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event only on the rollapp
  • Try transferring from rollapp to hub
| ✅ |
  • Should fail as no tokens are locked in the escrow address on the rollapp side
  • Should fail with ack error on validation
| ✅ | [TestTransferRollAppTriggerGenesis_EVM](../tests/rollapp_genesis_event_test.go#L195) [TestTransferRollAppTriggerGenesis_Wasm](../tests/rollapp_genesis_event_test.go#L350) | | 8 | Transfer from hub to rollapp from rollapp-genesis-account on the hub after only rollapp side has gone through genesis event |
  • Create relevant genesis accounts
  • Open a channel
  • Trigger genesis event only on the rollapp
  • Try transferring from hub to rollapp
|🛑
(missing) |
  • Should fail as there are no balances for those addresses on the hub
| 🛑
(missing) | TODO | From 05a22e796dbe1427aaa725450c8279b69c86deac Mon Sep 17 00:00:00 2001 From: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Date: Fri, 17 May 2024 16:22:44 +0700 Subject: [PATCH 47/61] Test: Hub Upgrade (#16) --- .../e2e-test-hub-upgrade-workflow-call.yml | 48 +++ Makefile | 8 +- tests/setup.go | 10 + tests/upgrade_hub_test.go | 291 ++++++++++++++++++ 4 files changed, 356 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/e2e-test-hub-upgrade-workflow-call.yml create mode 100644 tests/upgrade_hub_test.go diff --git a/.github/workflows/e2e-test-hub-upgrade-workflow-call.yml b/.github/workflows/e2e-test-hub-upgrade-workflow-call.yml new file mode 100644 index 00000000..a6a847f2 --- /dev/null +++ b/.github/workflows/e2e-test-hub-upgrade-workflow-call.yml @@ -0,0 +1,48 @@ +on: + workflow_call: + inputs: + dymension_ci: + description: "CI run on Dymension Repo" + required: false + type: string + default: "latest" + upgrade_name: + description: "Upgrade Name be used by e2e-tests" + required: false + type: string + default: "" + +jobs: + # e2e-tests-by runs the actual go test command to trigger the test. + hub-upgrade: + strategy: + matrix: + tests: + - "e2e-test-upgrade-hub" + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: dymensionxyz/e2e-tests + - name: Set up Go 1.21 + uses: actions/setup-go@v4 + with: + go-version: "1.21.4" + + - name: Download Tarball Artifact + uses: actions/download-artifact@v3 + with: + name: e2e + path: /tmp + + - name: Load Docker Image + run: | + docker image load -i /tmp/e2e.tar + docker image ls -a + + - name: Rollapp-EVM E2E Tests + run: make ${{ matrix.tests }} + env: + DYMENSION_CI: ${{ inputs.dymension_ci }} + UPGRADE_NAME: ${{ inputs.upgrade_name }} \ No newline at end of file diff --git a/Makefile b/Makefile index 3179e55a..9ecd6791 100644 --- a/Makefile +++ b/Makefile @@ -195,6 +195,9 @@ e2e-test-delayedack-pending-packets-wasm: clean-e2e e2e-test-delayedack-relayer-down-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_RelayerDown_Wasm . +e2e-test-upgrade-hub: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestHubUpgrade . + e2e-test-sequencer-invariant-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestSequencerInvariant_Wasm . @@ -257,7 +260,8 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-dym-finalize-block-on-timeout-packet \ e2e-test-dym-finalize-block-on-ack-packet\ e2e-test-delayedack-pending-packets-wasm \ - e2e-test-delayedack-relayer-down-wasm \ + e2e-test-delayedack-relayer-down-wasm \ + e2e-test-upgrade-hub \ e2e-test-sequencer-invariant-wasm \ e2e-test-rollapp-invariant-wasm \ e2e-test-rollapp-upgrade-non-state-breaking-wasm @@ -309,5 +313,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-dym-finalize-block-on-recv-packet \ e2e-test-dym-finalize-block-on-timeout-packet \ e2e-test-dym-finalize-block-on-ack-packet \ + e2e-test-delayedack-pending-packets-wasm \ + e2e-test-upgrade-hub \ e2e-test-other-rollapp-not-affected-wasm \ e2e-test-rollapp-upgrade-non-state-breaking-wasm diff --git a/tests/setup.go b/tests/setup.go index 6fd79e16..4e74467a 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -65,6 +65,8 @@ var ( dymensionVersion, rollappEVMVersion, rollappWasmVersion = GetDockerImageVersion() + upgradeName = GetUpgradeName() + dymensionImage = ibc.DockerImage{ Repository: DymensionMainRepo, Version: dymensionVersion, @@ -316,6 +318,14 @@ func GetDockerImageVersion() (dymensionVersion, rollappEVMVersion, rollappWasmVe return dymensionVersion, rollappEVMVersion, rollappWasmVersion } +func GetUpgradeName() (upgradeName string) { + upgradeName, found := os.LookupEnv("UPGRADE_NAME") + if !found { + upgradeName = "" + } + return upgradeName +} + func encodingConfig() *simappparams.EncodingConfig { cfg := cosmos.DefaultEncoding() diff --git a/tests/upgrade_hub_test.go b/tests/upgrade_hub_test.go new file mode 100644 index 00000000..db4d7801 --- /dev/null +++ b/tests/upgrade_hub_test.go @@ -0,0 +1,291 @@ +package tests + +import ( + "context" + "fmt" + "testing" + "time" + + test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" + + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +const ( + haltHeightDelta = uint64(20) + blocksAfterUpgrade = uint64(10) +) + +var ( + // baseChain is the current version of the chain that will be upgraded from + baseChain = ibc.DockerImage{ + Repository: "ghcr.io/dymensionxyz/dymension", + Version: "latest", + UidGid: "1025:1025", + } +) + +func TestHubUpgrade(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTime := "3s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 0 + numRollAppFn := 0 + numRollAppVals := 1 + + // Create chain factory with dymension + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{baseChain}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + // relayer for rollapp 1 + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + // relayer for rollapp 2 + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup().AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: false, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + // err = dymension.StopAllNodes(ctx) + // require.NoError(t, err) + + // path := "/home/ubuntu/genesis.json" + // state, err := os.ReadFile(path) + // require.NoError(t, err) + // for _, node := range dymension.Nodes() { + // err := node.OverwriteGenesisFile(ctx, state) + // require.NoError(t, err) + // } + + // for _, node := range dymension.Nodes() { + // _, _, err = node.ExecBin(ctx, "tendermint", "unsafe-reset-all") + // require.NoError(t, err) + // } + + // _ = dymension.StartAllNodes(ctx) + + //Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) + + // Get our Bech32 encoded user addresses + dymensionUser, _ := users[0], users[1] + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + // dymensionUser, rollappUser := users[0], users[1] + + // dymensionUserAddr := dymensionUser.FormattedAddress() + // rollappUserAddr := rollappUser.FormattedAddress() + + height, err := dymension.Height(ctx) + require.NoError(t, err, "error fetching height before submit upgrade proposal") + + haltHeight := height + haltHeightDelta + + proposal := cosmos.SoftwareUpgradeProposal{ + Deposit: "500000000000" + dymension.Config().Denom, // greater than min deposit + Title: "Chain Upgrade 1", + Name: upgradeName, + Description: "First chain software upgrade", + Height: haltHeight, + Info: "Info", + } + + upgradeTx, err := dymension.UpgradeLegacyProposal(ctx, dymensionUser.KeyName(), proposal) + require.NoError(t, err, "error submitting software upgrade proposal tx") + fmt.Println("upgradeTx", upgradeTx) + + err = dymension.VoteOnProposalAllValidators(ctx, upgradeTx.ProposalID, cosmos.ProposalVoteYes) + require.NoError(t, err, "failed to submit votes") + + _, err = cosmos.PollForProposalStatus(ctx, dymension.CosmosChain, height, haltHeight, upgradeTx.ProposalID, cosmos.ProposalStatusPassed) + prop, _ := dymension.QueryProposal(ctx, upgradeTx.ProposalID) + fmt.Println("prop: ", prop) + require.Equal(t, prop.Status, cosmos.ProposalStatusPassed) + require.NoError(t, err, "proposal status did not change to passed in expected number of blocks") + + timeoutCtx, timeoutCtxCancel := context.WithTimeout(ctx, time.Second*45) + defer timeoutCtxCancel() + + height, err = dymension.Height(ctx) + require.NoError(t, err, "error fetching height before upgrade") + + // this should timeout due to chain halt at upgrade height. + _ = testutil.WaitForBlocks(timeoutCtx, int(haltHeight-height)+1, dymension) + + height, err = dymension.Height(ctx) + require.NoError(t, err, "error fetching height after chain should have halted") + + // make sure that chain is halted + require.Equal(t, haltHeight, height, "height is not equal to halt height") + + // bring down nodes to prepare for upgrade + err = dymension.StopAllNodes(ctx) + require.NoError(t, err, "error stopping node(s)") + + // upgrade version on all nodes + dymension.UpgradeVersion(ctx, client, DymensionMainRepo, dymensionVersion) + + // start all nodes back up. + // validators reach consensus on first block after upgrade height + // and chain block production resumes. + err = dymension.StartAllNodes(ctx) + require.NoError(t, err, "error starting upgraded node(s)") + + timeoutCtx, timeoutCtxCancel = context.WithTimeout(ctx, time.Second*45) + defer timeoutCtxCancel() + + err = testutil.WaitForBlocks(timeoutCtx, int(blocksAfterUpgrade), dymension) + require.NoError(t, err, "chain did not produce blocks after upgrade") + + height, err = dymension.Height(ctx) + require.NoError(t, err, "error fetching height after upgrade") + + require.GreaterOrEqual(t, height, haltHeight+blocksAfterUpgrade, "height did not increment enough after upgrade") + + // channel, err := ibc.GetTransferChannel(ctx, r1, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + // require.NoError(t, err) + + // Compose an IBC transfer and send from dymension -> rollapp + // err = dymension.IBCTransfer(ctx, + // dymension, rollapp1, transferAmount, dymensionUserAddr, + // rollappUserAddr, r1, ibcPath, channel, + // eRep, ibc.TransferOptions{}) + // require.NoError(t, err) +} From 3ecc87f786d9a9dc473a345a03726bfeae21d6de Mon Sep 17 00:00:00 2001 From: nguyen | decentrio <144610611+trinitys7@users.noreply.github.com> Date: Fri, 17 May 2024 16:30:02 +0700 Subject: [PATCH 48/61] tests: add eibc AckError test (#142) Co-authored-by: anhductn2001 --- Makefile | 38 +- tests/eibc_ack_error_test.go | 2134 ++++++++++++++++++++++++++++++++++ tests_spec/eibc.md | 6 +- 3 files changed, 2171 insertions(+), 7 deletions(-) create mode 100644 tests/eibc_ack_error_test.go diff --git a/Makefile b/Makefile index 9ecd6791..93854820 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,15 @@ e2e-test-ibc-grace-period-evm: clean-e2e e2e-test-eibc-fulfillment-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_EVM . +e2e-test-eibc-ack-error-dym-evm: clean-e2e + cd tests && go test -timeout=30m -race -v -run TestEIBC_AckError_Dym_EVM . + +e2e-test-eibc-ack-error-ra-token-evm: clean-e2e + cd tests && go test -timeout=30m -race -v -run TestEIBC_AckError_RA_Token_EVM . + +e2e-test-eibc-ack-error-3rd-party-token-evm: clean-e2e + cd tests && go test -timeout=30m -race -v -run TestEIBC_AckError_3rd_Party_Token_EVM . + e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillment_ignore_hub_to_RA_EVM . @@ -132,6 +141,14 @@ e2e-test-ibc-success-wasm: clean-e2e e2e-test-ibc-timeout-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferTimeout_Wasm . +e2e-test-eibc-ack-error-dym-wasm: clean-e2e + cd tests && go test -timeout=30m -race -v -run TestEIBC_AckError_Dym_Wasm . + +e2e-test-eibc-ack-error-ra-token-wasm: clean-e2e + cd tests && go test -timeout=30m -race -v -run TestEIBC_AckError_RA_Token_Wasm . + +e2e-test-eibc-ack-error-3rd-party-token-wasm: clean-e2e + cd tests && go test -timeout=30m -race -v -run TestEIBC_AckError_3rd_Party_Token_Wasm . e2e-test-eibc-fulfillment-only-one-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCFulfillOnOneRollApp_Wasm . @@ -220,12 +237,15 @@ e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_hub_wasm: clean-e2 e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ e2e-test-ibc-grace-period-evm \ + e2e-test-eibc-ack-error-dym-evm \ + e2e-test-eibc-ack-error-ra-token-evm \ e2e-test-eibc-corrupted-memo-evm \ e2e-test-eibc-excessive-fee-evm \ e2e-test-eibc-fulfillment-evm \ - e2e-test-eibc-fulfillment-evm-2-RAs \ - e2e-test-eibc-fulfill-no-balance-evm \ + e2e-test-eibc-fulfillment-evm-2-RAs \ + e2e-test-eibc-fulfill-no-balance-evm \ e2e-test-eibc-fulfillment-thirdparty-evm \ + e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-evm \ e2e-test-eibc-invariant-evm \ e2e-test-eibc-pfm-evm \ e2e-test-eibc-timeout-evm \ @@ -245,9 +265,12 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ e2e-test-ibc-grace-period-wasm \ + e2e-test-eibc-ack-error-dym-wasm \ + e2e-test-eibc-ack-error-ra-token-wasm \ e2e-test-eibc-fulfillment-wasm \ e2e-test-eibc-fulfillment-thirdparty-wasm \ - e2e-test-eibc-invariant-wasm \ + e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm \ + e2e-test-eibc-invariant-wasm e2e-test-eibc-pfm-wasm \ e2e-test-transfer-multi-hop-wasm \ e2e-test-pfm-with-grace-period-wasm \ @@ -255,7 +278,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-batch-finalization-wasm \ e2e-test-disconnection-wasm \ e2e-test-rollapp-freeze-wasm \ - e2e-test-other-rollapp-not-affected-wasm \ + e2e-test-other-rollapp-not-affected-wasm \ e2e-test-dym-finalize-block-on-recv-packet \ e2e-test-dym-finalize-block-on-timeout-packet \ e2e-test-dym-finalize-block-on-ack-packet\ @@ -264,6 +287,7 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-upgrade-hub \ e2e-test-sequencer-invariant-wasm \ e2e-test-rollapp-invariant-wasm \ + e2e-test-delayedack-relayer-down-wasm \ e2e-test-rollapp-upgrade-non-state-breaking-wasm .PHONY: clean-e2e \ @@ -271,12 +295,15 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ e2e-test-ibc-grace-period-evm \ + e2e-test-eibc-ack-error-dym-evm \ + e2e-test-eibc-ack-error-ra-token-evm \ e2e-test-eibc-fulfillment-evm-2-RAs \ e2e-test-eibc-corrupted-memo-evm \ e2e-test-eibc-excessive-fee-evm \ e2e-test-eibc-fulfillment-evm \ e2e-test-eibc-fulfill-no-balance-evm \ e2e-test-eibc-fulfillment-thirdparty-evm \ + e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-evm \ e2e-test-eibc-invariant-evm \ e2e-test-eibc-pfm-evm \ e2e-test-eibc-timeout-evm \ @@ -296,8 +323,11 @@ e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-success-wasm \ e2e-test-ibc-timeout-wasm \ e2e-test-ibc-grace-period-wasm \ + e2e-test-eibc-ack-error-dym-wasm \ + e2e-test-eibc-ack-error-ra-token-wasm \ e2e-test-eibc-fulfillment-wasm \ e2e-test-eibc-fulfillment-thirdparty-wasm \ + e2e-test-eibc-fulfillment-ignore-hub-to-rollapp-wasm \ e2e-test-eibc-invariant-wasm \ e2e-test-eibc-pfm-wasm \ e2e-test-transfer-multi-hop-wasm \ diff --git a/tests/eibc_ack_error_test.go b/tests/eibc_ack_error_test.go new file mode 100644 index 00000000..aae1383e --- /dev/null +++ b/tests/eibc_ack_error_test.go @@ -0,0 +1,2134 @@ +package tests + +import ( + "bytes" + "context" + "fmt" + "testing" + + "cosmossdk.io/math" + transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" + test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +func TestEIBC_AckError_Dym_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTimeRollapp1 := "10s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTimeRollapp1) + + extraFlags := map[string]interface{}{"genesis-accounts-path": true} + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_2-1" + gas_price_rollapp2 := "0adym" + emptyBlocksMaxTimeRollapp2 := "1s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTimeRollapp2) + + // Custom dymension epoch for faster disconnection + modifyGenesisKV := append( + dymModifyGenesisKV, + []cosmos.GenesisKV{ + { + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + { + Key: "app_state.transfer.params.receive_enabled", + Value: false, + }, + }..., + ) + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_2-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Start both relayers + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + // Get dymension -> rollapp1 channel + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp1Dym := channsRollApp1[0] + require.NotEmpty(t, channRollApp1Dym.ChannelID) + channDymRollApp1 := channRollApp1Dym.Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + // Get dymension -> rollapp2 channel + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp2Dym := channsRollApp2[0] + require.NotEmpty(t, channRollApp2Dym.ChannelID) + channDymRollApp2 := channRollApp2Dym.Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + // Trigger genesis event for both rollapps + rollapps := []rollappParam{ + { + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, + { + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }, + } + + triggerHubGenesisEvent(t, dymension, rollapps...) + + // Get the IBC denom for adym on rollapp + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channDymRollApp1.PortID, channDymRollApp1.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + var options ibc.TransferOptions + + t.Run("Demand order is created upon AckError for dym", func(t *testing.T) { + // Transfer dymension from hub to rollapp + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferData, options) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: dymensionIBCDenom, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + ibcTx, err := rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + + balance, err := rollapp1.GetBalance(ctx, rollappUserAddr, dymensionIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of rollappUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + + // catch ACK errors + rollappHeight, err = rollapp1.Height(ctx) + require.NoError(t, err) + + ack, err := testutil.PollForAck(ctx, rollapp1, rollappHeight, rollappHeight+80, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that the ack contains error + require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + + // At the moment, the ack returned and the demand order status became "finalized" + // We will execute the ibc transfer again and try to fulfill the demand order + _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + require.Len(t, eibcEvents, 2) + fmt.Println("Event:", eibcEvents[1]) + require.Equal(t, eibcEvents[1].PacketStatus, "PENDING") + + // Get the balance of dymensionUserAddr and marketMakerAddr before fulfill the demand order + dymensionUserBalance, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + marketMakerBalance, err := dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) + require.NoError(t, err) + + // fulfill demand order + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr) + require.NoError(t, err) + fmt.Println(txhash) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + fmt.Println("Balance changed of dymensionUserAddr after fulfilling the order:", balance.Sub(dymensionUserBalance)) + require.True(t, balance.Sub(dymensionUserBalance).Equal(transferAmountWithoutFee), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance.Sub(dymensionUserBalance))) + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceDymDenom := marketMakerBalance.Sub((transferAmountWithoutFee)) + require.True(t, balance.Equal(expMmBalanceDymDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceDymDenom, balance)) + + // wait until packet finalization, mm balance should be the same due to the ack error + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + require.True(t, balance.Equal(expMmBalanceDymDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceDymDenom, balance)) + + // wait for a few blocks and check if the fund returns to rollapp + testutil.WaitForBlocks(ctx, 20, rollapp1) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + }) + + t.Cleanup( + func() { + err := r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTimeRollapp1 := "10s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTimeRollapp1) + + extraFlags := map[string]interface{}{"genesis-accounts-path": true} + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_2-1" + gas_price_rollapp2 := "0adym" + emptyBlocksMaxTimeRollapp2 := "1s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTimeRollapp2) + + // Custom dymension epoch for faster disconnection + modifyGenesisKV := append( + dymModifyGenesisKV, + []cosmos.GenesisKV{ + { + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + { + Key: "app_state.transfer.params.receive_enabled", + Value: false, + }, + }..., + ) + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_2-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Start both relayers + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + // Get dymension -> rollapp1 channel + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp1Dym := channsRollApp1[0] + require.NotEmpty(t, channRollApp1Dym.ChannelID) + channDymRollApp1 := channRollApp1Dym.Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + // Get dymension -> rollapp2 channel + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp2Dym := channsRollApp2[0] + require.NotEmpty(t, channRollApp2Dym.ChannelID) + channDymRollApp2 := channRollApp2Dym.Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + // Trigger genesis event for both rollapps + rollapps := []rollappParam{ + { + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, + { + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }, + } + + triggerHubGenesisEvent(t, dymension, rollapps...) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channRollApp1Dym.PortID, channRollApp1Dym.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + var options ibc.TransferOptions + + t.Run("Demand order is created upon AckError for rollapp token", func(t *testing.T) { + transferData := ibc.WalletData{ + Address: marketMakerAddr, + Denom: rollappIBCDenom, + Amount: transferAmount, + } + + // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order + err = dymension.Validators[0].SendFunds(ctx, "validator", transferData) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, rollappIBCDenom, transferAmount) + // end of preconditions + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + ibcTx, err := rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + + balance, err := dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + + // catch ACK errors + rollapp1Height, err := rollapp1.Height(ctx) + require.NoError(t, err) + + ack, err := testutil.PollForAck(ctx, rollapp1, rollapp1Height, rollapp1Height+30, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that the ack contains error + require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + // At the moment, the ack returned and the demand order status became "finalized" + // We will execute the ibc transfer again and try to fulfill the demand order + _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + require.Len(t, eibcEvents, 2) + fmt.Println("Event:", eibcEvents[1]) + require.Equal(t, eibcEvents[1].PacketStatus, "PENDING") + + // fulfill demand order + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr) + require.NoError(t, err) + fmt.Println(txhash) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmountWithoutFee), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom := transferAmount.Sub((transferAmountWithoutFee)) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // wait until packet finalization, mm balance should be the same due to the ack error + rollappHeight, err := rollapp1.Height(ctx) + require.NoError(t, err) + + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // wait for a few blocks and check if the fund returns to rollapp + testutil.WaitForBlocks(ctx, 20, rollapp1) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + }) +} + +func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTimeRollapp1 := "10s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTimeRollapp1) + + extraFlags := map[string]interface{}{"genesis-accounts-path": true} + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_2-1" + gas_price_rollapp2 := "0adym" + emptyBlocksMaxTimeRollapp2 := "1s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTimeRollapp2) + + // Custom dymension epoch for faster disconnection + modifyGenesisKV := append( + dymModifyGenesisKV, + []cosmos.GenesisKV{ + { + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + { + Key: "app_state.transfer.params.receive_enabled", + Value: false, + }, + }..., + ) + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_2-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Start both relayers + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, rollapp2) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollapp1User, rollapp2User := users[0], users[1], users[2], users[3] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollapp1UserAddr := rollapp1User.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, rollapp2.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + // Get dymension -> rollapp1 channel + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp1Dym := channsRollApp1[0] + require.NotEmpty(t, channRollApp1Dym.ChannelID) + channDymRollApp1 := channRollApp1Dym.Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + // Get dymension -> rollapp2 channel + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp2Dym := channsRollApp2[0] + require.NotEmpty(t, channRollApp2Dym.ChannelID) + channDymRollApp2 := channRollApp2Dym.Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + // Trigger genesis event for both rollapps + rollapps := []rollappParam{ + { + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, + { + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }, + } + + triggerHubGenesisEvent(t, dymension, rollapps...) + + // Get the IBC denom for rollapp 2 urax on Hub + rollapp2TokenDenom := transfertypes.GetPrefixedDenom(channDymRollApp2.PortID, channDymRollApp2.ChannelID, rollapp2.Config().Denom) + thirdPartyDenom := transfertypes.ParseDenomTrace(rollapp2TokenDenom).IBCDenom() + thirdPartyIBCDenomOnRA := transfertypes.ParseDenomTrace( + fmt.Sprintf("%s/%s/%s/%s/%s", + channRollApp1Dym.PortID, + channRollApp1Dym.ChannelID, + channDymRollApp2.PortID, + channDymRollApp2.ChannelID, + rollapp2.Config().Denom, + ), + ).IBCDenom() + + var options ibc.TransferOptions + + t.Run("Demand order is created upon AckError for rollapp token", func(t *testing.T) { + transferData := ibc.WalletData{ + Address: marketMakerAddr, + Denom: thirdPartyDenom, + Amount: transferAmount, + } + + // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order + err = dymension.Validators[0].SendFunds(ctx, "validator", transferData) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, thirdPartyDenom, transferAmount) + // user from rollapp1 should have funds to be able to make the ibc transfer transaction + transferData = ibc.WalletData{ + Address: rollapp1UserAddr, + Denom: thirdPartyDenom, + Amount: transferAmount, + } + + _, err = dymension.Validators[0].SendIBCTransfer(ctx, channDymRollApp1.ChannelID, "validator", transferData, options) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, thirdPartyIBCDenomOnRA, transferAmount) + // end of preconditions + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: thirdPartyIBCDenomOnRA, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + ibcTx, err := rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, options) + require.NoError(t, err) + + balance, err := dymension.GetBalance(ctx, dymensionUserAddr, thirdPartyDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + + // catch ACK errors + rollapp1Height, err := rollapp1.Height(ctx) + require.NoError(t, err) + + ack, err := testutil.PollForAck(ctx, rollapp1, rollapp1Height, rollapp1Height+30, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that the ack contains error + require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, thirdPartyIBCDenomOnRA, transferAmount) + + // At the moment, the ack returned and the demand order status became "finalized" + // We will execute the ibc transfer again and try to fulfill the demand order + _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, options) + require.NoError(t, err) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + require.Len(t, eibcEvents, 2) + fmt.Println("Event:", eibcEvents[1]) + require.Equal(t, eibcEvents[1].PacketStatus, "PENDING") + + // fulfill demand order + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr) + require.NoError(t, err) + fmt.Println(txhash) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, thirdPartyDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmountWithoutFee), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, thirdPartyDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom := transferAmount.Sub((transferAmountWithoutFee)) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // wait until packet finalization, mm balance should be the same due to the ack error + rollappHeight, err = rollapp1.Height(ctx) + require.NoError(t, err) + + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, thirdPartyDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // wait for a few blocks and check if the fund returns to rollapp + testutil.WaitForBlocks(ctx, 20, rollapp1) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) + }) +} + +func TestEIBC_AckError_Dym_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTimeRollapp1 := "10s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTimeRollapp1) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_2-1" + gas_price_rollapp2 := "0adym" + emptyBlocksMaxTimeRollapp2 := "1s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTimeRollapp2) + + // Custom dymension epoch for faster disconnection + modifyGenesisKV := append( + dymModifyGenesisKV, + []cosmos.GenesisKV{ + { + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + { + Key: "app_state.transfer.params.receive_enabled", + Value: false, + }, + }..., + ) + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_2-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Start both relayers + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + // Get dymension -> rollapp1 channel + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp1Dym := channsRollApp1[0] + require.NotEmpty(t, channRollApp1Dym.ChannelID) + channDymRollApp1 := channRollApp1Dym.Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + // Get dymension -> rollapp2 channel + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp2Dym := channsRollApp2[0] + require.NotEmpty(t, channRollApp2Dym.ChannelID) + channDymRollApp2 := channRollApp2Dym.Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + // Trigger genesis event for both rollapps + rollapps := []rollappParam{ + { + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, + { + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }, + } + + triggerHubGenesisEvent(t, dymension, rollapps...) + + // Get the IBC denom for adym on rollapp + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channDymRollApp1.PortID, channDymRollApp1.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + var options ibc.TransferOptions + + t.Run("Demand order is created upon AckError for dym", func(t *testing.T) { + // Transfer dymension from hub to rollapp + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferData, options) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: dymensionIBCDenom, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + ibcTx, err := rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + + balance, err := rollapp1.GetBalance(ctx, rollappUserAddr, dymensionIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of rollappUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + + // catch ACK errors + rollappHeight, err = rollapp1.Height(ctx) + require.NoError(t, err) + + ack, err := testutil.PollForAck(ctx, rollapp1, rollappHeight, rollappHeight+80, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that the ack contains error + require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + + // At the moment, the ack returned and the demand order status became "finalized" + // We will execute the ibc transfer again and try to fulfill the demand order + _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + require.Len(t, eibcEvents, 2) + fmt.Println("Event:", eibcEvents[1]) + require.Equal(t, eibcEvents[1].PacketStatus, "PENDING") + + // Get the balance of dymensionUserAddr and marketMakerAddr before fulfill the demand order + dymensionUserBalance, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + marketMakerBalance, err := dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) + require.NoError(t, err) + + // fulfill demand order + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr) + require.NoError(t, err) + fmt.Println(txhash) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + fmt.Println("Balance changed of dymensionUserAddr after fulfilling the order:", balance.Sub(dymensionUserBalance)) + require.True(t, balance.Sub(dymensionUserBalance).Equal(transferAmountWithoutFee), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance.Sub(dymensionUserBalance))) + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceDymDenom := marketMakerBalance.Sub((transferAmountWithoutFee)) + require.True(t, balance.Equal(expMmBalanceDymDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceDymDenom, balance)) + + // wait until packet finalization, mm balance should be the same due to the ack error + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + require.True(t, balance.Equal(expMmBalanceDymDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceDymDenom, balance)) + + // wait for a few blocks and check if the fund returns to rollapp + testutil.WaitForBlocks(ctx, 20, rollapp1) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + }) + + t.Cleanup( + func() { + err := r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTimeRollapp1 := "10s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTimeRollapp1) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_2-1" + gas_price_rollapp2 := "0adym" + emptyBlocksMaxTimeRollapp2 := "1s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTimeRollapp2) + + // Custom dymension epoch for faster disconnection + modifyGenesisKV := append( + dymModifyGenesisKV, + []cosmos.GenesisKV{ + { + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + { + Key: "app_state.transfer.params.receive_enabled", + Value: false, + }, + }..., + ) + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_2-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Start both relayers + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollappUser := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + // Get dymension -> rollapp1 channel + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp1Dym := channsRollApp1[0] + require.NotEmpty(t, channRollApp1Dym.ChannelID) + channDymRollApp1 := channRollApp1Dym.Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + // Get dymension -> rollapp2 channel + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp2Dym := channsRollApp2[0] + require.NotEmpty(t, channRollApp2Dym.ChannelID) + channDymRollApp2 := channRollApp2Dym.Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + // Trigger genesis event for both rollapps + rollapps := []rollappParam{ + { + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, + { + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }, + } + + triggerHubGenesisEvent(t, dymension, rollapps...) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channRollApp1Dym.PortID, channRollApp1Dym.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + var options ibc.TransferOptions + + t.Run("Demand order is created upon AckError for rollapp token", func(t *testing.T) { + transferData := ibc.WalletData{ + Address: marketMakerAddr, + Denom: rollappIBCDenom, + Amount: transferAmount, + } + + // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order + err = dymension.Validators[0].SendFunds(ctx, "validator", transferData) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, rollappIBCDenom, transferAmount) + // end of preconditions + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + ibcTx, err := rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + + balance, err := dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + + // catch ACK errors + rollapp1Height, err := rollapp1.Height(ctx) + require.NoError(t, err) + + ack, err := testutil.PollForAck(ctx, rollapp1, rollapp1Height, rollapp1Height+30, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that the ack contains error + require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + + // At the moment, the ack returned and the demand order status became "finalized" + // We will execute the ibc transfer again and try to fulfill the demand order + _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, options) + require.NoError(t, err) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + require.Len(t, eibcEvents, 2) + fmt.Println("Event:", eibcEvents[1]) + require.Equal(t, eibcEvents[1].PacketStatus, "PENDING") + + // fulfill demand order + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr) + require.NoError(t, err) + fmt.Println(txhash) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmountWithoutFee), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom := transferAmount.Sub((transferAmountWithoutFee)) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // wait until packet finalization, mm balance should be the same due to the ack error + rollappHeight, err := rollapp1.Height(ctx) + require.NoError(t, err) + + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // wait for a few blocks and check if the fund returns to rollapp + testutil.WaitForBlocks(ctx, 20, rollapp1) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + }) +} + +func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1-1" + gas_price_rollapp1 := "0adym" + emptyBlocksMaxTimeRollapp1 := "10s" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTimeRollapp1) + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_2-1" + gas_price_rollapp2 := "0adym" + emptyBlocksMaxTimeRollapp2 := "1s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTimeRollapp2) + + // Custom dymension epoch for faster disconnection + modifyGenesisKV := append( + dymModifyGenesisKV, + []cosmos.GenesisKV{ + { + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + { + Key: "app_state.transfer.params.receive_enabled", + Value: false, + }, + }..., + ) + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_2-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r1, "relayer1"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r1, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Start both relayers + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, rollapp2) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Get our Bech32 encoded user addresses + dymensionUser, marketMaker, rollapp1User, rollapp2User := users[0], users[1], users[2], users[3] + + dymensionUserAddr := dymensionUser.FormattedAddress() + marketMakerAddr := marketMaker.FormattedAddress() + rollapp1UserAddr := rollapp1User.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, rollapp2.Config().Denom, walletAmount) + + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + + // Get dymension -> rollapp1 channel + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp1Dym := channsRollApp1[0] + require.NotEmpty(t, channRollApp1Dym.ChannelID) + channDymRollApp1 := channRollApp1Dym.Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + // Get dymension -> rollapp2 channel + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp2Dym := channsRollApp2[0] + require.NotEmpty(t, channRollApp2Dym.ChannelID) + channDymRollApp2 := channRollApp2Dym.Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + // Trigger genesis event for both rollapps + rollapps := []rollappParam{ + { + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, + { + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }, + } + + triggerHubGenesisEvent(t, dymension, rollapps...) + + // Get the IBC denom for rollapp 2 urax on Hub + rollapp2TokenDenom := transfertypes.GetPrefixedDenom(channDymRollApp2.PortID, channDymRollApp2.ChannelID, rollapp2.Config().Denom) + thirdPartyDenom := transfertypes.ParseDenomTrace(rollapp2TokenDenom).IBCDenom() + thirdPartyIBCDenomOnRA := transfertypes.ParseDenomTrace( + fmt.Sprintf("%s/%s/%s/%s/%s", + channRollApp1Dym.PortID, + channRollApp1Dym.ChannelID, + channDymRollApp2.PortID, + channDymRollApp2.ChannelID, + rollapp2.Config().Denom, + ), + ).IBCDenom() + + var options ibc.TransferOptions + + t.Run("Demand order is created upon AckError for rollapp token", func(t *testing.T) { + transferData := ibc.WalletData{ + Address: marketMakerAddr, + Denom: thirdPartyDenom, + Amount: transferAmount, + } + + // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order + err = dymension.Validators[0].SendFunds(ctx, "validator", transferData) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, thirdPartyDenom, transferAmount) + // user from rollapp1 should have funds to be able to make the ibc transfer transaction + transferData = ibc.WalletData{ + Address: rollapp1UserAddr, + Denom: thirdPartyDenom, + Amount: transferAmount, + } + + _, err = dymension.Validators[0].SendIBCTransfer(ctx, channDymRollApp1.ChannelID, "validator", transferData, options) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, thirdPartyIBCDenomOnRA, transferAmount) + // end of preconditions + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: thirdPartyIBCDenomOnRA, + Amount: transferAmount, + } + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + ibcTx, err := rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, options) + require.NoError(t, err) + + balance, err := dymension.GetBalance(ctx, dymensionUserAddr, thirdPartyDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + + // catch ACK errors + rollapp1Height, err := rollapp1.Height(ctx) + require.NoError(t, err) + + ack, err := testutil.PollForAck(ctx, rollapp1, rollapp1Height, rollapp1Height+30, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that the ack contains error + require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, thirdPartyIBCDenomOnRA, transferAmount) + + // At the moment, the ack returned and the demand order status became "finalized" + // We will execute the ibc transfer again and try to fulfill the demand order + _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, options) + require.NoError(t, err) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + require.Len(t, eibcEvents, 2) + fmt.Println("Event:", eibcEvents[1]) + require.Equal(t, eibcEvents[1].PacketStatus, "PENDING") + + // fulfill demand order + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr) + require.NoError(t, err) + fmt.Println(txhash) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, thirdPartyDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmountWithoutFee), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMakerAddr, thirdPartyDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom := transferAmount.Sub((transferAmountWithoutFee)) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // wait until packet finalization, mm balance should be the same due to the ack error + rollappHeight, err = rollapp1.Height(ctx) + require.NoError(t, err) + + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, thirdPartyDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) + require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + + // wait for a few blocks and check if the fund returns to rollapp + testutil.WaitForBlocks(ctx, 20, rollapp1) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount) + }) +} diff --git a/tests_spec/eibc.md b/tests_spec/eibc.md index a964c06f..37554211 100644 --- a/tests_spec/eibc.md +++ b/tests_spec/eibc.md @@ -8,9 +8,9 @@ | 4 | DYM ibc transfer timeout | Same as the case above | ✅ |
  • send **dym** from dymension to rollapp
  • set minimum packet timeout (i.e. 1ms) so that the packet is not relayed before it is picked by a relayer
  • sender should get funds back after grace period.
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
  • demand order is created with correct ibc denom and fee
  • demand order can get fulfilled
  • upon timeout the funds should go to the fulfiller
| | [TestIBCTransferTimeout_EVM](../tests/ibc_timeout_test.go#25) [TestIBCTransferTimeout_Wasm](../tests/ibc_timeout_test.go#256) | | 5 | Rollapp token ibc-transfer timeout | Same as the case above | ✅ |
  • send rollapp IBC denom from dymension to rollapp
  • Same as the case above
| | [TestIBCTransferTimeout_EVM](../tests/ibc_timeout_test.go#25) [TestIBCTransferTimeout_Wasm](../tests/ibc_timeout_test.go#256) | | 6 | 3rd party token Demand order is created upon timeout and fulfilled | Same as the case above | ✅ |
  • send 3rd party IBC denom from dymension to rollapp
  • the amount returned should be smaller by a 0.15% fee
  • market maker is able to fulfill it
  • no packet commitment left on the rollapp (i.e ack recieved). can be queries using the cli rollapp-evm q ibc channel packet-commitments transfer
  • upon timeout the funds should go to the fulfiller
| ✅ | [TestEIBCTimeoutAndFulFillDymToRollapp](../tests/eibc_timeout_test.go#L266) | -| 7 | Demand order is created upon AckError for dym |
  • IBC which exists on the evm-rollapp but doesn’t have erc20
  • At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id.
| 🛑
(missing) |
  • send the DYM token from hub to rollapp
  • fulfiller the order with the IBC denom
  • ack error returned from the rollapp
  • eibc ack error demand order is created with correct denom and correct data
  • eibc managed to get fulfilled
  • upon ack error the funds should go to the fulfiller
| 🛑
(missing) | TO DO | -| 8 | Demand order is created upon AckError for 3rd party token | Same as the case above | 🛑
(missing) |
  • send the ibc token from hub to rollapp
  • Same as the case above
| 🛑
(missing) | TO DO | -| 9 | Demand order is created upon AckError for rollapp token | Same as the case above | 🛑
(missing) |
  • send the ibc token from hub to rollapp
  • Same as the case above
| 🛑
(missing) | TO DO | +| 7 | Demand order is created upon AckError for dym |
  • IBC which exists on the evm-rollapp but doesn’t have erc20
  • At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id.
| ✅ |
  • send the DYM token from hub to rollapp
  • fulfiller the order with the IBC denom
  • ack error returned from the rollapp
  • eibc ack error demand order is created with correct denom and correct data
  • eibc managed to get fulfilled
  • upon ack error the funds should go to the fulfiller
| ✅ | [TestEIBC_AckError_Dym_EVM](../tests/eibc_ack_error_test.go#L23) [TestEIBC_AckError_Dym_Wasm](../tests/eibc_ack_error_test.go#L1083) | +| 8 | Demand order is created upon AckError for 3rd party token | Same as the case above | ✅ |
  • send the ibc token from hub to rollapp
  • Same as the case above
| ✅ | [TestEIBC_AckError_3rd_Party_Token_EVM](../tests/eibc_ack_error_test.go#L716) [TestEIBC_AckError_3rd_Party_Token_Wasm](../tests/eibc_ack_error_test.go#L1771) | +| 9 | Demand order is created upon AckError for rollapp token | Same as the case above | ✅ |
  • send the ibc token from hub to rollapp
  • Same as the case above
| ✅ | [TestEIBC_AckError_RA_Token_EVM](../tests/eibc_ack_error_test.go#L382) [TestEIBC_AckError_RA_Token_Wasm](../tests/eibc_ack_error_test.go#L1072) | | 10 | eibc shouldn’t work together with PFM | At least 2 rollapps running, Rollapp A and B. Rollapp B is at finalized height < Rollapp A finalized height. Rollapp B has a channel-id different from the hub-channel-id.| ✅| Try to send RAX from rollapp to Dymension:
  • with both eibc and forward objects in memo.
  • Forward object could specify an address
The transfer should not be successful and RAX should be returned to rollapp’s wallet| ✅ | [TestEIBCPFM_EVM](../tests/eibc_pfm_test.go#26) [TestEIBCPFM_Wasm](../tests/eibc_pfm_test.go#303) | | 11 | Demand order fulfillment | eIBC pending order on the hub | ✅ |
  • fulfill the eIBC order
  • IBC Amount goes to the fulfiller upon finalization
  • Amount - Fee goes to the user
| ✅ | [TestEIBCFulfillment_EVM](../tests/ibc_grace_period_test.go#28) [TestEIBCFulfillment_Wasm](../tests/eibc_fulfillment_test.go#322) | | 12 | Demand order not fulfillment | eIBC pending order on the hub | ✅ |
  • don’t fulfill the eIBC demand order
  • user gets the entire amount upon grace period
| ✅ | [TestEIBCNotFulfillment_EVM](../tests/eibc_not_fulfillment_test.go#L25) [TestEIBCNotFulfillment_Wasm](../tests/eibc_not_fulfillment_test.go#L285) | From c8bd78f37f7b539f80d1bbc9a77d77b582f69049 Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Sat, 18 May 2024 16:46:08 +0700 Subject: [PATCH 49/61] fix: unstable CI tests (#173) --- Makefile | 4 ++-- tests/eibc_timeout_test.go | 2 +- tests/ibc_pfm_with_grace_period_test.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 93854820..956612cd 100644 --- a/Makefile +++ b/Makefile @@ -168,10 +168,10 @@ e2e-test-pfm-with-grace-period-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCPFMWithGracePeriod_Wasm . e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-erc20: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestIBCPFM_RollApp1ToRollApp2WithErc20_EVM . + cd tests && go test -timeout=25m -race -v -run TestIBCPFM_RollApp1To2WithErc20_EVM . e2e-test-pfm-with-grace-period-rollapp1-to-rollapp2-without-erc20: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestIBCPFM_RollApp1ToRollApp2WithOutErc20_Wasm . + cd tests && go test -timeout=25m -race -v -run TestIBCPFM_RollApp1To2WithOutErc20_Wasm . e2e-test-batch-finalization-wasm: cd tests && go test -timeout=25m -race -v -run TestBatchFinalization_Wasm . diff --git a/tests/eibc_timeout_test.go b/tests/eibc_timeout_test.go index b98f3e82..44902209 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -950,7 +950,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { // According to delayedack module, we need the rollapp to have finalizedHeight > ibcClientLatestHeight // in order to trigger ibc timeout or else it will trigger callback - err = testutil.WaitForBlocks(ctx, 1, dymension, rollapp1) + err = testutil.WaitForBlocks(ctx, 2, dymension, rollapp1) require.NoError(t, err) // get eibc event diff --git a/tests/ibc_pfm_with_grace_period_test.go b/tests/ibc_pfm_with_grace_period_test.go index c76fcc8b..f0adc07f 100644 --- a/tests/ibc_pfm_with_grace_period_test.go +++ b/tests/ibc_pfm_with_grace_period_test.go @@ -603,7 +603,7 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { } // PFM with grace period rollApp1 to rollApp2 with Erc20 registed on rollApp2 -func TestIBCPFM_RollApp1ToRollApp2WithErc20_EVM(t *testing.T) { +func TestIBCPFM_RollApp1To2WithErc20_EVM(t *testing.T) { if testing.Short() { t.Skip() } @@ -945,7 +945,7 @@ func TestIBCPFM_RollApp1ToRollApp2WithErc20_EVM(t *testing.T) { require.Equal(t, 0, len(resp.Commitments)) } -func TestIBCPFM_RollApp1ToRollApp2WithOutErc20_Wasm(t *testing.T) { +func TestIBCPFM_RollApp1To2WithOutErc20_Wasm(t *testing.T) { if testing.Short() { t.Skip() } From 1d23511d80e2e280a8f50ac6974733f7769063ae Mon Sep 17 00:00:00 2001 From: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Date: Mon, 20 May 2024 10:50:13 +0700 Subject: [PATCH 50/61] rollapp upgrade: add test for upgrade which requires migration (#177) --- .../e2e-test-hub-upgrade-workflow-call.yml | 2 +- ...test-rollapp-evm-upgrade-workflow-call.yml | 48 ++ ...est-rollapp-wasm-upgrade-workflow-call.yml | 48 ++ Makefile | 6 + tests/ibc_finalize_block_test.go | 8 +- tests/ibc_transfer_test.go | 4 +- tests/rollapp_upgrade_test.go | 506 +++++++++++++++++- tests/setup.go | 14 +- tests_spec/rollapp_upgrade.md | 2 +- 9 files changed, 625 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/e2e-test-rollapp-evm-upgrade-workflow-call.yml create mode 100644 .github/workflows/e2e-test-rollapp-wasm-upgrade-workflow-call.yml diff --git a/.github/workflows/e2e-test-hub-upgrade-workflow-call.yml b/.github/workflows/e2e-test-hub-upgrade-workflow-call.yml index a6a847f2..85e6ba4a 100644 --- a/.github/workflows/e2e-test-hub-upgrade-workflow-call.yml +++ b/.github/workflows/e2e-test-hub-upgrade-workflow-call.yml @@ -41,7 +41,7 @@ jobs: docker image load -i /tmp/e2e.tar docker image ls -a - - name: Rollapp-EVM E2E Tests + - name: Upgrade Hub E2E Tests run: make ${{ matrix.tests }} env: DYMENSION_CI: ${{ inputs.dymension_ci }} diff --git a/.github/workflows/e2e-test-rollapp-evm-upgrade-workflow-call.yml b/.github/workflows/e2e-test-rollapp-evm-upgrade-workflow-call.yml new file mode 100644 index 00000000..eca2e2bb --- /dev/null +++ b/.github/workflows/e2e-test-rollapp-evm-upgrade-workflow-call.yml @@ -0,0 +1,48 @@ +on: + workflow_call: + inputs: + rollapp_evm_ci: + description: "CI run on Rollapp-EVM Repo" + required: false + type: string + default: "latest" + upgrade_name: + description: "Upgrade Name be used by e2e-tests" + required: true + type: string + default: "" + +jobs: + # e2e-tests-by runs the actual go test command to trigger the test. + rollapp-evm-upgrade: + strategy: + matrix: + tests: + - "e2e-test-rollapp-upgrade-evm" + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: dymensionxyz/e2e-tests + - name: Set up Go 1.21 + uses: actions/setup-go@v4 + with: + go-version: "1.21.4" + + - name: Download Tarball Artifact + uses: actions/download-artifact@v3 + with: + name: e2e + path: /tmp + + - name: Load Docker Image + run: | + docker image load -i /tmp/e2e.tar + docker image ls -a + + - name: Rollapp-EVM Upgrade E2E Tests + run: make ${{ matrix.tests }} + env: + DYMENSION_CI: ${{ inputs.rollapp_evm_ci }} + UPGRADE_ROLAPP_EVM_NAME: ${{ inputs.upgrade_name }} \ No newline at end of file diff --git a/.github/workflows/e2e-test-rollapp-wasm-upgrade-workflow-call.yml b/.github/workflows/e2e-test-rollapp-wasm-upgrade-workflow-call.yml new file mode 100644 index 00000000..455ee17b --- /dev/null +++ b/.github/workflows/e2e-test-rollapp-wasm-upgrade-workflow-call.yml @@ -0,0 +1,48 @@ +on: + workflow_call: + inputs: + rollapp_wasm_ci: + description: "CI run on Rollapp-Wasm Repo" + required: false + type: string + default: "latest" + upgrade_name: + description: "Upgrade Name be used by e2e-tests" + required: false + type: string + default: "" + +jobs: + # e2e-tests-by runs the actual go test command to trigger the test. + rollapp-wasm-upgrade: + strategy: + matrix: + tests: + - "e2e-test-rollapp-upgrade-wasm" + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: dymensionxyz/e2e-tests + - name: Set up Go 1.21 + uses: actions/setup-go@v4 + with: + go-version: "1.21.4" + + - name: Download Tarball Artifact + uses: actions/download-artifact@v3 + with: + name: e2e + path: /tmp + + - name: Load Docker Image + run: | + docker image load -i /tmp/e2e.tar + docker image ls -a + + - name: Rollapp-Wasm Upgrade E2E Tests + run: make ${{ matrix.tests }} + env: + DYMENSION_CI: ${{ inputs.rollapp_wasm_ci }} + UPGRADE_ROLAPP_WASM_NAME: ${{ inputs.upgrade_name }} \ No newline at end of file diff --git a/Makefile b/Makefile index 956612cd..45ff3642 100644 --- a/Makefile +++ b/Makefile @@ -128,6 +128,9 @@ e2e-test-erc20-hub-to-rollapp-without-register: clean-e2e e2e-test-rollapp-upgrade-non-state-breaking-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollappUpgradeNonStateBreaking_EVM . +e2e-test-rollapp-upgrade-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestRollapp_EVM_Upgrade . + e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_rollapp_evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestTransferRollAppTriggerGenesis_EVM . @@ -233,6 +236,9 @@ e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_rollapp_wasm: clea e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_hub_wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollAppTransferHubTriggerGenesis_Wasm . +e2e-test-rollapp-upgrade-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestRollapp_Wasm_Upgrade . + # Executes all tests via rollup-e2e-testing e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ diff --git a/tests/ibc_finalize_block_test.go b/tests/ibc_finalize_block_test.go index 83b5c5e3..8970bc15 100644 --- a/tests/ibc_finalize_block_test.go +++ b/tests/ibc_finalize_block_test.go @@ -197,7 +197,7 @@ func TestDymFinalizeBlock_OnAckPacket_EVM(t *testing.T) { configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) // Create chain factory with dymension - numHubVals := 2 + numHubVals := 1 numHubFullNodes := 1 numRollAppFn := 0 numRollAppVals := 1 @@ -378,7 +378,7 @@ func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) // Create chain factory with dymension - numHubVals := 2 + numHubVals := 1 numHubFullNodes := 1 numRollAppFn := 0 numRollAppVals := 1 @@ -703,7 +703,7 @@ func TestDymFinalizeBlock_OnAckPacket_Wasm(t *testing.T) { configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) // Create chain factory with dymension - numHubVals := 2 + numHubVals := 1 numHubFullNodes := 1 numRollAppFn := 0 numRollAppVals := 1 @@ -885,7 +885,7 @@ func TestDymFinalizeBlock_OnTimeOutPacket_Wasm(t *testing.T) { configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) // Create chain factory with dymension - numHubVals := 2 + numHubVals := 1 numHubFullNodes := 1 numRollAppFn := 0 numRollAppVals := 1 diff --git a/tests/ibc_transfer_test.go b/tests/ibc_transfer_test.go index c1071c04..67deb63b 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -36,7 +36,7 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension - numHubVals := 2 + numHubVals := 1 numHubFullNodes := 1 numRollAppFn := 0 numRollAppVals := 1 @@ -221,7 +221,7 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension - numHubVals := 2 + numHubVals := 1 numHubFullNodes := 1 numRollAppFn := 0 numRollAppVals := 1 diff --git a/tests/rollapp_upgrade_test.go b/tests/rollapp_upgrade_test.go index 52b36892..ca9d65f2 100644 --- a/tests/rollapp_upgrade_test.go +++ b/tests/rollapp_upgrade_test.go @@ -4,9 +4,11 @@ import ( "context" "fmt" "testing" + "time" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" @@ -35,7 +37,7 @@ func TestRollappUpgradeNonStateBreaking_EVM(t *testing.T) { configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension - numHubVals := 2 + numHubVals := 1 numHubFullNodes := 1 numRollAppFn := 0 numRollAppVals := 1 @@ -234,7 +236,7 @@ func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension - numHubVals := 2 + numHubVals := 1 numHubFullNodes := 1 numRollAppFn := 0 numRollAppVals := 1 @@ -415,3 +417,503 @@ func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount) } + +func TestRollapp_EVM_Upgrade(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + preUpgradeRollappEVMImage := ibc.DockerImage{ + Repository: "ghcr.io/dymensionxyz/rollapp-evm", + Version: "latest", + UidGid: "1025:1025", + } + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{preUpgradeRollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + height, err := rollapp1.Height(ctx) + require.NoError(t, err, "error fetching height before submit upgrade proposal") + + haltHeight := height + haltHeightDelta + + proposal := cosmos.SoftwareUpgradeProposal{ + Deposit: "500000000000" + rollapp1.Config().Denom, // greater than min deposit + Title: "Rollapp Upgrade 1", + Name: upgradeEVMName, + Description: "First software upgrade", + Height: haltHeight, + Info: "Info", + } + + upgradeTx, err := rollapp1.UpgradeLegacyProposal(ctx, rollappUser.KeyName(), proposal) + require.NoError(t, err, "error submitting software upgrade proposal tx") + fmt.Println("upgradeTx", upgradeTx) + + err = rollapp1.VoteOnProposalAllValidators(ctx, upgradeTx.ProposalID, cosmos.ProposalVoteYes) + require.NoError(t, err, "failed to submit votes") + + _, err = cosmos.PollForProposalStatus(ctx, rollapp1.CosmosChain, height, haltHeight, upgradeTx.ProposalID, cosmos.ProposalStatusPassed) + prop, _ := rollapp1.QueryProposal(ctx, upgradeTx.ProposalID) + fmt.Println("prop: ", prop) + require.Equal(t, prop.Status, cosmos.ProposalStatusPassed) + require.NoError(t, err, "proposal status did not change to passed in expected number of blocks") + + timeoutCtx, timeoutCtxCancel := context.WithTimeout(ctx, time.Second*45) + defer timeoutCtxCancel() + + height, err = rollapp1.Height(ctx) + require.NoError(t, err, "error fetching height before upgrade") + + // this should timeout due to chain halt at upgrade height. + _ = testutil.WaitForBlocks(timeoutCtx, int(haltHeight-height)+1, rollapp1) + + // bring down nodes to prepare for upgrade + err = rollapp1.StopAllNodes(ctx) + require.NoError(t, err, "error stopping node(s)") + + // upgrade version on all nodes + rollapp1.UpgradeVersion(ctx, client, RollappEVMMainRepo, rollappEVMVersion) + + // start all nodes back up. + // validators reach consensus on first block after upgrade height + // and chain block production resumes. + err = rollapp1.StartAllNodes(ctx) + require.NoError(t, err, "error starting upgraded node(s)") + + timeoutCtx, timeoutCtxCancel = context.WithTimeout(ctx, time.Second*45) + defer timeoutCtxCancel() + + err = testutil.WaitForBlocks(timeoutCtx, int(blocksAfterUpgrade), rollapp1) + require.NoError(t, err, "chain did not produce blocks after upgrade") + + height, err = rollapp1.Height(ctx) + require.NoError(t, err, "error fetching height after upgrade") + + require.GreaterOrEqual(t, height, haltHeight+blocksAfterUpgrade, "height did not increment enough after upgrade") + + // Compose an IBC transfer and send from dymension -> rollapp + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from Hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + err = r.StopRelayer(ctx, eRep) + require.NoError(t, err) + + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // Assert funds were returned to the sender after the timeout has occured + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount) +} + +func TestRollapp_Wasm_Upgrade(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["gas_prices"] = "0adym" + dymintTomlOverrides["empty_blocks_max_time"] = "3s" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + preUpgradeRollappWasmImage := ibc.DockerImage{ + Repository: "ghcr.io/dymensionxyz/rollapp-wasm", + Version: "latest", + UidGid: "1025:1025", + } + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{preUpgradeRollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + rollapp := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp) + + height, err := rollapp1.Height(ctx) + require.NoError(t, err, "error fetching height before submit upgrade proposal") + + haltHeight := height + haltHeightDelta + + proposal := cosmos.SoftwareUpgradeProposal{ + Deposit: "500000000000" + rollapp1.Config().Denom, // greater than min deposit + Title: "Rollapp Upgrade 1", + Name: upgradeWasmName, + Description: "First software upgrade", + Height: haltHeight, + Info: "Info", + } + + upgradeTx, err := rollapp1.UpgradeLegacyProposal(ctx, rollappUser.KeyName(), proposal) + require.NoError(t, err, "error submitting software upgrade proposal tx") + fmt.Println("upgradeTx", upgradeTx) + + err = rollapp1.VoteOnProposalAllValidators(ctx, upgradeTx.ProposalID, cosmos.ProposalVoteYes) + require.NoError(t, err, "failed to submit votes") + + _, err = cosmos.PollForProposalStatus(ctx, rollapp1.CosmosChain, height, haltHeight, upgradeTx.ProposalID, cosmos.ProposalStatusPassed) + prop, _ := rollapp1.QueryProposal(ctx, upgradeTx.ProposalID) + fmt.Println("prop: ", prop) + require.Equal(t, prop.Status, cosmos.ProposalStatusPassed) + require.NoError(t, err, "proposal status did not change to passed in expected number of blocks") + + timeoutCtx, timeoutCtxCancel := context.WithTimeout(ctx, time.Second*45) + defer timeoutCtxCancel() + + height, err = rollapp1.Height(ctx) + require.NoError(t, err, "error fetching height before upgrade") + + // this should timeout due to chain halt at upgrade height. + _ = testutil.WaitForBlocks(timeoutCtx, int(haltHeight-height)+1, rollapp1) + + // bring down nodes to prepare for upgrade + err = rollapp1.StopAllNodes(ctx) + require.NoError(t, err, "error stopping node(s)") + + // upgrade version on all nodes + rollapp1.UpgradeVersion(ctx, client, RollappWasmMainRepo, rollappWasmVersion) + + // start all nodes back up. + // validators reach consensus on first block after upgrade height + // and chain block production resumes. + err = rollapp1.StartAllNodes(ctx) + require.NoError(t, err, "error starting upgraded node(s)") + + timeoutCtx, timeoutCtxCancel = context.WithTimeout(ctx, time.Second*45) + defer timeoutCtxCancel() + + err = testutil.WaitForBlocks(timeoutCtx, int(blocksAfterUpgrade), rollapp1) + require.NoError(t, err, "chain did not produce blocks after upgrade") + + height, err = rollapp1.Height(ctx) + require.NoError(t, err, "error fetching height after upgrade") + + require.GreaterOrEqual(t, height, haltHeight+blocksAfterUpgrade, "height did not increment enough after upgrade") + + // Compose an IBC transfer and send from dymension -> rollapp + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from Hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + err = r.StopRelayer(ctx, eRep) + require.NoError(t, err) + + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // Assert funds were returned to the sender after the timeout has occured + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount) +} diff --git a/tests/setup.go b/tests/setup.go index 4e74467a..843c5c93 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -65,7 +65,7 @@ var ( dymensionVersion, rollappEVMVersion, rollappWasmVersion = GetDockerImageVersion() - upgradeName = GetUpgradeName() + upgradeName, upgradeEVMName, upgradeWasmName = GetUpgradeName() dymensionImage = ibc.DockerImage{ Repository: DymensionMainRepo, @@ -318,12 +318,20 @@ func GetDockerImageVersion() (dymensionVersion, rollappEVMVersion, rollappWasmVe return dymensionVersion, rollappEVMVersion, rollappWasmVersion } -func GetUpgradeName() (upgradeName string) { +func GetUpgradeName() (upgradeName, upgradeEVMName, upgradeWasmName string) { upgradeName, found := os.LookupEnv("UPGRADE_NAME") if !found { upgradeName = "" } - return upgradeName + upgradeEVMName, found = os.LookupEnv("UPGRADE_ROLAPP_EVM_NAME") + if !found { + upgradeEVMName = "" + } + upgradeWasmName, found = os.LookupEnv("UPGRADE_ROLLAPP_WASM_NAME") + if !found { + upgradeWasmName = "" + } + return upgradeName, upgradeEVMName, upgradeWasmName } func encodingConfig() *simappparams.EncodingConfig { diff --git a/tests_spec/rollapp_upgrade.md b/tests_spec/rollapp_upgrade.md index 85d69932..6806badf 100644 --- a/tests_spec/rollapp_upgrade.md +++ b/tests_spec/rollapp_upgrade.md @@ -3,4 +3,4 @@ | No | Scenario | Pre-condition | Pre-condition check | Expected result | Expected result check | Covered By | |----|----------|---------------|---------------------|-----------------|-----------------------|------------| | 1 | Test non state breaking binary upgrade | Running rollapp | ✅ | Change to a new binary and rollapp should continue functioning with upgraded version | ✅ | [TestRollappUpgradeNonStateBreaking_EVM](../tests/rollapp_upgrade_test.go#28) [TestRollappUpgradeNonStateBreaking_Wasm](../tests/rollapp_upgrade_test.go#220) | -| 2 | Test upgrade which requires migration | Running rollapp and governor have enough tokens to vote for a governance proposal|🛑
(missing) | Vote for upgrade and rollapp should continue functioning with upgraded version | 🛑
(missing) | TODO | +| 2 | Test upgrade which requires migration | Running rollapp and governor have enough tokens to vote for a governance proposal|✅ | Vote for upgrade and rollapp should continue functioning with upgraded version |✅ | [TestRollappUpgrade_EVM](../tests/rollapp_upgrade_test.go#428) | From 139533342ef6ee3c4af706b12c6bf39addcf297d Mon Sep 17 00:00:00 2001 From: nguyen | decentrio <144610611+trinitys7@users.noreply.github.com> Date: Mon, 20 May 2024 13:26:32 +0700 Subject: [PATCH 51/61] fix unstable eibc ack tests (#188) Co-authored-by: anhductn2001 --- tests/eibc_ack_error_test.go | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/tests/eibc_ack_error_test.go b/tests/eibc_ack_error_test.go index aae1383e..e23ffaf5 100644 --- a/tests/eibc_ack_error_test.go +++ b/tests/eibc_ack_error_test.go @@ -319,9 +319,7 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { // get eIbc event eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) require.NoError(t, err) - require.Len(t, eibcEvents, 2) - fmt.Println("Event:", eibcEvents[1]) - require.Equal(t, eibcEvents[1].PacketStatus, "PENDING") + require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") // Get the balance of dymensionUserAddr and marketMakerAddr before fulfill the demand order dymensionUserBalance, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) @@ -330,7 +328,7 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { require.NoError(t, err) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr) require.NoError(t, err) fmt.Println(txhash) eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -666,12 +664,10 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { // get eIbc event eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) require.NoError(t, err) - require.Len(t, eibcEvents, 2) - fmt.Println("Event:", eibcEvents[1]) - require.Equal(t, eibcEvents[1].PacketStatus, "PENDING") + require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr) require.NoError(t, err) fmt.Println(txhash) eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -1033,12 +1029,10 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { // get eIbc event eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) require.NoError(t, err) - require.Len(t, eibcEvents, 2) - fmt.Println("Event:", eibcEvents[1]) - require.Equal(t, eibcEvents[1].PacketStatus, "PENDING") + require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr) require.NoError(t, err) fmt.Println(txhash) eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -1377,9 +1371,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { // get eIbc event eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) require.NoError(t, err) - require.Len(t, eibcEvents, 2) - fmt.Println("Event:", eibcEvents[1]) - require.Equal(t, eibcEvents[1].PacketStatus, "PENDING") + require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") // Get the balance of dymensionUserAddr and marketMakerAddr before fulfill the demand order dymensionUserBalance, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) @@ -1388,7 +1380,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.NoError(t, err) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr) require.NoError(t, err) fmt.Println(txhash) eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -1721,12 +1713,10 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { // get eIbc event eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) require.NoError(t, err) - require.Len(t, eibcEvents, 2) - fmt.Println("Event:", eibcEvents[1]) - require.Equal(t, eibcEvents[1].PacketStatus, "PENDING") + require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr) require.NoError(t, err) fmt.Println(txhash) eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -2086,12 +2076,10 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { // get eIbc event eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) require.NoError(t, err) - require.Len(t, eibcEvents, 2) - fmt.Println("Event:", eibcEvents[1]) - require.Equal(t, eibcEvents[1].PacketStatus, "PENDING") + require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr) require.NoError(t, err) fmt.Println(txhash) eibcEvent := getEibcEventFromTx(t, dymension, txhash) From 6c479ef7612efdd3b121e40510059d839f295fe9 Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Tue, 21 May 2024 10:41:05 +0700 Subject: [PATCH 52/61] test: rollapp-genesis ibc transfer from hub when only hub side gone through genesis (#182) --- Makefile | 3 + go.mod | 2 +- go.sum | 4 +- tests/rollapp_genesis_event_test.go | 191 +++++++++++++++++++++++++++- 4 files changed, 195 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 45ff3642..2eeb0218 100644 --- a/Makefile +++ b/Makefile @@ -137,6 +137,9 @@ e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_rollapp_evm: clean e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_hub_evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollAppTransferHubTriggerGenesis_EVM . +e2e-test-rollapp_genesis_transfer_hub_to_rollapp_with_trigger_hub_evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestHubTransferHubTriggerGenesis_EVM . + # Executes IBC tests via rollup-e2e-testing e2e-test-ibc-success-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferSuccess_Wasm . diff --git a/go.mod b/go.mod index f56c1755..1413b741 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( cosmossdk.io/math v1.3.0 github.com/cosmos/cosmos-sdk v0.46.16 github.com/cosmos/ibc-go/v6 v6.2.1 - github.com/decentrio/rollup-e2e-testing v0.0.0-20240516084938-988198ff177f + github.com/decentrio/rollup-e2e-testing v0.0.0-20240520072959-416adb7b1c64 github.com/dymensionxyz/dymension-rdk v1.1.0-beta github.com/dymensionxyz/dymension/v3 v3.1.0-rc01.0.20240404003005-53ccf8a922fd github.com/evmos/ethermint v0.22.0 diff --git a/go.sum b/go.sum index 87e13076..5a71d073 100644 --- a/go.sum +++ b/go.sum @@ -328,8 +328,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240516084938-988198ff177f h1:zSIExYUfmqZJhqhkq2GLsMxThu4Y8issfojrP6iC5PQ= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240516084938-988198ff177f/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240520072959-416adb7b1c64 h1:LIhOT1quF59rPn9lpQHKUsn+ljJ/WcKUMtmKyiC0r8U= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240520072959-416adb7b1c64/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= diff --git a/tests/rollapp_genesis_event_test.go b/tests/rollapp_genesis_event_test.go index da9f5e5e..90fef071 100644 --- a/tests/rollapp_genesis_event_test.go +++ b/tests/rollapp_genesis_event_test.go @@ -4,11 +4,13 @@ import ( "context" "fmt" "testing" + "bytes" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" + transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" test "github.com/decentrio/rollup-e2e-testing" "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" @@ -17,7 +19,6 @@ import ( "github.com/decentrio/rollup-e2e-testing/relayer" "github.com/decentrio/rollup-e2e-testing/testreporter" "github.com/decentrio/rollup-e2e-testing/testutil" - transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" ) // TestRollappGenesisEvent_EVM ensure that genesis event triggered in both rollapp evm and dymension hub @@ -299,7 +300,7 @@ func TestTransferRollAppTriggerGenesis_EVM(t *testing.T) { channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) require.NoError(t, err) registerGenesisEventTriggerer(t, rollapp1.CosmosChain, rollappUser.KeyName(), rollappUserAddr, "hubgenesis", "GenesisTriggererAllowlist") - + _, err = rollapp1.Validators[0].ExecTx(ctx, rollappUserAddr, "hubgenesis", "genesis-event", dymension.GetChainID(), channel.ChannelID) require.NoError(t, err) @@ -837,3 +838,189 @@ func TestRollAppTransferHubTriggerGenesis_Wasm(t *testing.T) { }, ) } + +func TestHubTransferHubTriggerGenesis_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_1234-1", "0adym", "3s") + + extraFlags := map[string]interface{}{"genesis-accounts-path": true} + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + // Enable erc20 + modifyRollappGeneisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.erc20.params.enable_erc20", + Value: true, + }, + ) + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(modifyRollappGeneisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + rollapp_params := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp_params) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + transferData := ibc.WalletData{ + Address: rollappUserAddr, + Denom: rollappIBCDenom, + Amount: transferAmount, + } + // get val0 address + val0Addr, err := dymension.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) + balance, err := dymension.GetBalance(ctx, val0Addr, rollappIBCDenom) + require.NoError(t, err) + // get and check balance of escrow address + + escrowAddress, err := rollapp1.Validators[0].QueryEscrowAddress(ctx, channel.PortID, channel.ChannelID) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, rollapp1, escrowAddress, rollapp1.Config().Denom, zeroBal) + + // get dymension and rollapp height + dymensionHeight, err := dymension.Height(ctx) + require.NoError(t, err) + rollappHeight, err := dymension.Height(ctx) + require.NoError(t, err) + + // ibc transfer from hub -> rollapp + txHash, err := dymension.Validators[0].SendIBCTransfer(ctx, channel.ChannelID, "validator", transferData, ibc.TransferOptions{}) + require.NoError(t, err) + // get Ibc tx + ibcTx, err := dymension.Validators[0].GetIbcTxFromTxHash(ctx, txHash) + require.NoError(t, err) + + // catch ACK errors + ack, err := testutil.PollForAck(ctx, dymension, dymensionHeight, dymensionHeight+30, ibcTx.Packet) + require.NoError(t, err) + + // Make sure that the ack contains error + require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // Check assets balance + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, val0Addr, rollappIBCDenom, balance) + testutil.AssertBalance(t, ctx, rollapp1, escrowAddress, rollapp1.Config().Denom, zeroBal) + t.Cleanup( + func() { + err := r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} From a02596acc301c4551a40ed1f42e2850ad32010b3 Mon Sep 17 00:00:00 2001 From: ducnt131 <62016666+anhductn2001@users.noreply.github.com> Date: Wed, 22 May 2024 22:05:16 +0700 Subject: [PATCH 53/61] chore: update dymint and go-relayer (#197) --- tests/disconnection_test.go | 16 ++- tests/eibc_ack_error_test.go | 144 +++++++++++++----------- tests/eibc_corrupted_memo_test.go | 10 +- tests/eibc_fee_test.go | 10 +- tests/eibc_fulfillment_test.go | 127 ++++++++++++--------- tests/eibc_invariant_test.go | 28 +++-- tests/eibc_nobalance_test.go | 10 +- tests/eibc_not_fulfillment_test.go | 28 +++-- tests/eibc_pfm_test.go | 58 +++++----- tests/eibc_timeout_test.go | 59 +++++----- tests/erc20_ibc_transfer_test.go | 11 +- tests/frozen_test.go | 82 +++++++++----- tests/ibc_finalize_block_test.go | 96 +++++++++------- tests/ibc_grace_period_test.go | 84 ++++++++------ tests/ibc_pfm_test.go | 42 +++++-- tests/ibc_pfm_with_grace_period_test.go | 59 ++++++---- tests/ibc_timeout_test.go | 20 ++-- tests/ibc_transfer_test.go | 35 ++---- tests/rollapp_genesis_event_test.go | 71 ++++++++---- tests/rollapp_invariant_test.go | 32 +++--- tests/rollapp_upgrade_test.go | 40 ++++--- tests/sequencer_invariant_test.go | 32 +++--- tests/setup.go | 18 +-- tests/tx_batch_finalization_test.go | 16 ++- tests/upgrade_hub_test.go | 16 +-- 25 files changed, 669 insertions(+), 475 deletions(-) diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index d1f93a53..9d82254f 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -27,10 +27,12 @@ func TestDisconnection_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -146,10 +148,12 @@ func TestDisconnection_Wasm(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension diff --git a/tests/eibc_ack_error_test.go b/tests/eibc_ack_error_test.go index e23ffaf5..dbb3256d 100644 --- a/tests/eibc_ack_error_test.go +++ b/tests/eibc_ack_error_test.go @@ -29,20 +29,21 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1-1" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTimeRollapp1 := "10s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTimeRollapp1) + maxIdleTime1 := "10s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") extraFlags := map[string]interface{}{"genesis-accounts-path": true} // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappevm_2-1" + rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - emptyBlocksMaxTimeRollapp2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTimeRollapp2) + maxIdleTime2 := "1s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Custom dymension epoch for faster disconnection modifyGenesisKV := append( @@ -69,7 +70,7 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp", - ChainID: "rollappevm_1-1", + ChainID: "rollappevm_1234-1", Images: []ibc.DockerImage{rollappEVMImage}, Bin: "rollappd", Bech32Prefix: "ethm", @@ -91,7 +92,7 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp", - ChainID: "rollappevm_2-1", + ChainID: "rollappevm_12345-1", Images: []ibc.DockerImage{rollappEVMImage}, Bin: "rollappd", Bech32Prefix: "ethm", @@ -144,10 +145,10 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -386,20 +387,21 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1-1" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTimeRollapp1 := "10s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTimeRollapp1) + maxIdleTime1 := "10s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") extraFlags := map[string]interface{}{"genesis-accounts-path": true} // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappevm_2-1" + rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - emptyBlocksMaxTimeRollapp2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTimeRollapp2) + maxIdleTime2 := "1s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Custom dymension epoch for faster disconnection modifyGenesisKV := append( @@ -426,7 +428,7 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp", - ChainID: "rollappevm_1-1", + ChainID: "rollappevm_1234-1", Images: []ibc.DockerImage{rollappEVMImage}, Bin: "rollappd", Bech32Prefix: "ethm", @@ -448,7 +450,7 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp", - ChainID: "rollappevm_2-1", + ChainID: "rollappevm_12345-1", Images: []ibc.DockerImage{rollappEVMImage}, Bin: "rollappd", Bech32Prefix: "ethm", @@ -501,10 +503,10 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -718,20 +720,21 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1-1" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTimeRollapp1 := "10s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTimeRollapp1) + maxIdleTime1 := "10s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") extraFlags := map[string]interface{}{"genesis-accounts-path": true} // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappevm_2-1" + rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - emptyBlocksMaxTimeRollapp2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTimeRollapp2) + maxIdleTime2 := "1s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Custom dymension epoch for faster disconnection modifyGenesisKV := append( @@ -758,7 +761,7 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp", - ChainID: "rollappevm_1-1", + ChainID: "rollappevm_1234-1", Images: []ibc.DockerImage{rollappEVMImage}, Bin: "rollappd", Bech32Prefix: "ethm", @@ -780,7 +783,7 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp", - ChainID: "rollappevm_2-1", + ChainID: "rollappevm_12345-1", Images: []ibc.DockerImage{rollappEVMImage}, Bin: "rollappd", Bech32Prefix: "ethm", @@ -833,10 +836,10 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -1083,18 +1086,21 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1-1" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTimeRollapp1 := "10s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTimeRollapp1) + maxIdleTime1 := "10s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + + extraFlags := map[string]interface{}{"genesis-accounts-path": true} // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_2-1" + rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - emptyBlocksMaxTimeRollapp2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTimeRollapp2) + maxIdleTime2 := "1s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Custom dymension epoch for faster disconnection modifyGenesisKV := append( @@ -1121,7 +1127,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp", - ChainID: "rollappwasm_1-1", + ChainID: "rollappwasm_1234-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", Bech32Prefix: "rol", @@ -1143,7 +1149,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp2", - ChainID: "rollappwasm_2-1", + ChainID: "rollappwasm_12345-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", Bech32Prefix: "rol", @@ -1196,10 +1202,10 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -1437,18 +1443,21 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1-1" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTimeRollapp1 := "10s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTimeRollapp1) + maxIdleTime1 := "10s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + + extraFlags := map[string]interface{}{"genesis-accounts-path": true} // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_2-1" + rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - emptyBlocksMaxTimeRollapp2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTimeRollapp2) + maxIdleTime2 := "1s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Custom dymension epoch for faster disconnection modifyGenesisKV := append( @@ -1475,7 +1484,7 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp", - ChainID: "rollappwasm_1-1", + ChainID: "rollappwasm_1234-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", Bech32Prefix: "rol", @@ -1497,7 +1506,7 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp2", - ChainID: "rollappwasm_2-1", + ChainID: "rollappwasm_12345-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", Bech32Prefix: "rol", @@ -1550,10 +1559,10 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -1767,18 +1776,21 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1-1" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTimeRollapp1 := "10s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTimeRollapp1) + maxIdleTime1 := "10s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + + extraFlags := map[string]interface{}{"genesis-accounts-path": true} // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_2-1" + rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - emptyBlocksMaxTimeRollapp2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTimeRollapp2) + maxIdleTime2 := "1s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Custom dymension epoch for faster disconnection modifyGenesisKV := append( @@ -1805,7 +1817,7 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp", - ChainID: "rollappwasm_1-1", + ChainID: "rollappwasm_1234-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", Bech32Prefix: "rol", @@ -1827,7 +1839,7 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp2", - ChainID: "rollappwasm_2-1", + ChainID: "rollappwasm_12345-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", Bech32Prefix: "rol", @@ -1880,10 +1892,10 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/eibc_corrupted_memo_test.go b/tests/eibc_corrupted_memo_test.go index 4fd533d9..7151f6bf 100644 --- a/tests/eibc_corrupted_memo_test.go +++ b/tests/eibc_corrupted_memo_test.go @@ -32,10 +32,12 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -109,7 +111,7 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) const ibcPath = "ibc-path" ic := test.NewSetup(). diff --git a/tests/eibc_fee_test.go b/tests/eibc_fee_test.go index 76639961..e3a8e9e2 100644 --- a/tests/eibc_fee_test.go +++ b/tests/eibc_fee_test.go @@ -32,10 +32,12 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -109,7 +111,7 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) const ibcPath = "ibc-path" ic := test.NewSetup(). diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index e947f3fb..7a5ab98e 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -34,17 +34,19 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -141,12 +143,12 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -403,17 +405,19 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -510,12 +514,12 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -774,18 +778,19 @@ func TestEIBCFulfillment_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) - + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -880,11 +885,11 @@ func TestEIBCFulfillment_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -1068,17 +1073,19 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -1174,11 +1181,11 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -1371,17 +1378,19 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -1478,12 +1487,12 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -1752,17 +1761,19 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -1877,11 +1888,11 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) r3 := test.NewBuiltinRelayerFactory( @@ -2151,17 +2162,19 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -2267,11 +2280,11 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) // Relayer for gaia r3 := test.NewBuiltinRelayerFactory( @@ -2538,17 +2551,19 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -2645,12 +2660,12 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -2790,17 +2805,19 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -2897,12 +2914,12 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/eibc_invariant_test.go b/tests/eibc_invariant_test.go index 82d70692..940ee8d9 100644 --- a/tests/eibc_invariant_test.go +++ b/tests/eibc_invariant_test.go @@ -29,17 +29,19 @@ func TestEIBCInvariant_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") const EPOCH_IDENTIFIER string = "minute" modifyGenesisKV := append( @@ -140,11 +142,11 @@ func TestEIBCInvariant_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -375,17 +377,19 @@ func TestEIBCInvariant_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") const EPOCH_IDENTIFIER string = "minute" modifyGenesisKV := append( @@ -486,11 +490,11 @@ func TestEIBCInvariant_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/eibc_nobalance_test.go b/tests/eibc_nobalance_test.go index 945d967d..14ea41c7 100644 --- a/tests/eibc_nobalance_test.go +++ b/tests/eibc_nobalance_test.go @@ -33,10 +33,12 @@ func TestEIBCNoBalanceToFulfillOrder_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -110,7 +112,7 @@ func TestEIBCNoBalanceToFulfillOrder_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) const ibcPath = "ibc-path" ic := test.NewSetup(). diff --git a/tests/eibc_not_fulfillment_test.go b/tests/eibc_not_fulfillment_test.go index dc974c71..8108de38 100644 --- a/tests/eibc_not_fulfillment_test.go +++ b/tests/eibc_not_fulfillment_test.go @@ -31,17 +31,19 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -137,11 +139,11 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -291,17 +293,19 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -397,11 +401,11 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/eibc_pfm_test.go b/tests/eibc_pfm_test.go index 212a28fd..e0f86d18 100644 --- a/tests/eibc_pfm_test.go +++ b/tests/eibc_pfm_test.go @@ -31,17 +31,20 @@ func TestEIBCPFM_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlementLayer := "dymension" - nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1Id := "rollappevm_1-1" - gasPrice := "0adym" - emptyBlocksMaxTimeRollapp1 := "30s" - configFileOverrides1 := overridesDymintToml(settlementLayer, nodeAddress, rollapp1Id, gasPrice, emptyBlocksMaxTimeRollapp1) + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 - rollapp2Id := "rollappevm_2-1" - emptyBlocksMaxTimeRollapp2 := "3s" // make sure rollapp 1 will have finalize height < rollapp 2 - configFileOverrides2 := overridesDymintToml(settlementLayer, nodeAddress, rollapp2Id, gasPrice, emptyBlocksMaxTimeRollapp2) + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -63,7 +66,7 @@ func TestEIBCPFM_EVM(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp", - ChainID: "rollappevm_1-1", + ChainID: "rollappevm_1234-1", Images: []ibc.DockerImage{rollappEVMImage}, Bin: "rollappd", Bech32Prefix: "ethm", @@ -85,7 +88,7 @@ func TestEIBCPFM_EVM(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp2", - ChainID: "rollappevm_2-1", + ChainID: "rollappevm_12345-1", Images: []ibc.DockerImage{rollappEVMImage}, Bin: "rollappd", Bech32Prefix: "ethm", @@ -138,11 +141,11 @@ func TestEIBCPFM_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -308,17 +311,20 @@ func TestEIBCPFM_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlementLayer := "dymension" - nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1Id := "rollappwasm_1-1" - gasPrice := "0adym" - emptyBlocksMaxTimeRollapp1 := "30s" - configFileOverrides1 := overridesDymintToml(settlementLayer, nodeAddress, rollapp1Id, gasPrice, emptyBlocksMaxTimeRollapp1) + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 - rollapp2Id := "rollappwasm_2-1" - emptyBlocksMaxTimeRollapp2 := "3s" // make sure rollapp 1 will have finalize height < rollapp 2 - configFileOverrides2 := overridesDymintToml(settlementLayer, nodeAddress, rollapp2Id, gasPrice, emptyBlocksMaxTimeRollapp2) + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -340,7 +346,7 @@ func TestEIBCPFM_Wasm(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-test", - ChainID: "rollappwasm_1-1", + ChainID: "rollappwasm_1234-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", Bech32Prefix: "rol", @@ -362,7 +368,7 @@ func TestEIBCPFM_Wasm(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-test2", - ChainID: "rollappwasm_2-1", + ChainID: "rollappwasm_12345-1", Images: []ibc.DockerImage{rollappWasmImage}, Bin: "rollappd", Bech32Prefix: "rol", @@ -415,11 +421,11 @@ func TestEIBCPFM_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/eibc_timeout_test.go b/tests/eibc_timeout_test.go index 44902209..562463a7 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -32,10 +32,12 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -107,7 +109,7 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) const ibcPath = "ibc-path" ic := test.NewSetup(). @@ -271,17 +273,20 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlementLayer := "dymension" - nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1Id := "rollappevm_1-1" - gasPrice := "0adym" - emptyBlocksMaxTimeRollapp1 := "5s" - configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollapp1Id, gasPrice, emptyBlocksMaxTimeRollapp1) + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 - rollapp2Id := "rollappevm_2-1" - emptyBlocksMaxTimeRollapp2 := "3s" // make sure rollapp 1 will have finalize height < rollapp 2 - configFileOverrides2 := overridesDymintToml(settlementLayer, nodeAddress, rollapp2Id, gasPrice, emptyBlocksMaxTimeRollapp2) + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -303,7 +308,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp", - ChainID: "rollappevm_1-1", + ChainID: "rollappevm_1234-1", Images: []ibc.DockerImage{rollappEVMImage}, Bin: "rollappd", Bech32Prefix: "ethm", @@ -315,7 +320,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { EncodingConfig: encodingConfig(), NoHostMount: false, ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), - ConfigFileOverrides: configFileOverrides, + ConfigFileOverrides: configFileOverrides1, }, NumValidators: &numRollAppVals, NumFullNodes: &numRollAppFn, @@ -325,7 +330,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { ChainConfig: ibc.ChainConfig{ Type: "rollapp-dym", Name: "rollapp-temp2", - ChainID: "rollappevm_2-1", + ChainID: "rollappevm_12345-1", Images: []ibc.DockerImage{rollappEVMImage}, Bin: "rollappd", Bech32Prefix: "ethm", @@ -385,11 +390,11 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) // relayer for rollapp gaia r3 := test.NewBuiltinRelayerFactory( @@ -649,17 +654,19 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappwasm_1234-1" - gasPrice := "0adym" - emptyBlocksMaxTimeRollapp1 := "5s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gasPrice, emptyBlocksMaxTimeRollapp1) + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappwasm_12345-1" - emptyBlocksMaxTimeRollapp2 := "3s" // make sure rollapp 1 will have finalize height < rollapp 2 - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gasPrice, emptyBlocksMaxTimeRollapp2) + gas_price_rollapp2 := "0adym" + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -757,11 +764,11 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) // Relayer for gaia r3 := test.NewBuiltinRelayerFactory( diff --git a/tests/erc20_ibc_transfer_test.go b/tests/erc20_ibc_transfer_test.go index 457e8cd4..88f97950 100644 --- a/tests/erc20_ibc_transfer_test.go +++ b/tests/erc20_ibc_transfer_test.go @@ -27,11 +27,12 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { // setup config for rollapp settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp, emptyBlocksMaxTime) + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -112,7 +113,7 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) ic := test.NewSetup(). AddRollUp(dymension, rollapp1). diff --git a/tests/frozen_test.go b/tests/frozen_test.go index 9695735d..e9e11753 100644 --- a/tests/frozen_test.go +++ b/tests/frozen_test.go @@ -39,8 +39,21 @@ func TestRollAppFreeze_EVM(t *testing.T) { ctx := context.Background() - configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_1234-1", "0adym", "3s") - configFileOverrides2 := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_12345-1", "0adym", "3s") + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -66,7 +79,7 @@ func TestRollAppFreeze_EVM(t *testing.T) { EncodingConfig: encodingConfig(), NoHostMount: false, ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), - ConfigFileOverrides: configFileOverrides, + ConfigFileOverrides: configFileOverrides1, }, NumValidators: &numRollAppVals, NumFullNodes: &numRollAppFn, @@ -131,11 +144,11 @@ func TestRollAppFreeze_EVM(t *testing.T) { // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -356,8 +369,21 @@ func TestRollAppFreeze_Wasm(t *testing.T) { ctx := context.Background() - configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappwasm_1234-1", "0adym", "3s") - configFileOverrides2 := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappwasm_12345-1", "0adym", "3s") + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappewasm_2-1" + gas_price_rollapp2 := "0adym" + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -382,7 +408,7 @@ func TestRollAppFreeze_Wasm(t *testing.T) { EncodingConfig: encodingConfig(), NoHostMount: false, ModifyGenesis: nil, - ConfigFileOverrides: configFileOverrides, + ConfigFileOverrides: configFileOverrides1, }, NumValidators: &numRollAppVals, NumFullNodes: &numRollAppFn, @@ -447,11 +473,11 @@ func TestRollAppFreeze_Wasm(t *testing.T) { // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -702,20 +728,22 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides configFileOverrides2 := make(map[string]any) dymintTomlOverrides2 := make(testutil.Toml) dymintTomlOverrides2["settlement_layer"] = "dymension" - dymintTomlOverrides2["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides2["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides2["rollapp_id"] = "rollappevm_12345-1" - dymintTomlOverrides2["gas_prices"] = "0adym" - dymintTomlOverrides2["empty_blocks_max_time"] = "3s" + dymintTomlOverrides2["settlement_gas_prices"] = "0adym" + dymintTomlOverrides2["max_idle_time"] = "3s" configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides2 // Create chain factory with dymension @@ -805,11 +833,11 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) s := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -1111,20 +1139,22 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides configFileOverrides2 := make(map[string]any) dymintTomlOverrides2 := make(testutil.Toml) dymintTomlOverrides2["settlement_layer"] = "dymension" - dymintTomlOverrides2["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides2["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides2["rollapp_id"] = "rollappwasm_12345-1" - dymintTomlOverrides2["gas_prices"] = "0adym" - dymintTomlOverrides2["empty_blocks_max_time"] = "3s" + dymintTomlOverrides2["settlement_gas_prices"] = "0adym" + dymintTomlOverrides2["max_idle_time"] = "3s" configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides2 // Create chain factory with dymension @@ -1214,11 +1244,11 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) s := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/ibc_finalize_block_test.go b/tests/ibc_finalize_block_test.go index 8970bc15..5eca2014 100644 --- a/tests/ibc_finalize_block_test.go +++ b/tests/ibc_finalize_block_test.go @@ -28,12 +28,14 @@ func TestDymFinalizeBlock_OnRecvPacket_EVM(t *testing.T) { ctx := context.Background() - settlementLayer := "dymension" - nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollappId := "rollappevm_1234-1" - gasPrice := "0adym" - emptyBlocksMaxTimeRollapp := "3s" - configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") modifyGenesisKV := append( rollappEVMGenesisKV, @@ -88,7 +90,7 @@ func TestDymFinalizeBlock_OnRecvPacket_EVM(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -189,12 +191,14 @@ func TestDymFinalizeBlock_OnAckPacket_EVM(t *testing.T) { ctx := context.Background() - settlementLayer := "dymension" - nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollappId := "rollappevm_1234-1" - gasPrice := "0adym" - emptyBlocksMaxTimeRollapp := "3s" - configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -254,7 +258,7 @@ func TestDymFinalizeBlock_OnAckPacket_EVM(t *testing.T) { client, network := test.DockerSetup(t) r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) r2 := test.NewBuiltinRelayerFactory( @@ -370,12 +374,14 @@ func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { ctx := context.Background() - settlementLayer := "dymension" - nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollappId := "rollappevm_1234-1" - gasPrice := "0adym" - emptyBlocksMaxTimeRollapp := "3s" - configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -425,7 +431,7 @@ func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -530,12 +536,14 @@ func TestDymFinalizeBlock_OnRecvPacket_Wasm(t *testing.T) { ctx := context.Background() - settlementLayer := "dymension" - nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollappId := "rollappwasm_1234-1" - gasPrice := "0adym" - emptyBlocksMaxTimeRollapp := "3s" - configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") modifyGenesisKV := []cosmos.GenesisKV{ { @@ -590,7 +598,7 @@ func TestDymFinalizeBlock_OnRecvPacket_Wasm(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -695,12 +703,14 @@ func TestDymFinalizeBlock_OnAckPacket_Wasm(t *testing.T) { ctx := context.Background() - settlementLayer := "dymension" - nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollappId := "rollappwasm_1234-1" - gasPrice := "0adym" - emptyBlocksMaxTimeRollapp := "3s" - configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -760,7 +770,7 @@ func TestDymFinalizeBlock_OnAckPacket_Wasm(t *testing.T) { client, network := test.DockerSetup(t) r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) r2 := test.NewBuiltinRelayerFactory( @@ -877,12 +887,14 @@ func TestDymFinalizeBlock_OnTimeOutPacket_Wasm(t *testing.T) { ctx := context.Background() - settlementLayer := "dymension" - nodeAddress := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollappId := "rollappwasm_1234-1" - gasPrice := "0adym" - emptyBlocksMaxTimeRollapp := "3s" - configFileOverrides := overridesDymintToml(settlementLayer, nodeAddress, rollappId, gasPrice, emptyBlocksMaxTimeRollapp) + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -932,7 +944,7 @@ func TestDymFinalizeBlock_OnTimeOutPacket_Wasm(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). diff --git a/tests/ibc_grace_period_test.go b/tests/ibc_grace_period_test.go index 6d63599f..512a77e5 100644 --- a/tests/ibc_grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -30,17 +30,19 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -136,11 +138,11 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -307,17 +309,19 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -413,11 +417,11 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -583,17 +587,19 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Increase dispute blocks modifyGenesisKV := append( @@ -690,11 +696,11 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -838,17 +844,19 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Increase dispute blocks modifyGenesisKV := append( @@ -945,11 +953,11 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -1093,17 +1101,19 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Increase dispute blocks modifyGenesisKV := append( @@ -1200,11 +1210,11 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -1363,17 +1373,19 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Increase dispute blocks modifyGenesisKV := append( @@ -1470,11 +1482,11 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/ibc_pfm_test.go b/tests/ibc_pfm_test.go index 3c2c545a..2db2d43b 100644 --- a/tests/ibc_pfm_test.go +++ b/tests/ibc_pfm_test.go @@ -31,10 +31,12 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -91,7 +93,7 @@ func TestIBCTransferMultiHop_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) r2 := test.NewBuiltinRelayerFactory( @@ -279,10 +281,12 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -339,7 +343,7 @@ func TestIBCTransferMultiHop_Wasm(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) r2 := test.NewBuiltinRelayerFactory( @@ -523,7 +527,14 @@ func TestIBCTransferGaiaToRollApp_EVM(t *testing.T) { } ctx := context.Background() - configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_1234-1", "0adym", "3s") + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -579,7 +590,7 @@ func TestIBCTransferGaiaToRollApp_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) r2 := test.NewBuiltinRelayerFactory( @@ -759,7 +770,14 @@ func TestIBCTransferGaiaToRollApp_Wasm(t *testing.T) { } ctx := context.Background() - configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappwasm_1234-1", "0adym", "3s") + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -815,7 +833,7 @@ func TestIBCTransferGaiaToRollApp_Wasm(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) r2 := test.NewBuiltinRelayerFactory( diff --git a/tests/ibc_pfm_with_grace_period_test.go b/tests/ibc_pfm_with_grace_period_test.go index f0adc07f..e281ea27 100644 --- a/tests/ibc_pfm_with_grace_period_test.go +++ b/tests/ibc_pfm_with_grace_period_test.go @@ -31,10 +31,12 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" modifyGenesisKV := append( dymensionGenesisKV, @@ -118,7 +120,7 @@ func TestIBCPFMWithGracePeriod_EVM(t *testing.T) { r := test.NewBuiltinRelayerFactory( ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) r2 := test.NewBuiltinRelayerFactory( @@ -322,10 +324,12 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" modifyGenesisKV := append(dymensionGenesisKV, cosmos.GenesisKV{ @@ -408,7 +412,7 @@ func TestIBCPFMWithGracePeriod_Wasm(t *testing.T) { r := test.NewBuiltinRelayerFactory( ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) r2 := test.NewBuiltinRelayerFactory( @@ -610,8 +614,21 @@ func TestIBCPFM_RollApp1To2WithErc20_EVM(t *testing.T) { ctx := context.Background() - configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_1234-1", "0adym", "3s") - configFileOverrides2 := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_12345-1", "0adym", "3s") + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -645,7 +662,7 @@ func TestIBCPFM_RollApp1To2WithErc20_EVM(t *testing.T) { EncodingConfig: encodingConfig(), NoHostMount: false, ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), - ConfigFileOverrides: configFileOverrides, + ConfigFileOverrides: configFileOverrides1, }, NumValidators: &numRollAppVals, NumFullNodes: &numRollAppFn, @@ -710,11 +727,11 @@ func TestIBCPFM_RollApp1To2WithErc20_EVM(t *testing.T) { // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -954,17 +971,19 @@ func TestIBCPFM_RollApp1To2WithOutErc20_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappwasm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappwasm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append(dymensionGenesisKV, cosmos.GenesisKV{ @@ -997,7 +1016,7 @@ func TestIBCPFM_RollApp1To2WithOutErc20_Wasm(t *testing.T) { EncodingConfig: encodingConfig(), NoHostMount: false, ModifyGenesis: nil, - ConfigFileOverrides: configFileOverrides, + ConfigFileOverrides: configFileOverrides1, }, NumValidators: &numRollAppVals, NumFullNodes: &numRollAppFn, @@ -1062,11 +1081,11 @@ func TestIBCPFM_RollApp1To2WithOutErc20_Wasm(t *testing.T) { // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/ibc_timeout_test.go b/tests/ibc_timeout_test.go index 07f9ec32..8c2bb495 100644 --- a/tests/ibc_timeout_test.go +++ b/tests/ibc_timeout_test.go @@ -32,10 +32,12 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -108,7 +110,7 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -263,10 +265,12 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -339,7 +343,7 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). diff --git a/tests/ibc_transfer_test.go b/tests/ibc_transfer_test.go index 67deb63b..b0883eef 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -29,10 +29,12 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -83,7 +85,7 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -160,9 +162,6 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) - err = r.StopRelayer(ctx, eRep) - require.NoError(t, err) - // Get the IBC denom dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -186,9 +185,6 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { // Assert balance was updated on the hub testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - // wait until the packet is finalized isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) @@ -214,10 +210,12 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -268,7 +266,7 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -344,9 +342,6 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) - err = r.StopRelayer(ctx, eRep) - require.NoError(t, err) - // Get the IBC denom dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -370,12 +365,6 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { // Assert balance was updated on the hub testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) - require.NoError(t, err) - // wait until the packet is finalized isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) diff --git a/tests/rollapp_genesis_event_test.go b/tests/rollapp_genesis_event_test.go index 90fef071..377e4482 100644 --- a/tests/rollapp_genesis_event_test.go +++ b/tests/rollapp_genesis_event_test.go @@ -1,10 +1,10 @@ package tests import ( + "bytes" "context" "fmt" "testing" - "bytes" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -33,10 +33,12 @@ func TestRollappGenesisEvent_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -89,7 +91,7 @@ func TestRollappGenesisEvent_EVM(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -200,7 +202,14 @@ func TestTransferRollAppTriggerGenesis_EVM(t *testing.T) { ctx := context.Background() - configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_1234-1", "0adym", "3s") + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -250,7 +259,7 @@ func TestTransferRollAppTriggerGenesis_EVM(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -357,11 +366,12 @@ func TestTransferRollAppTriggerGenesis_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") modifyGenesisKV := []cosmos.GenesisKV{ { @@ -418,7 +428,7 @@ func TestTransferRollAppTriggerGenesis_Wasm(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -523,7 +533,14 @@ func TestRollAppTransferHubTriggerGenesis_EVM(t *testing.T) { ctx := context.Background() - configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_1234-1", "0adym", "3s") + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -573,7 +590,7 @@ func TestRollAppTransferHubTriggerGenesis_EVM(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -680,11 +697,12 @@ func TestRollAppTransferHubTriggerGenesis_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") modifyGenesisKV := []cosmos.GenesisKV{ { @@ -741,7 +759,7 @@ func TestRollAppTransferHubTriggerGenesis_Wasm(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -846,7 +864,14 @@ func TestHubTransferHubTriggerGenesis_EVM(t *testing.T) { ctx := context.Background() - configFileOverrides := overridesDymintToml("dymension", fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()), "rollappevm_1234-1", "0adym", "3s") + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") extraFlags := map[string]interface{}{"genesis-accounts-path": true} @@ -908,7 +933,7 @@ func TestHubTransferHubTriggerGenesis_EVM(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -991,7 +1016,7 @@ func TestHubTransferHubTriggerGenesis_EVM(t *testing.T) { require.NoError(t, err) rollappHeight, err := dymension.Height(ctx) require.NoError(t, err) - + // ibc transfer from hub -> rollapp txHash, err := dymension.Validators[0].SendIBCTransfer(ctx, channel.ChannelID, "validator", transferData, ibc.TransferOptions{}) require.NoError(t, err) @@ -1010,7 +1035,7 @@ func TestHubTransferHubTriggerGenesis_EVM(t *testing.T) { isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - + // Check assets balance testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, dymension, val0Addr, rollappIBCDenom, balance) diff --git a/tests/rollapp_invariant_test.go b/tests/rollapp_invariant_test.go index eab80221..7969b1a6 100644 --- a/tests/rollapp_invariant_test.go +++ b/tests/rollapp_invariant_test.go @@ -26,17 +26,19 @@ func TestRollappInvariant_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -132,11 +134,11 @@ func TestRollappInvariant_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -287,17 +289,19 @@ func TestRollappInvariant_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_12345-1" + rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -393,11 +397,11 @@ func TestRollappInvariant_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/rollapp_upgrade_test.go b/tests/rollapp_upgrade_test.go index ca9d65f2..97481641 100644 --- a/tests/rollapp_upgrade_test.go +++ b/tests/rollapp_upgrade_test.go @@ -30,10 +30,12 @@ func TestRollappUpgradeNonStateBreaking_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -90,7 +92,7 @@ func TestRollappUpgradeNonStateBreaking_EVM(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -229,10 +231,12 @@ func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -289,7 +293,7 @@ func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -428,10 +432,12 @@ func TestRollapp_EVM_Upgrade(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -488,7 +494,7 @@ func TestRollapp_EVM_Upgrade(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). @@ -678,10 +684,12 @@ func TestRollapp_Wasm_Upgrade(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -738,7 +746,7 @@ func TestRollapp_Wasm_Upgrade(t *testing.T) { client, network := test.DockerSetup(t) r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer", network) ic := test.NewSetup(). diff --git a/tests/sequencer_invariant_test.go b/tests/sequencer_invariant_test.go index f9499a54..d6d9a2c9 100644 --- a/tests/sequencer_invariant_test.go +++ b/tests/sequencer_invariant_test.go @@ -26,17 +26,19 @@ func TestSequencerInvariant_EVM(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -132,11 +134,11 @@ func TestSequencerInvariant_EVM(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). @@ -290,17 +292,19 @@ func TestSequencerInvariant_Wasm(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_12345-1" + rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") modifyGenesisKV := append( dymensionGenesisKV, @@ -396,11 +400,11 @@ func TestSequencerInvariant_Wasm(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup(). diff --git a/tests/setup.go b/tests/setup.go index 843c5c93..a205c722 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -56,12 +56,12 @@ var ( DymensionMainRepo = "ghcr.io/dymensionxyz/dymension" - RollappEVMMainRepo = "ghcr.io/dymensionxyz/rollapp-evm" + RollappEVMMainRepo = "ghcr.io/decentrio/rollapp-evm" RollappWasmMainRepo = "ghcr.io/dymensionxyz/rollapp-wasm" - IBCRelayerImage = "ghcr.io/decentrio/relayer" - IBCRelayerVersion = "main" + IBCRelayerImage = "ghcr.io/dymensionxyz/go-relayer" + IBCRelayerVersion = "main-dym" dymensionVersion, rollappEVMVersion, rollappWasmVersion = GetDockerImageVersion() @@ -75,7 +75,7 @@ var ( rollappEVMImage = ibc.DockerImage{ Repository: RollappEVMMainRepo, - Version: rollappEVMVersion, + Version: "debug", UidGid: "1025:1025", } @@ -576,15 +576,17 @@ func registerGenesisEventTriggerer(t *testing.T, targetChain *cosmos.CosmosChain require.Equal(t, string(deployerWhitelistParams), newParams.Value) } -func overridesDymintToml(settlemenLayer, nodeAddress, rollappId, gasPrices, emptyBlocksMaxTime string) map[string]any { +func overridesDymintToml(settlemenLayer, nodeAddress, rollappId, gasPrices, maxIdleTime, maxProofTime, batchSubmitMaxTime string) map[string]any { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = settlemenLayer - dymintTomlOverrides["node_address"] = nodeAddress + dymintTomlOverrides["settlement_node_address"] = nodeAddress dymintTomlOverrides["rollapp_id"] = rollappId - dymintTomlOverrides["gas_prices"] = gasPrices - dymintTomlOverrides["empty_blocks_max_time"] = emptyBlocksMaxTime + dymintTomlOverrides["settlement_gas_prices"] = gasPrices + dymintTomlOverrides["max_idle_time"] = maxIdleTime + dymintTomlOverrides["max_proof_time"] = maxProofTime + dymintTomlOverrides["batch_submit_max_time"] = batchSubmitMaxTime configFileOverrides["config/dymint.toml"] = dymintTomlOverrides diff --git a/tests/tx_batch_finalization_test.go b/tests/tx_batch_finalization_test.go index 7ecacd65..11c0edab 100644 --- a/tests/tx_batch_finalization_test.go +++ b/tests/tx_batch_finalization_test.go @@ -37,10 +37,12 @@ func TestBatchFinalization_EVM(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" modifyGenesisKV := append( dymensionGenesisKV, @@ -173,10 +175,12 @@ func TestBatchFinalization_Wasm(t *testing.T) { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" modifyGenesisKV := append( dymensionGenesisKV, diff --git a/tests/upgrade_hub_test.go b/tests/upgrade_hub_test.go index db4d7801..f80ff996 100644 --- a/tests/upgrade_hub_test.go +++ b/tests/upgrade_hub_test.go @@ -42,17 +42,19 @@ func TestHubUpgrade(t *testing.T) { // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" - node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) rollapp1_id := "rollappevm_1234-1" gas_price_rollapp1 := "0adym" - emptyBlocksMaxTime := "3s" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, node_address, rollapp1_id, gas_price_rollapp1, emptyBlocksMaxTime) + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_12345-1" + rollapp2_id := "rollappevm_12345-1" gas_price_rollapp2 := "0adym" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, node_address, rollapp2_id, gas_price_rollapp2, emptyBlocksMaxTime) + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") // Create chain factory with dymension numHubVals := 1 @@ -142,11 +144,11 @@ func TestHubUpgrade(t *testing.T) { client, network := test.DockerSetup(t) // relayer for rollapp 1 r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer1", network) // relayer for rollapp 2 r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + relayer.CustomDockerImage("ghcr.io/dymensionxyz/go-relayer", "main-dym", "100:1000"), ).Build(t, client, "relayer2", network) ic := test.NewSetup().AddRollUp(dymension, rollapp1, rollapp2). From 5db3619618be793114325693b795cb332af9ca1a Mon Sep 17 00:00:00 2001 From: Hoang Do Date: Thu, 23 May 2024 17:24:28 +0700 Subject: [PATCH 54/61] Feat(e2e): Add test for rollapp freeze non broken invariants (#195) Co-authored-by: anhductn2001 --- Makefile | 7 + tests/frozen_test.go | 624 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 631 insertions(+) diff --git a/Makefile b/Makefile index 2eeb0218..754a5c84 100644 --- a/Makefile +++ b/Makefile @@ -82,6 +82,9 @@ e2e-test-fullnode-sync-evm: clean-e2e e2e-test-rollapp-freeze-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollAppFreeze_EVM . + +e2e-test-rollapp-freeze-non-broken-invariant-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestRollAppFreezeNoBrokenInvariants_EVM . e2e-test-other-rollapp-not-affected-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestOtherRollappNotAffected_EVM . @@ -190,6 +193,10 @@ e2e-test-fullnode-sync-wasm: clean-e2e e2e-test-rollapp-freeze-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollAppFreeze_Wasm . + +e2e-test-rollapp-freeze-non-broken-invariant-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestRollAppFreezeNoBrokenInvariants_Wasm . + e2e-test-other-rollapp-not-affected-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestOtherRollappNotAffected_Wasm . diff --git a/tests/frozen_test.go b/tests/frozen_test.go index e9e11753..4d08006b 100644 --- a/tests/frozen_test.go +++ b/tests/frozen_test.go @@ -1539,6 +1539,630 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { require.Equal(t, true, dymUserUpdateBal2.Equal(dymUserOriginBal2.Add(transferAmount)), "dym hub balance did not change") } +// TestRollAppFreezeNoBrokenInvariants_EVM ensure upon freeze gov proposal passed, no updates can be made to the rollapp evm. No invariants broken. +func TestRollAppFreezeNoBrokenInvariants_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp1", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "118", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + + s := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r, "relayer1"). + AddRelayer(s, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: s, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Start both relayers + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = s.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + t.Cleanup( + func() { + err = r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + + err = s.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) + + // Get our Bech32 encoded user addresses + dymensionUser, rollapp1User, rollapp2User := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollapp1UserAddr := rollapp1User.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollapp1UserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + rollapp2OrigBal, err := rollapp2.GetBalance(ctx, rollapp2UserAddr, rollapp2.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollapp2OrigBal) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + sequencerAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", keyDir) + require.NoError(t, err) + + // IBC channel for rollapps + channsDym1, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym1, 2) + + channsDym2, err := s.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym2, 2) + + channsRollApp1, err := r.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channDymRollApp1 := channsRollApp1[0].Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + channsRollApp1Dym := channsRollApp1[0] + require.NotEmpty(t, channsRollApp1Dym.ChannelID) + + channsRollApp2, err := s.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp2, 1) + + channDymRollApp2 := channsRollApp2[0].Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + channsRollApp2Dym := channsRollApp2[0] + require.NotEmpty(t, channsRollApp2Dym.ChannelID) + + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + + // Access the index value + index := oldLatestIndex.StateIndex.Index + oldUintIndex, err := strconv.ParseUint(index, 10, 64) + require.NoError(t, err) + + targetIndex := oldUintIndex + 1 + + // Loop until the latest index updates + for { + latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + + index := latestIndex.StateIndex.Index + uintIndex, err := strconv.ParseUint(index, 10, 64) + require.NoError(t, err) + + if uintIndex >= targetIndex { + break + } + } + + submitFraudStr := "fraud" + deposit := "500000000000" + dymension.Config().Denom + + rollappHeight, err := rollapp1.Height(ctx) + require.NoError(t, err) + + fraudHeight := fmt.Sprint(rollappHeight - 5) + + dymClients, err := r.GetClients(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 2, len(dymClients)) + + var rollapp1ClientOnDym string + + for _, client := range dymClients { + if client.ClientState.ChainID == rollapp1.Config().ChainID { + rollapp1ClientOnDym = client.ClientID + } + } + + propTx, err := dymension.SubmitFraudProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fraudHeight, sequencerAddr, rollapp1ClientOnDym, submitFraudStr, submitFraudStr, deposit) + require.NoError(t, err) + + err = dymension.VoteOnProposalAllValidators(ctx, propTx.ProposalID, cosmos.ProposalVoteYes) + require.NoError(t, err, "failed to submit votes") + + height, err := dymension.Height(ctx) + require.NoError(t, err, "error fetching height") + + _, err = cosmos.PollForProposalStatus(ctx, dymension.CosmosChain, height, height+20, propTx.ProposalID, cosmos.ProposalStatusPassed) + require.NoError(t, err, "proposal status did not change to passed") + + // Check if rollapp1 has frozen or not + rollappParams, err := dymension.QueryRollappParams(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, true, rollappParams.Rollapp.Frozen, "rollapp does not frozen") + + // Check rollapp1 state index not increment + latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, fmt.Sprint(targetIndex), latestIndex.StateIndex.Index, "rollapp state index still increment") + + // Run invariant check + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "block-height-to-finalization-queue") + require.NoError(t, err) + +} + +// TestRollAppFreezeNoBrokenInvariants_Wasm ensure upon freeze gov proposal passed, no updates can be made to the rollapp wasm. No invariants broken. +func TestRollAppFreezeNoBrokenInvariants_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappewasm_2-1" + gas_price_rollapp2 := "0adym" + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp2", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "118", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + + s := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r, "relayer1"). + AddRelayer(s, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: s, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Start both relayers + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = s.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + t.Cleanup( + func() { + err = r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + + err = s.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) + + // Get our Bech32 encoded user addresses + dymensionUser, rollapp1User, rollapp2User := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollapp1UserAddr := rollapp1User.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollapp1UserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + rollapp2OrigBal, err := rollapp2.GetBalance(ctx, rollapp2UserAddr, rollapp2.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollapp2OrigBal) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + sequencerAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", keyDir) + require.NoError(t, err) + + // IBC channel for rollapps + channsDym1, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym1, 2) + + channsDym2, err := s.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym2, 2) + + channsRollApp1, err := r.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channDymRollApp1 := channsRollApp1[0].Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + channsRollApp1Dym := channsRollApp1[0] + require.NotEmpty(t, channsRollApp1Dym.ChannelID) + + channsRollApp2, err := s.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp2, 1) + + channDymRollApp2 := channsRollApp2[0].Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + channsRollApp2Dym := channsRollApp2[0] + require.NotEmpty(t, channsRollApp2Dym.ChannelID) + + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + + // Access the index value + index := oldLatestIndex.StateIndex.Index + oldUintIndex, err := strconv.ParseUint(index, 10, 64) + require.NoError(t, err) + + targetIndex := oldUintIndex + 1 + + // Loop until the latest index updates + for { + latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + + index := latestIndex.StateIndex.Index + uintIndex, err := strconv.ParseUint(index, 10, 64) + require.NoError(t, err) + + if uintIndex >= targetIndex { + break + } + } + + submitFraudStr := "fraud" + deposit := "500000000000" + dymension.Config().Denom + + rollappHeight, err := rollapp1.Height(ctx) + require.NoError(t, err) + + fraudHeight := fmt.Sprint(rollappHeight - 5) + + dymClients, err := r.GetClients(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 2, len(dymClients)) + + var rollapp1ClientOnDym string + + for _, client := range dymClients { + if client.ClientState.ChainID == rollapp1.Config().ChainID { + rollapp1ClientOnDym = client.ClientID + } + } + + propTx, err := dymension.SubmitFraudProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fraudHeight, sequencerAddr, rollapp1ClientOnDym, submitFraudStr, submitFraudStr, deposit) + require.NoError(t, err) + + err = dymension.VoteOnProposalAllValidators(ctx, propTx.ProposalID, cosmos.ProposalVoteYes) + require.NoError(t, err, "failed to submit votes") + + height, err := dymension.Height(ctx) + require.NoError(t, err, "error fetching height") + + _, err = cosmos.PollForProposalStatus(ctx, dymension.CosmosChain, height, height+20, propTx.ProposalID, cosmos.ProposalStatusPassed) + require.NoError(t, err, "proposal status did not change to passed") + + // Check if rollapp1 has frozen or not + rollappParams, err := dymension.QueryRollappParams(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, true, rollappParams.Rollapp.Frozen, "rollapp does not frozen") + + // Check rollapp1 state index not increment + latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, fmt.Sprint(targetIndex), latestIndex.StateIndex.Index, "rollapp state index still increment") + + // Run invariant check + _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "block-height-to-finalization-queue") + require.NoError(t, err) + +} + func GetIBCDenom(counterPartyPort, counterPartyChannel, denom string) string { prefixDenom := transfertypes.GetPrefixedDenom(counterPartyPort, counterPartyChannel, denom) ibcDenom := transfertypes.ParseDenomTrace(prefixDenom).IBCDenom() From 3f6a0b709e2b9c0cd081ad84878df68900bec30a Mon Sep 17 00:00:00 2001 From: Hoang Do Date: Thu, 23 May 2024 19:14:12 +0700 Subject: [PATCH 55/61] Feat: ibc packet rollback on rollapp freeze (#199) Co-authored-by: anhductn2001 --- Makefile | 6 + tests/frozen_test.go | 766 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 770 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 754a5c84..1edc9856 100644 --- a/Makefile +++ b/Makefile @@ -89,6 +89,9 @@ e2e-test-rollapp-freeze-non-broken-invariant-evm: clean-e2e e2e-test-other-rollapp-not-affected-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestOtherRollappNotAffected_EVM . +e2e-test-freeze-packets-rollback-evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestPacketRollbacked_EVM . + e2e-test-rollapp-genesis-event-evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollappGenesisEvent_EVM . @@ -201,6 +204,9 @@ e2e-test-rollapp-freeze-non-broken-invariant-wasm: clean-e2e e2e-test-other-rollapp-not-affected-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestOtherRollappNotAffected_Wasm . +e2e-test-freeze-packets-rollback-wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestPacketRollbacked_Wasm . + e2e-test-eibc-not-fulfillment-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestEIBCNotFulfillment_Wasm . diff --git a/tests/frozen_test.go b/tests/frozen_test.go index 4d08006b..4d1908bc 100644 --- a/tests/frozen_test.go +++ b/tests/frozen_test.go @@ -7,6 +7,7 @@ import ( "strings" "testing" + "cosmossdk.io/math" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" @@ -1539,6 +1540,769 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { require.Equal(t, true, dymUserUpdateBal2.Equal(dymUserOriginBal2.Add(transferAmount)), "dym hub balance did not change") } +// TestPacketRollbacked_EVM ensure upon freeze gov proposal passed, ibc-transfer that not yet finalized's packets will be reverted. +func TestPacketRollbacked_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappevm_12345-1" + gas_price_rollapp2 := "0adym" + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp1", + ChainID: "rollappevm_12345-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "118", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + + s := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r, "relayer1"). + AddRelayer(s, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: s, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Start both relayers + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = s.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + t.Cleanup( + func() { + err = r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + + err = s.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) + + // Get our Bech32 encoded user addresses + dymensionUser, rollapp1User, rollapp2User := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollapp1UserAddr := rollapp1User.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollapp1UserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + rollapp2OrigBal, err := rollapp2.GetBalance(ctx, rollapp2UserAddr, rollapp2.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollapp2OrigBal) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + sequencerAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", keyDir) + require.NoError(t, err) + + // IBC channel for rollapps + channsDym1, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym1, 2) + + channsDym2, err := s.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym2, 2) + + channsRollApp1, err := r.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channDymRollApp1 := channsRollApp1[0].Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + channsRollApp1Dym := channsRollApp1[0] + require.NotEmpty(t, channsRollApp1Dym.ChannelID) + + channsRollApp2, err := s.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp2, 1) + + channDymRollApp2 := channsRollApp2[0].Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + channsRollApp2Dym := channsRollApp2[0] + require.NotEmpty(t, channsRollApp2Dym.ChannelID) + + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + // Confirm previous ibc transfers were successful (dymension -> rollapp1) + // Get the IBC denom + rollapp1IbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) + dymToRollapp1IbcDenom := GetIBCDenom(channsRollApp1Dym.PortID, channsRollApp1Dym.ChannelID, dymension.Config().Denom) + + // Get origin rollapp1 denom balance + rollapp1OriginBal1, err := rollapp1.GetBalance(ctx, rollapp1UserAddr, dymToRollapp1IbcDenom) + fmt.Println("rollapp1OriginBal1", rollapp1OriginBal1) + require.NoError(t, err) + + // IBC Transfer working between Dymension <-> rollapp1 + transferDataFromDym := ibc.WalletData{ + Address: rollapp1UserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount.Quo(math.NewInt(4)), + } + + var options ibc.TransferOptions + _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferDataFromDym, ibc.TransferOptions{}) + require.NoError(t, err) + + testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + + rollapp1UserUpdateBal, err := rollapp1.GetBalance(ctx, rollapp1UserAddr, dymToRollapp1IbcDenom) + require.NoError(t, err) + + require.Equal(t, true, rollapp1OriginBal1.Add(transferAmount.Quo(math.NewInt(4))).Equal(rollapp1UserUpdateBal), "rollapp balance did not change") + // verified ibc transfers worked + + // Create some pending eIBC packet + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + // IBC Transfer working between rollapp1 <-> Dymension + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, options) + require.NoError(t, err) + dymUserRollapp1bal, err := dymension.GetBalance(ctx, dymensionUserAddr, rollapp1IbcDenom) + require.NoError(t, err) + + require.Equal(t, true, dymUserRollapp1bal.Equal(zeroBal), "dym hub balance changed") + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + + for i, eibcEvent := range eibcEvents { + fmt.Println(i, "EIBC Event:", eibcEvent) + } + + oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + + // Access the index value + index := oldLatestIndex.StateIndex.Index + oldUintIndex, err := strconv.ParseUint(index, 10, 64) + require.NoError(t, err) + + targetIndex := oldUintIndex + 1 + + // Loop until the latest index updates + for { + latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + + index := latestIndex.StateIndex.Index + uintIndex, err := strconv.ParseUint(index, 10, 64) + require.NoError(t, err) + + if uintIndex >= targetIndex { + break + } + } + + submitFraudStr := "fraud" + deposit := "500000000000" + dymension.Config().Denom + + // Get new height after frozen + rollappHeight, err := rollapp1.Height(ctx) + require.NoError(t, err) + + fraudHeight := fmt.Sprint(rollappHeight - 5) + + dymClients, err := r.GetClients(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 2, len(dymClients)) + + var rollapp1ClientOnDym string + + for _, client := range dymClients { + if client.ClientState.ChainID == rollapp1.Config().ChainID { + rollapp1ClientOnDym = client.ClientID + } + } + + // SEND IBC transfer right before vote + dymUserOriginBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferDataFromDym, ibc.TransferOptions{}) + require.NoError(t, err) + + // Submit fraud proposal + propTx, err := dymension.SubmitFraudProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fraudHeight, sequencerAddr, rollapp1ClientOnDym, submitFraudStr, submitFraudStr, deposit) + require.NoError(t, err) + + err = dymension.VoteOnProposalAllValidators(ctx, propTx.ProposalID, cosmos.ProposalVoteYes) + require.NoError(t, err, "failed to submit votes") + + height, err := dymension.Height(ctx) + require.NoError(t, err, "error fetching height") + + _, err = cosmos.PollForProposalStatus(ctx, dymension.CosmosChain, height, height+20, propTx.ProposalID, cosmos.ProposalStatusPassed) + require.NoError(t, err, "proposal status did not change to passed") + + latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + // after Grace period, the latest index should be the same + lalatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.Equal(t, latestIndex, lalatestIndex, "rollapp state index still increment after grace period. Rerun") + + // Check if rollapp1 has frozen or not + rollappParams, err := dymension.QueryRollappParams(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, true, rollappParams.Rollapp.Frozen, "rollapp does not frozen") + + // Check rollapp1 state index not increment + require.NoError(t, err) + require.Equal(t, fmt.Sprint(targetIndex), latestIndex.StateIndex.Index, "rollapp state index still increment") + + // After rollapp frozen, fund should return + dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.Equal(t, dymUserOriginBal, dymUserUpdateBal, "funds aren't sent back to sender") +} + +// TestPacketRollbacked_Wasm ensure upon freeze gov proposal passed, ibc-transfer that not yet finalized's packets will be reverted. +func TestPacketRollbacked_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + + // setup config for rollapp 2 + settlement_layer_rollapp2 := "dymension" + rollapp2_id := "rollappwasm_12345-1" + gas_price_rollapp2 := "0adym" + maxIdleTime2 := "3s" + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides1, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "rollapp2", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp1", + ChainID: "rollappwasm_12345-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides2, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + rollapp2 := chains[1].(*dym_rollapp.DymRollApp) + dymension := chains[2].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + + s := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1, rollapp2). + AddRelayer(r, "relayer1"). + AddRelayer(s, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp2, + Relayer: s, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, s, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) + + // Start both relayers + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = s.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + t.Cleanup( + func() { + err = r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + + err = s.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) + + // Get our Bech32 encoded user addresses + dymensionUser, rollapp1User, rollapp2User := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollapp1UserAddr := rollapp1User.FormattedAddress() + rollapp2UserAddr := rollapp2User.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollapp1UserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + rollapp2OrigBal, err := rollapp2.GetBalance(ctx, rollapp2UserAddr, rollapp2.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollapp2OrigBal) + + keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir() + sequencerAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", keyDir) + require.NoError(t, err) + + // IBC channel for rollapps + channsDym1, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym1, 2) + + channsDym2, err := s.GetChannels(ctx, eRep, dymension.GetChainID()) + require.NoError(t, err) + require.Len(t, channsDym2, 2) + + channsRollApp1, err := r.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channDymRollApp1 := channsRollApp1[0].Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + + channsRollApp1Dym := channsRollApp1[0] + require.NotEmpty(t, channsRollApp1Dym.ChannelID) + + channsRollApp2, err := s.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp2, 1) + + channDymRollApp2 := channsRollApp2[0].Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + channsRollApp2Dym := channsRollApp2[0] + require.NotEmpty(t, channsRollApp2Dym.ChannelID) + + triggerHubGenesisEvent(t, dymension, + rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser.KeyName(), + }, rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser.KeyName(), + }) + + // Confirm previous ibc transfers were successful (dymension -> rollapp1) + // Get the IBC denom + rollapp1IbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) + dymToRollapp1IbcDenom := GetIBCDenom(channsRollApp1Dym.PortID, channsRollApp1Dym.ChannelID, dymension.Config().Denom) + + // Get origin rollapp1 denom balance + rollapp1OriginBal1, err := rollapp1.GetBalance(ctx, rollapp1UserAddr, dymToRollapp1IbcDenom) + fmt.Println("rollapp1OriginBal1", rollapp1OriginBal1) + require.NoError(t, err) + + // IBC Transfer working between Dymension <-> rollapp1 + transferDataFromDym := ibc.WalletData{ + Address: rollapp1UserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount.Quo(math.NewInt(4)), + } + + var options ibc.TransferOptions + _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferDataFromDym, ibc.TransferOptions{}) + require.NoError(t, err) + + testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + + rollapp1UserUpdateBal, err := rollapp1.GetBalance(ctx, rollapp1UserAddr, dymToRollapp1IbcDenom) + require.NoError(t, err) + + require.Equal(t, true, rollapp1OriginBal1.Add(transferAmount.Quo(math.NewInt(4))).Equal(rollapp1UserUpdateBal), "rollapp balance did not change") + // verified ibc transfers worked + + // Create some pending eIBC packet + multiplier := math.NewInt(10) + + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + // IBC Transfer working between rollapp1 <-> Dymension + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, options) + require.NoError(t, err) + dymUserRollapp1bal, err := dymension.GetBalance(ctx, dymensionUserAddr, rollapp1IbcDenom) + require.NoError(t, err) + + require.Equal(t, true, dymUserRollapp1bal.Equal(zeroBal), "dym hub balance changed") + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + + for i, eibcEvent := range eibcEvents { + fmt.Println(i, "EIBC Event:", eibcEvent) + } + + oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + + // Access the index value + index := oldLatestIndex.StateIndex.Index + oldUintIndex, err := strconv.ParseUint(index, 10, 64) + require.NoError(t, err) + + targetIndex := oldUintIndex + 1 + + // Loop until the latest index updates + for { + latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + + index := latestIndex.StateIndex.Index + uintIndex, err := strconv.ParseUint(index, 10, 64) + require.NoError(t, err) + + if uintIndex >= targetIndex { + break + } + } + + submitFraudStr := "fraud" + deposit := "500000000000" + dymension.Config().Denom + + // Get new height after frozen + rollappHeight, err := rollapp1.Height(ctx) + require.NoError(t, err) + + fraudHeight := fmt.Sprint(rollappHeight - 5) + + dymClients, err := r.GetClients(ctx, eRep, dymension.Config().ChainID) + require.NoError(t, err) + require.Equal(t, 2, len(dymClients)) + + var rollapp1ClientOnDym string + + for _, client := range dymClients { + if client.ClientState.ChainID == rollapp1.Config().ChainID { + rollapp1ClientOnDym = client.ClientID + } + } + + // SEND IBC transfer right before vote + dymUserOriginBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferDataFromDym, ibc.TransferOptions{}) + require.NoError(t, err) + + // Submit fraud proposal + propTx, err := dymension.SubmitFraudProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fraudHeight, sequencerAddr, rollapp1ClientOnDym, submitFraudStr, submitFraudStr, deposit) + require.NoError(t, err) + + err = dymension.VoteOnProposalAllValidators(ctx, propTx.ProposalID, cosmos.ProposalVoteYes) + require.NoError(t, err, "failed to submit votes") + + height, err := dymension.Height(ctx) + require.NoError(t, err, "error fetching height") + + _, err = cosmos.PollForProposalStatus(ctx, dymension.CosmosChain, height, height+20, propTx.ProposalID, cosmos.ProposalStatusPassed) + require.NoError(t, err, "proposal status did not change to passed") + + latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + // after Grace period, the latest index should be the same + lalatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.Equal(t, latestIndex, lalatestIndex, "rollapp state index still increment after grace period. Rerun") + + // Check if rollapp1 has frozen or not + rollappParams, err := dymension.QueryRollappParams(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, true, rollappParams.Rollapp.Frozen, "rollapp does not frozen") + + // Check rollapp1 state index not increment + require.NoError(t, err) + require.Equal(t, fmt.Sprint(targetIndex), latestIndex.StateIndex.Index, "rollapp state index still increment") + + // After rollapp frozen, fund should return + dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.Equal(t, dymUserOriginBal, dymUserUpdateBal, "funds aren't sent back to sender") +} + // TestRollAppFreezeNoBrokenInvariants_EVM ensure upon freeze gov proposal passed, no updates can be made to the rollapp evm. No invariants broken. func TestRollAppFreezeNoBrokenInvariants_EVM(t *testing.T) { if testing.Short() { @@ -1848,7 +2612,6 @@ func TestRollAppFreezeNoBrokenInvariants_EVM(t *testing.T) { // Run invariant check _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "block-height-to-finalization-queue") require.NoError(t, err) - } // TestRollAppFreezeNoBrokenInvariants_Wasm ensure upon freeze gov proposal passed, no updates can be made to the rollapp wasm. No invariants broken. @@ -2160,7 +2923,6 @@ func TestRollAppFreezeNoBrokenInvariants_Wasm(t *testing.T) { // Run invariant check _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "block-height-to-finalization-queue") require.NoError(t, err) - } func GetIBCDenom(counterPartyPort, counterPartyChannel, denom string) string { From 652b1ddfbde6e8d1d57bb762866d79f0027401a9 Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Thu, 23 May 2024 19:30:40 +0700 Subject: [PATCH 56/61] =?UTF-8?q?test:=20transfer=20rollapp=20tokens=20bet?= =?UTF-8?q?ween=20hub=20=E2=86=94=20rollapp=20BEFORE=20rollapp=20has=20any?= =?UTF-8?q?=20finalized=20state=20on=20the=20hub=20(#194)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: anhductn2001 --- Makefile | 6 + tests/rollapp_genesis_event_test.go | 432 ++++++++++++++++++++++++++++ 2 files changed, 438 insertions(+) diff --git a/Makefile b/Makefile index 1edc9856..c7a787f7 100644 --- a/Makefile +++ b/Makefile @@ -146,6 +146,9 @@ e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_hub_evm: clean-e2e e2e-test-rollapp_genesis_transfer_hub_to_rollapp_with_trigger_hub_evm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestHubTransferHubTriggerGenesis_EVM . +e2e-test-rollapp_genesis_transfer_back_and_forth_with_trigger_both_evm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestTransferTriggerGenesisBoth_EVM . + # Executes IBC tests via rollup-e2e-testing e2e-test-ibc-success-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestIBCTransferSuccess_Wasm . @@ -255,6 +258,9 @@ e2e-test-rollapp_genesis_transfer_rollapp_to_hub_with_trigger_hub_wasm: clean-e2 e2e-test-rollapp-upgrade-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestRollapp_Wasm_Upgrade . +e2e-test-rollapp_genesis_transfer_back_and_forth_with_trigger_both_wasm: clean-e2e + cd tests && go test -timeout=25m -race -v -run TestTransferTriggerGenesisBoth_Wasm . + # Executes all tests via rollup-e2e-testing e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ diff --git a/tests/rollapp_genesis_event_test.go b/tests/rollapp_genesis_event_test.go index 377e4482..2c1dcb65 100644 --- a/tests/rollapp_genesis_event_test.go +++ b/tests/rollapp_genesis_event_test.go @@ -1049,3 +1049,435 @@ func TestHubTransferHubTriggerGenesis_EVM(t *testing.T) { }, ) } + +func TestTransferTriggerGenesisBoth_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + + extraFlags := map[string]interface{}{"genesis-accounts-path": true} + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, rollapp1, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser1, dymensionUser2, rollappUser1, rollappUser2, rollappUser3 := users[0], users[1], users[2], users[3], users[4] + + dymensionUserAddr1 := dymensionUser1.FormattedAddress() + dymensionUserAddr2 := dymensionUser2.FormattedAddress() + rollappUserAddr1 := rollappUser1.FormattedAddress() + rollappUserAddr2 := rollappUser2.FormattedAddress() + rollappUserAddr3 := rollappUser3.FormattedAddress() + + // Get original account balances + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr1, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr2, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr1, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr2, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr3, rollapp1.Config().Denom, walletAmount) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + rollapp_params := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser1.KeyName(), + } + // trigger genesis event for hub and rollapp + triggerHubGenesisEvent(t, dymension, rollapp_params) + + registerGenesisEventTriggerer(t, rollapp1.CosmosChain, rollappUser1.KeyName(), rollappUserAddr1, "hubgenesis", "GenesisTriggererAllowlist") + _, err = rollapp1.Validators[0].ExecTx(ctx, rollappUserAddr1, "hubgenesis", "genesis-event", dymension.GetChainID(), channel.ChannelID) + require.NoError(t, err) + + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + // get roll app height + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // transfer from hub to rollapp + transferHubToRollAppData := ibc.WalletData{ + Address: rollappUserAddr1, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from Hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr1, transferHubToRollAppData, ibc.TransferOptions{}) + require.NoError(t, err) + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr1, dymension.Config().Denom, walletAmount.Sub(transferHubToRollAppData.Amount)) + + // transfer from roll app to hub + transferRollAppToHubData := ibc.WalletData{ + Address: dymensionUserAddr2, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr2, transferRollAppToHubData, ibc.TransferOptions{}) + require.NoError(t, err) + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr2, rollapp1.Config().Denom, walletAmount.Sub(transferHubToRollAppData.Amount)) + + // transfer from genesis acount on hub to roll app + transferFromGenesisAccountToRollappData := ibc.WalletData{ + Address: rollappUserAddr3, + Denom: rollappIBCDenom, + Amount: transferAmount, + } + // get val0 address + val0Addr, err := dymension.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) + + balance, err := dymension.GetBalance(ctx, val0Addr, rollappIBCDenom) + require.NoError(t, err) + // ibc transfer from hub -> rollapp + _, err = dymension.Validators[0].SendIBCTransfer(ctx, channel.ChannelID, "validator", transferFromGenesisAccountToRollappData, ibc.TransferOptions{}) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, dymension, val0Addr, rollappIBCDenom, balance.Sub(transferFromGenesisAccountToRollappData.Amount)) + + // check rollapp don't has any finalized state on the hub + _, err = dymension.QueryRollappState(ctx, rollapp1.Config().Name, true) + require.Error(t, err) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + // wait until packet finalization and verify funds + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // check asset balance for transfer from hub to roll app + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr1, dymension.Config().Denom, walletAmount.Sub(transferHubToRollAppData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr1, dymensionIBCDenom, transferAmount) + // check asset balance for transfer from roll app to roll app + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr2, rollapp1.Config().Denom, walletAmount.Sub(transferRollAppToHubData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr2, rollappIBCDenom, transferAmount) + // check asset balance for transfer from genesis account on hub to roll app + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr3, rollapp1.Config().Denom, walletAmount.Add(transferFromGenesisAccountToRollappData.Amount)) + testutil.AssertBalance(t, ctx, dymension, val0Addr, rollappIBCDenom, balance.Sub(transferFromGenesisAccountToRollappData.Amount)) + + t.Cleanup( + func() { + err := r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} + +func TestTransferTriggerGenesisBoth_Wasm(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappwasm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + + extraFlags := map[string]interface{}{"genesis-accounts-path": true} + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappwasm_1234-1", + Images: []ibc.DockerImage{rollappWasmImage}, + Bin: "rollappd", + Bech32Prefix: "rol", + Denom: "urax", + CoinType: "118", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: nil, + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + ExtraFlags: extraFlags, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }) + require.NoError(t, err) + + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, rollapp1, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser1, dymensionUser2, rollappUser1, rollappUser2, rollappUser3 := users[0], users[1], users[2], users[3], users[4] + + dymensionUserAddr1 := dymensionUser1.FormattedAddress() + dymensionUserAddr2 := dymensionUser2.FormattedAddress() + rollappUserAddr1 := rollappUser1.FormattedAddress() + rollappUserAddr2 := rollappUser2.FormattedAddress() + rollappUserAddr3 := rollappUser3.FormattedAddress() + + // Get original account balances + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr1, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr2, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr1, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr2, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr3, rollapp1.Config().Denom, walletAmount) + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + rollapp_params := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channel.ChannelID, + userKey: dymensionUser1.KeyName(), + } + // trigger genesis event for hub and rollapp + triggerHubGenesisEvent(t, dymension, rollapp_params) + + registerGenesisEventTriggerer(t, rollapp1.CosmosChain, rollappUser1.KeyName(), rollappUserAddr1, "hubgenesis", "GenesisTriggererAllowlist") + _, err = rollapp1.Validators[0].ExecTx(ctx, rollappUserAddr1, "hubgenesis", "genesis-event", dymension.GetChainID(), channel.ChannelID) + require.NoError(t, err) + + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + // get roll app height + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // transfer from hub to rollapp + transferHubToRollAppData := ibc.WalletData{ + Address: rollappUserAddr1, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from Hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr1, transferHubToRollAppData, ibc.TransferOptions{}) + require.NoError(t, err) + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr1, dymension.Config().Denom, walletAmount.Sub(transferHubToRollAppData.Amount)) + + // transfer from roll app to hub + transferRollAppToHubData := ibc.WalletData{ + Address: dymensionUserAddr2, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr2, transferRollAppToHubData, ibc.TransferOptions{}) + require.NoError(t, err) + // Assert balance was updated on the rollapp + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr2, rollapp1.Config().Denom, walletAmount.Sub(transferHubToRollAppData.Amount)) + + // transfer from genesis acount on hub to roll app + transferFromGenesisAccountToRollappData := ibc.WalletData{ + Address: rollappUserAddr3, + Denom: rollappIBCDenom, + Amount: transferAmount, + } + // get val0 address + val0Addr, err := dymension.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) + + balance, err := dymension.GetBalance(ctx, val0Addr, rollappIBCDenom) + require.NoError(t, err) + // ibc transfer from hub -> rollapp + _, err = dymension.Validators[0].SendIBCTransfer(ctx, channel.ChannelID, "validator", transferFromGenesisAccountToRollappData, ibc.TransferOptions{}) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, dymension, val0Addr, rollappIBCDenom, balance.Sub(transferFromGenesisAccountToRollappData.Amount)) + + // check rollapp don't has any finalized state on the hub + _, err = dymension.QueryRollappState(ctx, rollapp1.Config().Name, true) + require.Error(t, err) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + // wait until packet finalization and verify funds + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // check asset balance for transfer from hub to roll app + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr1, dymension.Config().Denom, walletAmount.Sub(transferHubToRollAppData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr1, dymensionIBCDenom, transferAmount) + // check asset balance for transfer from roll app to roll app + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr2, rollapp1.Config().Denom, walletAmount.Sub(transferRollAppToHubData.Amount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr2, rollappIBCDenom, transferAmount) + // check asset balance for transfer from genesis account on hub to roll app + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr3, rollapp1.Config().Denom, walletAmount.Add(transferFromGenesisAccountToRollappData.Amount)) + testutil.AssertBalance(t, ctx, dymension, val0Addr, rollappIBCDenom, balance.Sub(transferFromGenesisAccountToRollappData.Amount)) + + t.Cleanup( + func() { + err := r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) +} From f9ba02fb4d5c633f36ef6ce4df7d9f9806a576b7 Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Nhan | Decentrio Date: Thu, 23 May 2024 21:41:48 +0700 Subject: [PATCH 57/61] [test]: test cases ibc and eibc transfer after hub upgrade (#198) --- Makefile | 2 +- tests/eibc_fulfillment_test.go | 312 +++++++++++++++---------- tests/eibc_invariant_test.go | 69 +++--- tests/eibc_pfm_test.go | 69 +++--- tests/eibc_timeout_test.go | 62 +++-- tests/ibc_pfm_test.go | 34 +-- tests/rollapp_genesis_event_test.go | 85 ++++--- tests/upgrade_hub_test.go | 346 ++++++++++++++++++++++++++-- 8 files changed, 710 insertions(+), 269 deletions(-) diff --git a/Makefile b/Makefile index c7a787f7..f5bdcdc2 100644 --- a/Makefile +++ b/Makefile @@ -235,7 +235,7 @@ e2e-test-delayedack-relayer-down-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestDelayedAck_RelayerDown_Wasm . e2e-test-upgrade-hub: clean-e2e - cd tests && go test -timeout=25m -race -v -run TestHubUpgrade . + cd tests && go test -timeout=40m -race -v -run TestHubUpgrade . e2e-test-sequencer-invariant-wasm: clean-e2e cd tests && go test -timeout=25m -race -v -run TestSequencerInvariant_Wasm . diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 7a5ab98e..07f381c0 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -33,20 +33,28 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappevm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := append( dymensionGenesisKV, @@ -404,20 +412,28 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := append( dymensionGenesisKV, @@ -777,20 +793,29 @@ func TestEIBCFulfillment_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappevm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides + modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -1072,21 +1097,28 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -1377,20 +1409,28 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappevm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := append( dymensionGenesisKV, @@ -1760,21 +1800,28 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappevm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -2161,20 +2208,28 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := append( dymensionGenesisKV, @@ -2550,21 +2605,29 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + // setup config for rollapp 1 + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappevm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -2804,21 +2867,28 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ diff --git a/tests/eibc_invariant_test.go b/tests/eibc_invariant_test.go index 940ee8d9..1424f357 100644 --- a/tests/eibc_invariant_test.go +++ b/tests/eibc_invariant_test.go @@ -28,21 +28,28 @@ func TestEIBCInvariant_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappevm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides const EPOCH_IDENTIFIER string = "minute" modifyGenesisKV := append( dymensionGenesisKV, @@ -376,20 +383,28 @@ func TestEIBCInvariant_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides const EPOCH_IDENTIFIER string = "minute" modifyGenesisKV := append( diff --git a/tests/eibc_pfm_test.go b/tests/eibc_pfm_test.go index e0f86d18..cfbda7d1 100644 --- a/tests/eibc_pfm_test.go +++ b/tests/eibc_pfm_test.go @@ -31,21 +31,28 @@ func TestEIBCPFM_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappevm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -311,20 +318,28 @@ func TestEIBCPFM_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension numHubVals := 1 diff --git a/tests/eibc_timeout_test.go b/tests/eibc_timeout_test.go index 562463a7..a8aa4cad 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -273,21 +273,28 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappevm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := append( dymensionGenesisKV, cosmos.GenesisKV{ @@ -653,21 +660,28 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappwasm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 diff --git a/tests/ibc_pfm_test.go b/tests/ibc_pfm_test.go index 2db2d43b..af464b5e 100644 --- a/tests/ibc_pfm_test.go +++ b/tests/ibc_pfm_test.go @@ -528,14 +528,17 @@ func TestIBCTransferGaiaToRollApp_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -771,14 +774,17 @@ func TestIBCTransferGaiaToRollApp_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 diff --git a/tests/rollapp_genesis_event_test.go b/tests/rollapp_genesis_event_test.go index 2c1dcb65..451f9055 100644 --- a/tests/rollapp_genesis_event_test.go +++ b/tests/rollapp_genesis_event_test.go @@ -203,14 +203,17 @@ func TestTransferRollAppTriggerGenesis_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -365,14 +368,17 @@ func TestTransferRollAppTriggerGenesis_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := []cosmos.GenesisKV{ { Key: "app_state.gov.voting_params.voting_period", @@ -534,14 +540,17 @@ func TestRollAppTransferHubTriggerGenesis_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -696,14 +705,17 @@ func TestRollAppTransferHubTriggerGenesis_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := []cosmos.GenesisKV{ { Key: "app_state.gov.voting_params.voting_period", @@ -865,14 +877,17 @@ func TestHubTransferHubTriggerGenesis_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides extraFlags := map[string]interface{}{"genesis-accounts-path": true} // Create chain factory with dymension diff --git a/tests/upgrade_hub_test.go b/tests/upgrade_hub_test.go index f80ff996..f03261a6 100644 --- a/tests/upgrade_hub_test.go +++ b/tests/upgrade_hub_test.go @@ -6,6 +6,8 @@ import ( "testing" "time" + "cosmossdk.io/math" + transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" test "github.com/decentrio/rollup-e2e-testing" "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" @@ -41,21 +43,28 @@ func TestHubUpgrade(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "rollappevm_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_12345-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_max_time"] = "100s" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 0 @@ -200,10 +209,10 @@ func TestHubUpgrade(t *testing.T) { // _ = dymension.StartAllNodes(ctx) //Create some user accounts on both chains - users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1, rollapp2) + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, dymension, dymension, rollapp1, rollapp2) // Get our Bech32 encoded user addresses - dymensionUser, _ := users[0], users[1] + dymensionUser1, dymensionUser2, marketmaker1, marketmaker2, rollappUser1, rollappUser2 := users[0], users[1], users[2], users[3], users[4], users[5] // Wait a few blocks for relayer to start and for user accounts to be created err = testutil.WaitForBlocks(ctx, 5, dymension) @@ -212,8 +221,20 @@ func TestHubUpgrade(t *testing.T) { // Get our Bech32 encoded user addresses // dymensionUser, rollappUser := users[0], users[1] - // dymensionUserAddr := dymensionUser.FormattedAddress() - // rollappUserAddr := rollappUser.FormattedAddress() + dymensionUser1Addr := dymensionUser1.FormattedAddress() + dymensionUser2Addr := dymensionUser2.FormattedAddress() + marketMaker1Addr := marketmaker1.FormattedAddress() + marketMaker2Addr := marketmaker2.FormattedAddress() + rollappUser1Addr := rollappUser1.FormattedAddress() + rollappUser2Addr := rollappUser2.FormattedAddress() + + // Assert the accounts were funded + testutil.AssertBalance(t, ctx, dymension, dymensionUser1Addr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, dymensionUser2Addr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMaker1Addr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, dymension, marketMaker2Addr, dymension.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp1, rollappUser1Addr, rollapp1.Config().Denom, walletAmount) + testutil.AssertBalance(t, ctx, rollapp2, rollappUser2Addr, rollapp2.Config().Denom, walletAmount) height, err := dymension.Height(ctx) require.NoError(t, err, "error fetching height before submit upgrade proposal") @@ -229,7 +250,7 @@ func TestHubUpgrade(t *testing.T) { Info: "Info", } - upgradeTx, err := dymension.UpgradeLegacyProposal(ctx, dymensionUser.KeyName(), proposal) + upgradeTx, err := dymension.UpgradeLegacyProposal(ctx, dymensionUser1.KeyName(), proposal) require.NoError(t, err, "error submitting software upgrade proposal tx") fmt.Println("upgradeTx", upgradeTx) @@ -263,7 +284,7 @@ func TestHubUpgrade(t *testing.T) { // upgrade version on all nodes dymension.UpgradeVersion(ctx, client, DymensionMainRepo, dymensionVersion) - + // dymension.UpgradeVersion(ctx, client, DymensionMainRepo, "v4.0.0") // start all nodes back up. // validators reach consensus on first block after upgrade height // and chain block production resumes. @@ -281,6 +302,279 @@ func TestHubUpgrade(t *testing.T) { require.GreaterOrEqual(t, height, haltHeight+blocksAfterUpgrade, "height did not increment enough after upgrade") + // Get dymension -> rollapp1 channel + channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp1, 1) + + channRollApp1Dym := channsRollApp1[0] + require.NotEmpty(t, channRollApp1Dym.ChannelID) + channDymRollApp1 := channRollApp1Dym.Counterparty + require.NotEmpty(t, channDymRollApp1.ChannelID) + println("port dym rollapp1: ", channDymRollApp1.PortID) + println("channel dym rollapp1: ", channDymRollApp1.ChannelID) + // Get dymension -> rollapp2 channel + channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) + require.NoError(t, err) + require.Len(t, channsRollApp2, 1) + channRollApp2Dym := channsRollApp2[0] + require.NotEmpty(t, channRollApp2Dym.ChannelID) + channDymRollApp2 := channRollApp2Dym.Counterparty + require.NotEmpty(t, channDymRollApp2.ChannelID) + + println("port dym rollapp2: ", channDymRollApp2.PortID) + println("channel dym rollapp2: ", channDymRollApp2.ChannelID) + // Trigger genesis event for rollapp1 + rollapp1Param := rollappParam{ + rollappID: rollapp1.Config().ChainID, + channelID: channDymRollApp1.ChannelID, + userKey: dymensionUser1.KeyName(), + } + + rollapp2Param := rollappParam{ + rollappID: rollapp2.Config().ChainID, + channelID: channDymRollApp2.ChannelID, + userKey: dymensionUser2.KeyName(), + } + triggerHubGenesisEvent(t, dymension, rollapp1Param, rollapp2Param) + + err = r1.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + //SET UP TEST FOR ROLLAPP 1 + // ibc transfer from hub to rollapp1 + transferData := ibc.WalletData{ + Address: rollappUser1Addr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + rollapp1Height, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // Compose an IBC transfer and send from hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUser1Addr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUser1Addr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 400) + require.NoError(t, err) + require.True(t, isFinalized) + + // Get the IBC denom + dymensionTokenDenom1 := transfertypes.GetPrefixedDenom(channDymRollApp1.PortID, channDymRollApp1.ChannelID, dymension.Config().Denom) + dymensionIBCDenom1 := transfertypes.ParseDenomTrace(dymensionTokenDenom1).IBCDenom() + + // check assets balance + testutil.AssertBalance(t, ctx, rollapp1, rollappUser1Addr, dymensionIBCDenom1, transferData.Amount) + testutil.AssertBalance(t, ctx, dymension, dymensionUser1Addr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // MAKE eIBC TRANSFER + // Get the IBC denom for urax on Hub + rollapp1TokenDenom := transfertypes.GetPrefixedDenom(channRollApp1Dym.PortID, channRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) + rollapp1IBCDenom := transfertypes.ParseDenomTrace(rollapp1TokenDenom).IBCDenom() + + var options ibc.TransferOptions + + multiplier := math.NewInt(10) + eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 + transferAmountWithoutFee := transferAmount.Sub(eibcFee) + // set eIBC specific memo + options.Memo = BuildEIbcMemo(eibcFee) + + // Send packet from rollapp1 -> hub market maker + transferData = ibc.WalletData{ + Address: marketMaker1Addr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUser1Addr, transferData, options) + require.NoError(t, err) + rollapp1Height, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized on Rollapp 1 + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 400) + require.NoError(t, err) + require.True(t, isFinalized) + + expMmBalanceRollapp1Denom := transferData.Amount + balance, err := dymension.GetBalance(ctx, marketMaker1Addr, rollapp1IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMaker1Addr after preconditions:", balance) + require.True(t, balance.Equal(expMmBalanceRollapp1Denom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollapp1Denom, balance)) + + transferData = ibc.WalletData{ + Address: dymensionUser1Addr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + // eibc transfer from hub to rollapp1 + _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUser1Addr, transferData, options) + require.NoError(t, err) + + rollapp1Height, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + zeroBalance := math.NewInt(0) + balance, err = dymension.GetBalance(ctx, dymensionUser1Addr, rollapp1IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUser1Addr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) + + // get eIbc event + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + fmt.Println("Events:", eibcEvents) + + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMaker1Addr) + require.NoError(t, err) + eibcEvent := getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUser1Addr, rollapp1IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUser1Addr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmount.Sub(eibcFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMaker1Addr, rollapp1IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMaker1Addr after fulfilling the order:", balance) + expMmBalanceRollapp1Denom = expMmBalanceRollapp1Denom.Sub(transferAmountWithoutFee) + require.True(t, balance.Equal(expMmBalanceRollapp1Denom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollapp1Denom, balance)) + + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMaker1Addr, rollapp1IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMaker1Addr after packet finalization:", balance) + expMmBalanceRollapp1Denom = expMmBalanceRollapp1Denom.Add(transferData.Amount) + require.True(t, balance.Equal(expMmBalanceRollapp1Denom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollapp1Denom, balance)) + + //SET UP TEST FOR ROLLAPP 2 + // ibc transfer from hub to rollapp2 + transferData = ibc.WalletData{ + Address: rollappUser2Addr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + rollapp2Height, err := rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + + // Compose an IBC transfer and send from hub -> rollapp 2 + _, err = dymension.SendIBCTransfer(ctx, channDymRollApp2.ChannelID, dymensionUser2Addr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUser2Addr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollapp2Height, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + // Get the IBC denom + dymensionTokenDenom2 := transfertypes.GetPrefixedDenom(channRollApp2Dym.PortID, channRollApp2Dym.ChannelID, dymension.Config().Denom) + dymensionIBCDenom2 := transfertypes.ParseDenomTrace(dymensionTokenDenom2).IBCDenom() + println("check ibc denom 2: ", dymensionIBCDenom2) + println("check addres rollapp2 user: ", rollappUser2Addr) + // check assets balance + testutil.AssertBalance(t, ctx, dymension, dymensionUser2Addr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp2, rollappUser2Addr, dymensionIBCDenom2, transferData.Amount) + + // MAKE eIBC TRANSFER + // Get the IBC denom for urax on Hub + rollapp2TokenDenom := transfertypes.GetPrefixedDenom(channDymRollApp2.PortID, channDymRollApp2.ChannelID, rollapp2.Config().Denom) + rollapp2IBCDenom := transfertypes.ParseDenomTrace(rollapp2TokenDenom).IBCDenom() + + // Send packet from rollapp2 -> hub market maker + transferData = ibc.WalletData{ + Address: marketMaker2Addr, + Denom: rollapp2.Config().Denom, + Amount: transferAmount, + } + _, err = rollapp2.SendIBCTransfer(ctx, channRollApp2Dym.ChannelID, rollappUser2Addr, transferData, options) + require.NoError(t, err) + rollapp2Height, err = rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized on Rollapp 2 + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollapp2Height, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + expMmBalanceRollapp2Denom := transferData.Amount + balance, err = dymension.GetBalance(ctx, marketMaker2Addr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMaker2Addr after preconditions:", balance) + require.True(t, balance.Equal(expMmBalanceRollapp2Denom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollapp2Denom, balance)) + + transferData = ibc.WalletData{ + Address: dymensionUser2Addr, + Denom: rollapp2.Config().Denom, + Amount: transferAmount, + } + // eibc transfer from hub to rollapp2 + _, err = rollapp2.SendIBCTransfer(ctx, channRollApp2Dym.ChannelID, rollappUser2Addr, transferData, options) + require.NoError(t, err) + + rollapp2Height, err = rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUser2Addr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUser2Addr right after sending eIBC transfer:", balance) + require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) + + // get eIbc event + eibcEvents, err = getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + require.NoError(t, err) + fmt.Println("Events:", eibcEvents) + + txhash, err = dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMaker2Addr) + require.NoError(t, err) + eibcEvent = getEibcEventFromTx(t, dymension, txhash) + if eibcEvent != nil { + fmt.Println("After order fulfillment:", eibcEvent) + } + + // wait a few blocks and verify sender received funds on the hub + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + // verify funds minus fee were added to receiver's address + balance, err = dymension.GetBalance(ctx, dymensionUser2Addr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of dymensionUser2Addr after fulfilling the order:", balance) + require.True(t, balance.Equal(transferAmount.Sub(eibcFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee, balance)) + + // verify funds were deducted from market maker's wallet address + balance, err = dymension.GetBalance(ctx, marketMaker2Addr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMaker2Addr after fulfilling the order:", balance) + expMmBalanceRollapp2Denom = expMmBalanceRollapp2Denom.Sub(transferAmountWithoutFee) + require.True(t, balance.Equal(expMmBalanceRollapp2Denom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollapp2Denom, balance)) + + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollapp2Height, 300) + require.NoError(t, err) + require.True(t, isFinalized) + balance, err = dymension.GetBalance(ctx, marketMaker2Addr, rollapp2IBCDenom) + require.NoError(t, err) + fmt.Println("Balance of marketMaker2Addr after packet finalization:", balance) + expMmBalanceRollapp2Denom = expMmBalanceRollapp2Denom.Add(transferData.Amount) + require.True(t, balance.Equal(expMmBalanceRollapp2Denom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollapp2Denom, balance)) // channel, err := ibc.GetTransferChannel(ctx, r1, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) // require.NoError(t, err) @@ -290,4 +584,16 @@ func TestHubUpgrade(t *testing.T) { // rollappUserAddr, r1, ibcPath, channel, // eRep, ibc.TransferOptions{}) // require.NoError(t, err) + t.Cleanup( + func() { + err := r1.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + }, + ) } From e6e91bf577c4336bf129795c890da874f13648b8 Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Tue, 4 Jun 2024 17:07:52 +0700 Subject: [PATCH 58/61] minor waiting for new image --- .github/workflows/e2e-test-workflow-call.yml | 1 - tests/fullnode_sync_test.go | 39 +++++++++++++++----- tests/setup.go | 1 - 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.github/workflows/e2e-test-workflow-call.yml b/.github/workflows/e2e-test-workflow-call.yml index 0e0d5c2a..617c860e 100644 --- a/.github/workflows/e2e-test-workflow-call.yml +++ b/.github/workflows/e2e-test-workflow-call.yml @@ -143,4 +143,3 @@ jobs: ROLLAPP_WASM_CI: ${{ inputs.rollapp_wasm_ci }} RELAYER_CI: ${{ inputs.relayer_ci }} - diff --git a/tests/fullnode_sync_test.go b/tests/fullnode_sync_test.go index 13b9f022..5696c8da 100644 --- a/tests/fullnode_sync_test.go +++ b/tests/fullnode_sync_test.go @@ -13,6 +13,7 @@ import ( "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" "github.com/decentrio/rollup-e2e-testing/testreporter" "github.com/decentrio/rollup-e2e-testing/testutil" ) @@ -24,15 +25,15 @@ func TestFullnodeSync_EVM(t *testing.T) { ctx := context.Background() - configFileOverrides := make(map[string]any) - dymintTomlOverrides := make(testutil.Toml) - dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -80,8 +81,19 @@ func TestFullnodeSync_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), + ).Build(t, client, "relayer1", network) + ic := test.NewSetup(). - AddRollUp(dymension, rollapp1) + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer1"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) rep := testreporter.NewNopReporter() eRep := rep.RelayerExecReporter(t) @@ -97,10 +109,17 @@ func TestFullnodeSync_EVM(t *testing.T) { }) require.NoError(t, err) + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + // Wait for rollapp finalized rollapp1Height, err := rollapp1.Height(ctx) require.NoError(t, err) - dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 300) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 300) + require.True(t, isFinalized) + require.NoError(t, err) // Stop the full node err = rollapp1.FullNodes[0].StopContainer(ctx) diff --git a/tests/setup.go b/tests/setup.go index dc3f7e57..7eb03fdb 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -367,7 +367,6 @@ func defaultConfig() *simappparams.EncodingConfig { return &cfg } - func customEpochConfig(epochDuration string) ibc.ChainConfig { // Custom dymension epoch for faster disconnection modifyGenesisKV := dymensionGenesisKV From c4bbc1330f31e9b008d5c121cefbbefd6afd8b55 Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Wed, 12 Jun 2024 15:31:21 +0700 Subject: [PATCH 59/61] WIP need to resolve go mod --- go.mod | 43 +++++++---- go.sum | 137 +++++++++++++++++++++++++----------- tests/fullnode_sync_test.go | 29 ++++++++ tests/setup.go | 1 + 4 files changed, 155 insertions(+), 55 deletions(-) diff --git a/go.mod b/go.mod index 9de01600..983507a9 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/dymensionxyz/e2e-tests -go 1.22.1 +go 1.22.2 + +toolchain go1.22.4 replace ( github.com/evmos/ethermint => github.com/dymensionxyz/ethermint v0.22.0-dymension-v0.3 @@ -9,16 +11,16 @@ replace ( github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // use cometbft github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.32 - github.com/vedhavyas/go-subkey => github.com/strangelove-ventures/go-subkey v1.0.7 ) require ( cosmossdk.io/math v1.3.0 github.com/cosmos/cosmos-sdk v0.46.16 - github.com/cosmos/ibc-go/v6 v6.2.1 + github.com/cosmos/ibc-go/v6 v6.3.1 + github.com/decentrio/e2e-testing-live v0.0.0-20240607135413-e01fbc94078c github.com/decentrio/rollup-e2e-testing v0.0.0-20240605082141-a2b8d70279d8 github.com/dymensionxyz/dymension-rdk v1.1.0-beta - github.com/dymensionxyz/dymension/v3 v3.1.0-rc01.0.20240404003005-53ccf8a922fd + github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56 github.com/evmos/ethermint v0.22.0 github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845 github.com/stretchr/testify v1.8.4 @@ -35,20 +37,26 @@ require ( filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.2 // indirect + github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/BurntSushi/toml v1.3.2 // indirect - github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect + github.com/ChainSafe/go-schnorrkel v1.1.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/armon/go-metrics v0.4.1 // indirect - github.com/avast/retry-go/v4 v4.3.4 // indirect + github.com/avast/retry-go/v4 v4.5.0 // indirect github.com/aws/aws-sdk-go v1.44.122 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + github.com/btcsuite/btcd/btcutil v1.1.3 // indirect + github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 // indirect + github.com/celestiaorg/nmt v0.20.0 // indirect + github.com/celestiaorg/rsmt2d v0.11.0 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/cockroachdb/apd/v2 v2.0.2 // indirect + github.com/cometbft/cometbft v0.37.2 // indirect github.com/confio/ics23/go v0.9.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect @@ -63,12 +71,13 @@ require ( github.com/dgraph-io/badger/v3 v3.2103.3 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/docker/distribution v2.8.1+incompatible // indirect - github.com/docker/docker v24.0.1+incompatible // indirect + github.com/docker/docker v24.0.2+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect - github.com/ethereum/go-ethereum v1.10.26 // indirect + github.com/dymensionxyz/dymint v1.1.2 // indirect + github.com/ethereum/go-ethereum v1.12.0 // indirect github.com/felixge/httpsnoop v1.0.2 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-kit/kit v0.12.0 // indirect @@ -86,6 +95,7 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/flatbuffers v2.0.8+incompatible // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/google/gofuzz v1.2.0 // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/google/uuid v1.4.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect @@ -102,15 +112,19 @@ require ( github.com/hashicorp/go-getter v1.7.1 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect + github.com/hashicorp/go-uuid v1.0.1 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect + github.com/holiman/uint256 v1.2.2 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/klauspost/compress v1.17.6 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect + github.com/klauspost/reedsolomon v1.11.8 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/manifoldco/promptui v0.9.0 // indirect @@ -119,6 +133,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/moby/term v0.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc2 // indirect @@ -134,6 +149,8 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/regen-network/cosmos-proto v0.3.1 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/rollkit/celestia-openrpc v0.0.0-00010101000000-000000000000 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect @@ -151,7 +168,7 @@ require ( github.com/tidwall/btree v1.5.0 // indirect github.com/tidwall/gjson v1.14.4 // indirect github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/sjson v1.2.5 // indirect github.com/ulikunitz/xz v0.5.10 // indirect github.com/zondax/hid v0.9.2 // indirect @@ -162,14 +179,14 @@ require ( go.opentelemetry.io/otel/metric v1.19.0 // indirect go.opentelemetry.io/otel/trace v1.19.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.19.0 // indirect + golang.org/x/crypto v0.22.0 // indirect golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect golang.org/x/mod v0.15.0 // indirect - golang.org/x/net v0.21.0 // indirect + golang.org/x/net v0.24.0 // indirect golang.org/x/oauth2 v0.16.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.18.0 // indirect diff --git a/go.sum b/go.sum index 2c88d355..6c2e8457 100644 --- a/go.sum +++ b/go.sum @@ -195,8 +195,8 @@ github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMb github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= github.com/99designs/keyring v1.2.2 h1:pZd3neh/EmUzWONb35LxQfvuY7kiSXAq3HQd97+XBn0= github.com/99designs/keyring v1.2.2/go.mod h1:wes/FrByc8j7lFOAGLGSNEg8f/PaI3cgTBqhFkHUrPk= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= @@ -204,8 +204,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/DataDog/zstd v1.5.0 h1:+K/VEwIAaPcHiMtQvpLD4lqW7f0Gk3xdYZmI1hD+CXo= -github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= +github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= @@ -218,6 +218,7 @@ github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrd github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/Workiva/go-datastructures v1.0.53 h1:J6Y/52yX10Xc5JjXmGtWoSSxs3mZnGSaq37xZZh7Yig= github.com/Workiva/go-datastructures v1.0.53/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= +github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -226,8 +227,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= -github.com/avast/retry-go/v4 v4.3.4 h1:pHLkL7jvCvP317I8Ge+Km2Yhntv3SdkJm7uekkqbKhM= -github.com/avast/retry-go/v4 v4.3.4/go.mod h1:rv+Nla6Vk3/ilU0H51VHddWHiwimzX66yZ0JT6T+UvE= +github.com/avast/retry-go/v4 v4.5.0 h1:QoRAZZ90cj5oni2Lsgl2GW8mNTnUCnmpx/iKpwVisHg= +github.com/avast/retry-go/v4 v4.5.0/go.mod h1:7hLEXp0oku2Nir2xBAsg0PTphp9z71bN5Aq1fboC3+I= github.com/aws/aws-sdk-go v1.44.122 h1:p6mw01WBaNpbdP2xrisz5tIkcNwzj/HysobNoaAHjgo= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -238,13 +239,38 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1U github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= +github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= github.com/btcsuite/btcd v0.23.4 h1:IzV6qqkfwbItOS/sg/aDfPDsjPP8twrCOE2R93hxMlQ= +github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= +github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= +github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/celestiaorg/celestia-openrpc v0.3.0 h1:/0lzmgg1v/9ONwFs9fNVti3x11kI/Sk87dsYLcms43Q= +github.com/celestiaorg/celestia-openrpc v0.3.0/go.mod h1:2ZhU01YF2hsHIROWzxfMZOYM09Kgyy4roH5JWoNJzp0= +github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc= +github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4/go.mod h1:fzuHnhzj1pUygGz+1ZkB3uQbEUL4htqCGJ4Qs2LwMZA= +github.com/celestiaorg/nmt v0.20.0 h1:9i7ultZ8Wv5ytt8ZRaxKQ5KOOMo4A2K2T/aPGjIlSas= +github.com/celestiaorg/nmt v0.20.0/go.mod h1:Oz15Ub6YPez9uJV0heoU4WpFctxazuIhKyUtaYNio7E= +github.com/celestiaorg/rsmt2d v0.11.0 h1:lcto/637WyTEZR3dLRoNvyuExfnUbxvdvKi3qz/2V4k= +github.com/celestiaorg/rsmt2d v0.11.0/go.mod h1:6Y580I3gVr0+OVFfW6m2JTwnCCmvW3WfbwSLfuT+HCA= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= @@ -292,6 +318,8 @@ github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZ github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= github.com/cometbft/cometbft v0.34.32 h1:yh/BnL38fGJ448xeKuolOLe971NBRZ0go8JO+MC53eY= github.com/cometbft/cometbft v0.34.32/go.mod h1:25SXMPtyfSWIh172/UGa08/Kra7yrhK2Hm4IKs5X4AQ= +github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc= +github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= github.com/cometbft/cometbft-db v0.11.0 h1:M3Lscmpogx5NTbb1EGyGDaFRdsoLWrUWimFEyf7jej8= github.com/cometbft/cometbft-db v0.11.0/go.mod h1:GDPJAC/iFHNjmZZPN8V8C1yr/eyityhi2W1hz2MGKSc= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= @@ -314,8 +342,8 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4 github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.19.6 h1:XY78yEeNPrEYyNCKlqr9chrwoeSDJ0bV2VjocTk//OU= github.com/cosmos/iavl v0.19.6/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= -github.com/cosmos/ibc-go/v6 v6.2.1 h1:NiaDXTRhKwf3n9kELD4VRIe5zby1yk1jBvaz9tXTQ6k= -github.com/cosmos/ibc-go/v6 v6.2.1/go.mod h1:XLsARy4Y7+GtAqzMcxNdlQf6lx+ti1e8KcMGv5NIK7A= +github.com/cosmos/ibc-go/v6 v6.3.1 h1:/5ur3AsmNW8WuOevfODHlaY5Ze236PBNE3vVo9o3fQA= +github.com/cosmos/ibc-go/v6 v6.3.1/go.mod h1:Dm14j9s094bGyCEE8W4fD+2t8IneHv+cz+80Mvwjr1w= github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw= github.com/cosmos/ledger-cosmos-go v0.12.4/go.mod h1:fjfVWRf++Xkygt9wzCsjEBdjcf7wiiY35fv3ctT+k4M= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= @@ -324,18 +352,25 @@ github.com/creachadair/taskgroup v0.3.2 h1:zlfutDS+5XG40AOxcHDSThxKzns8Tnr9jnr6V github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+kq+TDlRJQ0Wbk= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decentrio/e2e-testing-live v0.0.0-20240607135413-e01fbc94078c h1:2TpLnXMuYxUK1w0hgE6HoEO6DA4TVLHoy/CQSlSF1qM= +github.com/decentrio/e2e-testing-live v0.0.0-20240607135413-e01fbc94078c/go.mod h1:GDoIFdNFWS2zh9vkN1Q4VXL3UO056cp5RwYlaUGBrm0= github.com/decentrio/rollup-e2e-testing v0.0.0-20240605082141-a2b8d70279d8 h1:+JBW2km8ftY6kZ2bbl9/D4YXTL2cnzDTwwhwuiEM2zs= github.com/decentrio/rollup-e2e-testing v0.0.0-20240605082141-a2b8d70279d8/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= -github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= +github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= +github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= @@ -347,18 +382,18 @@ github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkz github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 h1:Izz0+t1Z5nI16/II7vuEo/nHjodOg0p7+OiDpjX5t1E= -github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= +github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v24.0.1+incompatible h1:NxN81beIxDlUaVt46iUQrYHD9/W3u9EGl52r86O/IGw= -github.com/docker/docker v24.0.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v24.0.2+incompatible h1:eATx+oLz9WdNVkQrr0qjQ8HvRJ4bOOxfzEo8R+dA3cg= +github.com/docker/docker v24.0.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf h1:Yt+4K30SdjOkRoRRm3vYNQgR+/ZIy0RmeUDZo7Y8zeQ= -github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= +github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7 h1:kgvzE5wLsLa7XKfV85VZl40QXaMCaeFtHpPwJ8fhotY= +github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= @@ -366,12 +401,12 @@ github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQx github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/dymensionxyz/dymension-rdk v1.1.0-beta h1:vvKB6Y65aOOyS6inUCmRrSnlph0MmeLAz6EyXzsdbg4= github.com/dymensionxyz/dymension-rdk v1.1.0-beta/go.mod h1:WnmIZVAFUjwsLSWlhPu3VtOHeBinLYAK9s5t1OPOL3o= -github.com/dymensionxyz/dymension/v3 v3.1.0-rc01.0.20240404003005-53ccf8a922fd h1:P7Ku9WRopjY7sKSIx4ahwnHjRYOiUDu8hv4uM+Rzyek= -github.com/dymensionxyz/dymension/v3 v3.1.0-rc01.0.20240404003005-53ccf8a922fd/go.mod h1:3Pfrr8j/BR9ztNKztGfC5PqDiO6CcrzMLCJtFtPEVW4= +github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56 h1:cmpJYdRviuUfmlJdHrcAND8Jd6JIY4rp63bWAQzPr54= +github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56/go.mod h1:3Pfrr8j/BR9ztNKztGfC5PqDiO6CcrzMLCJtFtPEVW4= +github.com/dymensionxyz/dymint v1.1.2 h1:KcvwPpMp+Y6j8EbhaLjvtKFtTEn04hPpeVI45Mhs5QY= +github.com/dymensionxyz/dymint v1.1.2/go.mod h1:QedWhB9RjsZOxevADYZz3EFtofQqtQdZyivSmT6QZM0= github.com/dymensionxyz/ethermint v0.22.0-dymension-v0.3 h1:iAtAivMtJh2Ublnq2KasC7EIa5/gfsff5EJ7kUlnd9A= github.com/dymensionxyz/ethermint v0.22.0-dymension-v0.3/go.mod h1:O2J61ZwM0Vdms6pRa1fb43pwmCuNRctro3AB90WlOc0= -github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= -github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -382,8 +417,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s= -github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= +github.com/ethereum/go-ethereum v1.12.0 h1:bdnhLPtqETd4m3mS8BGMNvBTf36bO5bx/hxE2zljOa0= +github.com/ethereum/go-ethereum v1.12.0/go.mod h1:/oo2X/dZLJjf2mJ6YT9wcWxa4nNJDBKDBU6sFIpx1Gs= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= @@ -434,6 +469,8 @@ github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -504,8 +541,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= -github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -584,8 +621,9 @@ github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= -github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -614,12 +652,15 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= +github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= @@ -629,10 +670,15 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNU github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI= github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= +github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/reedsolomon v1.11.8 h1:s8RpUW5TK4hjr+djiOpbZJB4ksx+TdYbRH7vHQpwPOY= +github.com/klauspost/reedsolomon v1.11.8/go.mod h1:4bXRN+cVzMdml6ti7qLouuYi32KHJ5MGv0Qd8a47h6A= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -642,6 +688,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= @@ -677,8 +725,8 @@ github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae h1:O4SWKdcHVCvYqyDV+9CJA1fcDN2L11Bule0iFy3YlAI= -github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -695,10 +743,13 @@ github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= @@ -743,8 +794,6 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= -github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= @@ -758,13 +807,11 @@ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94 github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rjeczalik/notify v0.9.3 h1:6rJAzHTGKXGj76sbRgDiDcYj/HniypXmSJo1SWakZeY= -github.com/rjeczalik/notify v0.9.3/go.mod h1:gF3zSOrafR9DQEWSE8TjfI9NkooDxbyT4UgRGKZA0lc= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/cors v1.9.0 h1:l9HGsTsHJcvW14Nk7J9KFz8bzeAWXn3CG6bgt7LsrAE= github.com/rs/cors v1.9.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= @@ -818,7 +865,6 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= @@ -836,8 +882,9 @@ github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= +github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= @@ -861,6 +908,8 @@ github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= +gitlab.com/NebulousLabs/errors v0.0.0-20171229012116-7ead97ef90b8/go.mod h1:ZkMZ0dpQyWwlENaeZVBiQRjhMEZvk6VTXquzl3FOFP8= +gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40/go.mod h1:rOnSnoRyxMI3fe/7KIbVcsHRGxe30OONv8dEgo+vCfA= go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -890,6 +939,7 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -897,11 +947,12 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200109152110-61a87790db17/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -942,6 +993,7 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -995,8 +1047,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1118,14 +1170,15 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/tests/fullnode_sync_test.go b/tests/fullnode_sync_test.go index 5696c8da..52fe0c7f 100644 --- a/tests/fullnode_sync_test.go +++ b/tests/fullnode_sync_test.go @@ -16,8 +16,37 @@ import ( "github.com/decentrio/rollup-e2e-testing/relayer" "github.com/decentrio/rollup-e2e-testing/testreporter" "github.com/decentrio/rollup-e2e-testing/testutil" + + "flag" + "log" + "net" + "strconv" + + grpcda "github.com/dymensionxyz/dymint/da/grpc" + "github.com/dymensionxyz/dymint/da/grpc/mockserv" + "github.com/dymensionxyz/dymint/store" ) +// StartDA start grpc DALC server +func StartDA() { + conf := grpcda.DefaultConfig + + flag.IntVar(&conf.Port, "port", conf.Port, "listening port") + flag.StringVar(&conf.Host, "host", "0.0.0.0", "listening address") + flag.Parse() + + kv := store.NewDefaultKVStore(".", "db", "dymint") + lis, err := net.Listen("tcp", conf.Host+":"+strconv.Itoa(conf.Port)) + if err != nil { + log.Panic(err) + } + log.Println("Listening on:", lis.Addr()) + srv := mockserv.GetServer(kv, conf, nil) + if err := srv.Serve(lis); err != nil { + log.Println("error while serving:", err) + } +} + func TestFullnodeSync_EVM(t *testing.T) { if testing.Short() { t.Skip() diff --git a/tests/setup.go b/tests/setup.go index 8e874796..82c4bede 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -595,6 +595,7 @@ func overridesDymintToml(settlemenLayer, nodeAddress, rollappId, gasPrices, maxI configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["da_layer"] = "grpc" dymintTomlOverrides["settlement_layer"] = settlemenLayer dymintTomlOverrides["settlement_node_address"] = nodeAddress dymintTomlOverrides["rollapp_id"] = rollappId From 455012db354e6f40622fa6d36d99ff668033b9d5 Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Fri, 14 Jun 2024 02:11:29 +0700 Subject: [PATCH 60/61] done --- .gitignore | 1 + tests/fullnode_sync_test.go | 25 +++++-------------------- 2 files changed, 6 insertions(+), 20 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2d93080d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tests/db/* \ No newline at end of file diff --git a/tests/fullnode_sync_test.go b/tests/fullnode_sync_test.go index 52fe0c7f..01e91cc1 100644 --- a/tests/fullnode_sync_test.go +++ b/tests/fullnode_sync_test.go @@ -13,7 +13,6 @@ import ( "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" - "github.com/decentrio/rollup-e2e-testing/relayer" "github.com/decentrio/rollup-e2e-testing/testreporter" "github.com/decentrio/rollup-e2e-testing/testutil" @@ -40,7 +39,7 @@ func StartDA() { if err != nil { log.Panic(err) } - log.Println("Listening on:", lis.Addr()) + log.Println("DA grpc listening on:", lis.Addr()) srv := mockserv.GetServer(kv, conf, nil) if err := srv.Serve(lis); err != nil { log.Println("error while serving:", err) @@ -54,6 +53,8 @@ func TestFullnodeSync_EVM(t *testing.T) { ctx := context.Background() + go StartDA() + // setup config for rollapp 1 settlement_layer_rollapp1 := "dymension" settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) @@ -110,19 +111,8 @@ func TestFullnodeSync_EVM(t *testing.T) { // Relayer Factory client, network := test.DockerSetup(t) - r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage("ghcr.io/decentrio/relayer", "2.5.2", "100:1000"), - ).Build(t, client, "relayer1", network) - ic := test.NewSetup(). - AddRollUp(dymension, rollapp1). - AddRelayer(r, "relayer1"). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp1, - Relayer: r, - Path: ibcPath, - }) + AddRollUp(dymension, rollapp1) rep := testreporter.NewNopReporter() eRep := rep.RelayerExecReporter(t) @@ -138,11 +128,6 @@ func TestFullnodeSync_EVM(t *testing.T) { }) require.NoError(t, err) - CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - // Wait for rollapp finalized rollapp1Height, err := rollapp1.Height(ctx) require.NoError(t, err) @@ -155,7 +140,7 @@ func TestFullnodeSync_EVM(t *testing.T) { require.NoError(t, err) // Wait for a few blocks before start the node again and sync - err = testutil.WaitForBlocks(ctx, 50, rollapp1) + err = testutil.WaitForBlocks(ctx, 50, dymension) require.NoError(t, err) // Start full node again From c31c3bbf2874a4af0076198ede939fcf3d4ddecd Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Thu, 25 Jul 2024 13:52:09 +0700 Subject: [PATCH 61/61] mod tidy --- go.mod | 10 +-- go.sum | 209 ++++++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 173 insertions(+), 46 deletions(-) diff --git a/go.mod b/go.mod index 983507a9..80315bf4 100644 --- a/go.mod +++ b/go.mod @@ -17,10 +17,10 @@ require ( cosmossdk.io/math v1.3.0 github.com/cosmos/cosmos-sdk v0.46.16 github.com/cosmos/ibc-go/v6 v6.3.1 - github.com/decentrio/e2e-testing-live v0.0.0-20240607135413-e01fbc94078c github.com/decentrio/rollup-e2e-testing v0.0.0-20240605082141-a2b8d70279d8 github.com/dymensionxyz/dymension-rdk v1.1.0-beta github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56 + github.com/dymensionxyz/dymint v1.1.2 github.com/evmos/ethermint v0.22.0 github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845 github.com/stretchr/testify v1.8.4 @@ -37,7 +37,6 @@ require ( filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.2 // indirect - github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/BurntSushi/toml v1.3.2 // indirect github.com/ChainSafe/go-schnorrkel v1.1.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect @@ -48,7 +47,6 @@ require ( github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect - github.com/btcsuite/btcd/btcutil v1.1.3 // indirect github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 // indirect github.com/celestiaorg/nmt v0.20.0 // indirect github.com/celestiaorg/rsmt2d v0.11.0 // indirect @@ -76,7 +74,7 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect - github.com/dymensionxyz/dymint v1.1.2 // indirect + github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240421130646-b8980ec7aade // indirect github.com/ethereum/go-ethereum v1.12.0 // indirect github.com/felixge/httpsnoop v1.0.2 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -95,7 +93,6 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/flatbuffers v2.0.8+incompatible // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/google/uuid v1.4.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect @@ -112,7 +109,6 @@ require ( github.com/hashicorp/go-getter v1.7.1 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect - github.com/hashicorp/go-uuid v1.0.1 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/hashicorp/hcl v1.0.0 // indirect @@ -133,7 +129,6 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/moby/term v0.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc2 // indirect @@ -149,7 +144,6 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/regen-network/cosmos-proto v0.3.1 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rollkit/celestia-openrpc v0.0.0-00010101000000-000000000000 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect diff --git a/go.sum b/go.sum index 6c2e8457..7a4292ee 100644 --- a/go.sum +++ b/go.sum @@ -184,6 +184,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= +code.cloudfoundry.org/go-diodes v0.0.0-20220725190411-383eb6634c40 h1:wzkYwwcf4uMGcDpn48WAbq8GtoqDny49tdQ4zJVAsmo= +code.cloudfoundry.org/go-diodes v0.0.0-20220725190411-383eb6634c40/go.mod h1:Nx9ASXN4nIlRDEXv+qXE3dpuhnTnO28Lxl/bMUd6BMc= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= @@ -201,8 +203,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= -github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= +github.com/ChainSafe/go-schnorrkel v1.1.0 h1:rZ6EU+CZFCjB4sHUE1jIu8VDoB/wRKZxoe1tkcO71Wk= +github.com/ChainSafe/go-schnorrkel v1.1.0/go.mod h1:ABkENxiP+cvjFiByMIZ9LYbRoNNLeBLiakC1XeTFxfE= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= @@ -218,7 +220,8 @@ github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrd github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/Workiva/go-datastructures v1.0.53 h1:J6Y/52yX10Xc5JjXmGtWoSSxs3mZnGSaq37xZZh7Yig= github.com/Workiva/go-datastructures v1.0.53/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= -github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI= +github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -231,6 +234,8 @@ github.com/avast/retry-go/v4 v4.5.0 h1:QoRAZZ90cj5oni2Lsgl2GW8mNTnUCnmpx/iKpwVis github.com/avast/retry-go/v4 v4.5.0/go.mod h1:7hLEXp0oku2Nir2xBAsg0PTphp9z71bN5Aq1fboC3+I= github.com/aws/aws-sdk-go v1.44.122 h1:p6mw01WBaNpbdP2xrisz5tIkcNwzj/HysobNoaAHjgo= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= +github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= +github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -239,32 +244,23 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1U github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= -github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= +github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= +github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= +github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/btcsuite/btcd v0.23.4 h1:IzV6qqkfwbItOS/sg/aDfPDsjPP8twrCOE2R93hxMlQ= -github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= -github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= +github.com/btcsuite/btcd v0.23.4/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= -github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= -github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= -github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= -github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= -github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= -github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/celestiaorg/celestia-openrpc v0.3.0 h1:/0lzmgg1v/9ONwFs9fNVti3x11kI/Sk87dsYLcms43Q= github.com/celestiaorg/celestia-openrpc v0.3.0/go.mod h1:2ZhU01YF2hsHIROWzxfMZOYM09Kgyy4roH5JWoNJzp0= +github.com/celestiaorg/go-fraud v0.2.0 h1:aaq2JiW0gTnhEdac3l51UCqSyJ4+VjFGTTpN83V4q7I= +github.com/celestiaorg/go-fraud v0.2.0/go.mod h1:lNY1i4K6kUeeE60Z2VK8WXd+qXb8KRzfBhvwPkK6aUc= +github.com/celestiaorg/go-header v0.4.0 h1:Ine/xpvFx8o9p6fXW+h2RSPp68rn7VUxTkW1okJxcEY= +github.com/celestiaorg/go-header v0.4.0/go.mod h1:H8xhnDLDLbkpwmWPhCaZyTnIV3dlVxBHPnxNXS2Qu6c= github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc= github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4/go.mod h1:fzuHnhzj1pUygGz+1ZkB3uQbEUL4htqCGJ4Qs2LwMZA= github.com/celestiaorg/nmt v0.20.0 h1:9i7ultZ8Wv5ytt8ZRaxKQ5KOOMo4A2K2T/aPGjIlSas= @@ -272,9 +268,12 @@ github.com/celestiaorg/nmt v0.20.0/go.mod h1:Oz15Ub6YPez9uJV0heoU4WpFctxazuIhKyU github.com/celestiaorg/rsmt2d v0.11.0 h1:lcto/637WyTEZR3dLRoNvyuExfnUbxvdvKi3qz/2V4k= github.com/celestiaorg/rsmt2d v0.11.0/go.mod h1:6Y580I3gVr0+OVFfW6m2JTwnCCmvW3WfbwSLfuT+HCA= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= +github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.12 h1:DCYWIBOalB0mKKfUg2HhtGgIkBbMA1fnlnkZp7fHB18= +github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.12/go.mod h1:5g1oM4Zu3BOaLpsKQ+O8PAv2kNuq+kPcA1VzFbsSqxE= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -324,16 +323,19 @@ github.com/cometbft/cometbft-db v0.11.0 h1:M3Lscmpogx5NTbb1EGyGDaFRdsoLWrUWimFEy github.com/cometbft/cometbft-db v0.11.0/go.mod h1:GDPJAC/iFHNjmZZPN8V8C1yr/eyityhi2W1hz2MGKSc= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= +github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= +github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= github.com/cosmos/cosmos-sdk v0.46.16 h1:RVGv1+RulLZeNyfCaPZrZtv0kY7ZZNAI6JGpub0Uh6o= github.com/cosmos/cosmos-sdk v0.46.16/go.mod h1:05U50tAsOzQ8JOAePshJCbJQw5ib1YJR6IXcqyVI1Xg= -github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR2g= @@ -352,25 +354,26 @@ github.com/creachadair/taskgroup v0.3.2 h1:zlfutDS+5XG40AOxcHDSThxKzns8Tnr9jnr6V github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+kq+TDlRJQ0Wbk= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= -github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decentrio/e2e-testing-live v0.0.0-20240607135413-e01fbc94078c h1:2TpLnXMuYxUK1w0hgE6HoEO6DA4TVLHoy/CQSlSF1qM= -github.com/decentrio/e2e-testing-live v0.0.0-20240607135413-e01fbc94078c/go.mod h1:GDoIFdNFWS2zh9vkN1Q4VXL3UO056cp5RwYlaUGBrm0= +github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR6AkioZ1ySsx5yxlDQZ8stG2b88gTPxgJU= +github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= github.com/decentrio/rollup-e2e-testing v0.0.0-20240605082141-a2b8d70279d8 h1:+JBW2km8ftY6kZ2bbl9/D4YXTL2cnzDTwwhwuiEM2zs= github.com/decentrio/rollup-e2e-testing v0.0.0-20240605082141-a2b8d70279d8/go.mod h1:kslnOTBoqMTES+SQ5H3hzR3aO11Sf4vaGbAxzKZCD/Y= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= +github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/base58 v1.0.4 h1:QJC6B0E0rXOPA8U/kw2rP+qiRJsUaE2Er+pYb3siUeA= +github.com/decred/base58 v1.0.4/go.mod h1:jJswKPEdvpFpvf7dsDvFZyLT22xZ9lWqEByX38oGd9E= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/decred/dcrd/dcrec/edwards v1.0.0 h1:UDcPNzclKiJlWqV3x1Fl8xMCJrolo4PB4X9t8LwKDWU= +github.com/decred/dcrd/dcrec/edwards v1.0.0/go.mod h1:HblVh1OfMt7xSxUL1ufjToaEvpbjpWvvTAUx4yem8BI= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= @@ -399,6 +402,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= +github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240421130646-b8980ec7aade h1:LHbwDuI4hPNGSA+gWQz4ev0xt8p+ztPLEcZWR7e5YzA= +github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240421130646-b8980ec7aade/go.mod h1:UxhLdtWOWg7l6+5Hpkm39Khd23wcr5H62YxM04rMbh8= github.com/dymensionxyz/dymension-rdk v1.1.0-beta h1:vvKB6Y65aOOyS6inUCmRrSnlph0MmeLAz6EyXzsdbg4= github.com/dymensionxyz/dymension-rdk v1.1.0-beta/go.mod h1:WnmIZVAFUjwsLSWlhPu3VtOHeBinLYAK9s5t1OPOL3o= github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240411195658-f7cd96f53b56 h1:cmpJYdRviuUfmlJdHrcAND8Jd6JIY4rp63bWAQzPr54= @@ -407,6 +412,8 @@ github.com/dymensionxyz/dymint v1.1.2 h1:KcvwPpMp+Y6j8EbhaLjvtKFtTEn04hPpeVI45Mh github.com/dymensionxyz/dymint v1.1.2/go.mod h1:QedWhB9RjsZOxevADYZz3EFtofQqtQdZyivSmT6QZM0= github.com/dymensionxyz/ethermint v0.22.0-dymension-v0.3 h1:iAtAivMtJh2Ublnq2KasC7EIa5/gfsff5EJ7kUlnd9A= github.com/dymensionxyz/ethermint v0.22.0-dymension-v0.3/go.mod h1:O2J61ZwM0Vdms6pRa1fb43pwmCuNRctro3AB90WlOc0= +github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/4= +github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -429,8 +436,14 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o= github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/filecoin-project/go-jsonrpc v0.3.1 h1:qwvAUc5VwAkooquKJmfz9R2+F8znhiqcNHYjEp/NM10= +github.com/filecoin-project/go-jsonrpc v0.3.1/go.mod h1:jBSvPTl8V1N7gSTuCR4bis8wnQnIjHbRPpROol6iQKM= +github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg= +github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= +github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -441,6 +454,7 @@ github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqG github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -467,8 +481,12 @@ github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5Nq github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= +github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= +github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= @@ -543,6 +561,8 @@ github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= +github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -596,6 +616,8 @@ github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= +github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk= +github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= @@ -605,11 +627,12 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= -github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= +github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= @@ -618,6 +641,8 @@ github.com/hashicorp/go-getter v1.7.1/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17 github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= @@ -630,6 +655,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4= +github.com/hashicorp/golang-lru/v2 v2.0.5/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 h1:aSVUgRRRtOrZOC1fYmY9gV0e9z/Iu+xNVSASWjsuyGU= @@ -645,22 +672,39 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845 h1:H+uM0Bv88eur3ZSsd2NGKg3YIiuXxwxtlN7HjE66UTU= github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845/go.mod h1:c1tRKs5Tx7E2+uHGSyyncziFjvGpgv4H2HrqXeUQ/Uk= +github.com/ignite/cli v0.26.1 h1:T4qMjM9H38JOBsgCruilGcsfrlDGHO2K1V88gIe0ubs= +github.com/ignite/cli v0.26.1/go.mod h1:0BQcJCseK0O5RG8HYP/lvVTFbZQjkw+AY8B+wDklj38= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= +github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= +github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk= +github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8= +github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8= +github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ= +github.com/ipfs/go-ipns v0.2.0 h1:BgmNtQhqOw5XEZ8RAfWEpK4DhqaYiuP6h71MhIp7xXU= +github.com/ipfs/go-ipns v0.2.0/go.mod h1:3cLT2rbvgPZGkHJoPO1YMJeh6LtkxopCkKFcio/wE24= +github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= +github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= +github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= +github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= +github.com/ipld/go-ipld-prime v0.9.0 h1:N2OjJMb+fhyFPwPnVvJcWU/NsumP8etal+d2v3G4eww= +github.com/ipld/go-ipld-prime v0.9.0/go.mod h1:KvBLMr4PX1gWptgkzRjVZCrLmSGcZCb/jioOQwCqZN8= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= -github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= +github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk= +github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o= +github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= -github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= @@ -670,7 +714,6 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNU github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI= @@ -680,6 +723,8 @@ github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZY github.com/klauspost/reedsolomon v1.11.8 h1:s8RpUW5TK4hjr+djiOpbZJB4ksx+TdYbRH7vHQpwPOY= github.com/klauspost/reedsolomon v1.11.8/go.mod h1:4bXRN+cVzMdml6ti7qLouuYi32KHJ5MGv0Qd8a47h6A= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0= +github.com/koron/go-ssdp v0.0.4/go.mod h1:oDXq+E5IL5q0U8uSBcoAXzTzInwy5lEgC91HoKtbmZk= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -694,6 +739,32 @@ github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= +github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38yPW7c= +github.com/libp2p/go-cidranger v1.1.0/go.mod h1:KWZTfSr+r9qEo9OkI9/SIEeAtw+NNoU0dXIXt15Okic= +github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= +github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= +github.com/libp2p/go-libp2p v0.33.1 h1:tvJl9b9M6nSLBtZSXSguq+/lRhRj2oLRkyhBmQNMFLA= +github.com/libp2p/go-libp2p v0.33.1/go.mod h1:zOUTMjG4I7TXwMndNyOBn/CNtVBLlvBlnxfi+8xzx+E= +github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= +github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= +github.com/libp2p/go-libp2p-kad-dht v0.21.1 h1:xpfp8/t9+X2ip1l8Umap1/UGNnJ3RHJgKGAEsnRAlTo= +github.com/libp2p/go-libp2p-kad-dht v0.21.1/go.mod h1:Oy8wvbdjpB70eS5AaFaI68tOtrdo3KylTvXDjikxqFo= +github.com/libp2p/go-libp2p-kbucket v0.5.0 h1:g/7tVm8ACHDxH29BGrpsQlnNeu+6OF1A9bno/4/U1oA= +github.com/libp2p/go-libp2p-kbucket v0.5.0/go.mod h1:zGzGCpQd78b5BNTDGHNDLaTt9aDK/A02xeZp9QeFC4U= +github.com/libp2p/go-libp2p-pubsub v0.9.3 h1:ihcz9oIBMaCK9kcx+yHWm3mLAFBMAUsM4ux42aikDxo= +github.com/libp2p/go-libp2p-pubsub v0.9.3/go.mod h1:RYA7aM9jIic5VV47WXu4GkcRxRhrdElWf8xtyli+Dzc= +github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= +github.com/libp2p/go-libp2p-record v0.2.0/go.mod h1:I+3zMkvvg5m2OcSdoL0KPljyJyvNDFGKX7QdlpYUcwk= +github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= +github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM= +github.com/libp2p/go-nat v0.2.0 h1:Tyz+bUFAYqGyJ/ppPPymMGbIgNRH+WqC5QrT5fKrrGk= +github.com/libp2p/go-nat v0.2.0/go.mod h1:3MJr+GRpRkyT65EpVPBstXLvOlAPzUVlG6Pwg9ohLJk= +github.com/libp2p/go-netroute v0.2.1 h1:V8kVrpD8GK0Riv15/7VN6RbUQ3URNZVosw7H2v9tksU= +github.com/libp2p/go-netroute v0.2.1/go.mod h1:hraioZr0fhBjG0ZRXJJ6Zj2IVEVNx6tDTFQfSmcq7mQ= +github.com/libp2p/go-reuseport v0.4.0 h1:nR5KU7hD0WxXCJbmw7r2rhRYruNRl2koHw8fQscQm2s= +github.com/libp2p/go-reuseport v0.4.0/go.mod h1:ZtI03j/wO5hZVDFo2jKywN6bYKWLOy8Se6DrI2E1cLU= +github.com/libp2p/go-yamux/v4 v4.0.1 h1:FfDR4S1wj6Bw2Pqbc8Uz7pCxeRBPbwsBbEdfwiCypkQ= +github.com/libp2p/go-yamux/v4 v4.0.1/go.mod h1:NWjl8ZTLOGlozrXSOZ/HlfG++39iKNnM5wwmtQP1YB4= github.com/linxGnu/grocksdb v1.8.12 h1:1/pCztQUOa3BX/1gR3jSZDoaKFpeHFvQ1XrqZpSvZVo= github.com/linxGnu/grocksdb v1.8.12/go.mod h1:xZCIb5Muw+nhbDK4Y5UJuOrin5MceOuiXkVUR7vp4WY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= @@ -701,6 +772,8 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= +github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8u83wA0rVZ8ttrq5CpaPZdvrK0LP2lOk= +github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd/go.mod h1:QuCEs1Nt24+FYQEqAAncTDPJIuGs+LxK1MCiFL25pMU= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= @@ -713,11 +786,19 @@ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= +github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY= +github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUMM0I83AUIT6Hu17AWfgjzIbtrYFc= +github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b/go.mod h1:lxPUiZwKoFL8DUUmalo2yJJUCxbPKtm8OKfqr2/FTNU= +github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc h1:PTfri+PuQmWDqERdnNMiD9ZejrlswWrCpBEZgWOiTrc= +github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc/go.mod h1:cGKTAVKx4SxOuR/czcZ/E2RSJ3sfHs8FpHhQ5CWMf9s= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b h1:QrHweqAtyJ9EwCaGHBu1fghwxIPiopAHV06JlXrMHjk= github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b/go.mod h1:xxLb2ip6sSUts3g1irPVHyk/DGslwQsNOo9I7smJfNU= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= +github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= +github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= @@ -733,8 +814,30 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= +github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= +github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE= +github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= +github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= +github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= +github.com/multiformats/go-multiaddr v0.12.2 h1:9G9sTY/wCYajKa9lyfWPmpZAwe6oV+Wb1zcmMS1HG24= +github.com/multiformats/go-multiaddr v0.12.2/go.mod h1:GKyaTYjZRdcUhyOetrxTk9z0cW+jA/YrnqTOvKgi44M= +github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= +github.com/multiformats/go-multiaddr-dns v0.3.1/go.mod h1:G/245BRQ6FJGmryJCrOuTdB37AMA5AMOVuO6NY3JwTk= +github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= +github.com/multiformats/go-multiaddr-fmt v0.1.0/go.mod h1:hGtDIW4PU4BqJ50gW2quDuPVjyWNZxToGUh/HwTZYJo= +github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= +github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= +github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg= +github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= +github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U= +github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= +github.com/multiformats/go-multistream v0.5.0 h1:5htLSLl7lvJk3xx3qT/8Zm9J4K8vEOf/QGkvOGQAyiE= +github.com/multiformats/go-multistream v0.5.0/go.mod h1:n6tMZiwiP2wUsR8DgfDWw1dydlEqV3l6N3/GBsX6ILA= +github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= +github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= @@ -743,13 +846,12 @@ github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= +github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= @@ -758,15 +860,23 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= +github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= +github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 h1:hDSdbBuw3Lefr6R18ax0tZ2BJeNB3NehB3trOwYBsdU= github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/pierrec/xxHash v0.1.5 h1:n/jBpwTHiER4xYvK3/CdPVnLDPchj8eTJFFLUb4QHBo= +github.com/pierrec/xxHash v0.1.5/go.mod h1:w2waW5Zoa/Wc4Yqe0wgrIYAGKqRMf7czn2HNKXmuL+I= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -774,6 +884,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e h1:ZOcivgkkFRnjfoTcGsDq3UQYiBmekwLA+qg0OjyB/ls= +github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= @@ -794,8 +906,16 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= +github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= +github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM= +github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M= +github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFDD3NxaZLY= +github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc= github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= +github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= +github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg= @@ -897,6 +1017,10 @@ github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3C github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/vedhavyas/go-subkey v1.0.3 h1:iKR33BB/akKmcR2PMlXPBeeODjWLM90EL98OrOGs8CA= +github.com/vedhavyas/go-subkey v1.0.3/go.mod h1:CloUaFQSSTdWnINfBRFjVMkWXZANW+nd8+TI5jYcl6Y= +github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= +github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1/go.mod h1:8UvriyWtv5Q5EOgjHaSseUEdkQfvwFv1I/In/O2M9gc= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -909,6 +1033,9 @@ github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWp github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= gitlab.com/NebulousLabs/errors v0.0.0-20171229012116-7ead97ef90b8/go.mod h1:ZkMZ0dpQyWwlENaeZVBiQRjhMEZvk6VTXquzl3FOFP8= +gitlab.com/NebulousLabs/errors v0.0.0-20200929122200-06c536cf6975 h1:L/ENs/Ar1bFzUeKx6m3XjlmBgIUlykX9dzvp5k9NGxc= +gitlab.com/NebulousLabs/errors v0.0.0-20200929122200-06c536cf6975/go.mod h1:ZkMZ0dpQyWwlENaeZVBiQRjhMEZvk6VTXquzl3FOFP8= +gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40 h1:dizWJqTWjwyD8KGcMOwgrkqu1JIkofYgKkmDeNE7oAs= gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40/go.mod h1:rOnSnoRyxMI3fe/7KIbVcsHRGxe30OONv8dEgo+vCfA= go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= @@ -931,22 +1058,26 @@ go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1 go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/dig v1.17.1 h1:Tga8Lz8PcYNsWsyHMZ1Vm0OQOUaJNDyvPImgbAu9YSc= +go.uber.org/dig v1.17.1/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= +go.uber.org/fx v1.20.1 h1:zVwVQGS8zYvhh9Xxcu4w1M6ESyeMzebzj2NbSayZ4Mk= +go.uber.org/fx v1.20.1/go.mod h1:iSYNbHf2y55acNCwCXKx7LbWb5WG1Bnue5RDXz1OREg= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200109152110-61a87790db17/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -993,7 +1124,6 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1517,6 +1647,7 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1526,6 +1657,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= +lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw=