Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[E2E Test] Hard fork due to DRS deprecation #504

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ e2e-test-rollapp-hardfork-evm: clean-e2e
e2e-test-rollapp-hardfork-recover-ibc-client-evm: clean-e2e
cd tests && go test -timeout=45m -race -v -run TestHardForkRecoverIbcClient_EVM .

e2e-test-rollapp-hardforkduetodrs-evm: clean-e2e
cd tests && go test -timeout=45m -race -v -run TestHardForkDueToDrs_EVM .

e2e-test-rollapp-genesis-transfer-bridge-blocking-evm: clean-e2e
cd tests && go test -timeout=45m -race -v -run TestGenesisTransferBridgeBlocking_EVM .

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ replace (

require (
github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869
github.com/decentrio/rollup-e2e-testing v0.0.0-20241106053431-7375da2a5c60
github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20241016085626-2b8c8898058b
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241015102238-a827c3784461
github.com/decentrio/rollup-e2e-testing v0.0.0-20241101042254-a87404cf9897
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,8 @@ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U=
github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869 h1:qWpUYGOsrSC+1Vmd2TjhbsSpntvvx9PsX3AoeMunFxc=
github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869/go.mod h1:HZNYnPwmSxkwTPjSD5yolauc1Vx1ZzKL4FFMxTq4H5Y=
github.com/decentrio/rollup-e2e-testing v0.0.0-20241101042254-a87404cf9897 h1:kpYvC4h6tzWz4Q2XQ11/E53DIpur9zvnVmRDoExhWgw=
github.com/decentrio/rollup-e2e-testing v0.0.0-20241101042254-a87404cf9897/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c=
github.com/decentrio/rollup-e2e-testing v0.0.0-20241106053431-7375da2a5c60 h1:RZ7fHR7EZUTtS+2C9CrivvE/HXI7JKHFJxxQgSdO9LU=
github.com/decentrio/rollup-e2e-testing v0.0.0-20241106053431-7375da2a5c60/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c=
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=
Expand Down
222 changes: 222 additions & 0 deletions tests/hardfork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1661,3 +1661,225 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) {
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}

func TestHardForkDueToDrs_EVM(t *testing.T) {
if testing.Short() {
t.Skip()
}

ctx := context.Background()

go StartDA()

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_time"] = "50s"
dymintTomlOverrides["p2p_blocksync_enabled"] = "true"

modifyHubGenesisKV := append(
dymensionGenesisKV,
cosmos.GenesisKV{
Key: "app_state.sequencer.params.unbonding_time",
Value: "300s",
},
cosmos.GenesisKV{
Key: "app_state.staking.params.unbonding_time",
Value: "300s",
},
)

modifyRAGenesisKV := append(
rollappEVMGenesisKV,
cosmos.GenesisKV{
Key: "app_state.sequencers.params.unbonding_time",
Value: "300s",
},
cosmos.GenesisKV{
Key: "app_state.staking.params.unbonding_time",
Value: "300s",
},
cosmos.GenesisKV{
Key: "app_state.rollappparams.params.da",
Value: "grpc",
},
)

// 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(modifyRAGenesisKV),
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(modifyHubGenesisKV),
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 1
r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t),
relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage),
).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,
}, nil, "", nil, false, 195)
require.NoError(t, err)

// Check IBC Transfer before switch
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()

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
sequencerAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", keyDir)
require.NoError(t, err)

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)

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)

res, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID)
require.NoError(t, err)
require.Equal(t, len(res.Sequencers), 1, "should have 1 sequences")

// 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)

submitDrsDeprecationStr := "DRS deprecation"
deposit := "500000000000" + dymension.Config().Denom

// Get height
rollappHeight, err := rollapp1.Height(ctx)
require.NoError(t, err)

drsHeight := fmt.Sprint(rollappHeight)

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
}
}

// Submit DRS deprecation proposal
propTx, err := dymension.SubmitDRSDeprecationProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, drsHeight, sequencerAddr, rollapp1ClientOnDym, submitDrsDeprecationStr, submitDrsDeprecationStr, 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")

// Send a normal ibc tx from RA -> Hub
transferData := ibc.WalletData{
Address: dymensionUserAddr,
Denom: rollapp1.Config().Denom,
Amount: transferAmount,
}
_, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{})
require.NoError(t, err)

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)

// Assert balance was updated on the hub
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount))
// Run invariant check
CheckInvariant(t, ctx, dymension, dymensionUser.KeyName())
}