From 0a5e6fc1e0aa4bb6800695fd6609708a5e10d59a Mon Sep 17 00:00:00 2001 From: hungdinh82 Date: Fri, 29 Nov 2024 14:41:54 +0700 Subject: [PATCH 01/10] Test_SeqRewardsAddress_Register_EVM --- Makefile | 6 + tests/sequencer_reward_address_test.go | 499 +++++++++++++++++++++++++ 2 files changed, 505 insertions(+) create mode 100644 tests/sequencer_reward_address_test.go diff --git a/Makefile b/Makefile index f6c37cde..4f65f330 100644 --- a/Makefile +++ b/Makefile @@ -355,6 +355,9 @@ e2e-test-sequencer-rotation-history-sync-old-sequencer-unbonded-p2p-wasm: clean- e2e-test-sequencer-rotation-forced-da-evm: clean-e2e cd tests && go test -timeout=30m -race -v -run Test_SeqRotation_Forced_DA_EVM . + +e2e-test-sequencer-rewardsaddress-register-evm: clean-e2e + cd tests && go test -timeout=30m -race -v -run Test_SeqRewardsAddress_Register_EVM . e2e-test-eibc-client-success-evm: clean-e2e cd tests && go test -timeout=45m -race -v -run Test_EIBC_Client_Success_EVM . @@ -580,6 +583,9 @@ e2e-test-sequencer-rotation-roatate-request-no-da-wasm: clean-e2e e2e-test-zero-fee-relay-wasm: clean-e2e cd tests && go test -timeout=45m -race -v -run TestZeroFee_RelaySuccess_Wasm . +e2e-test-without-genesis-account-evm: clean-e2e + cd tests && go test -timeout=45m -race -v -run TestGenesisBridgeWithoutGenesisAcc_EVM . + # Executes all tests via rollup-e2e-testing e2e-test-all: e2e-test-ibc-success-evm \ e2e-test-ibc-timeout-evm \ diff --git a/tests/sequencer_reward_address_test.go b/tests/sequencer_reward_address_test.go new file mode 100644 index 00000000..e475459b --- /dev/null +++ b/tests/sequencer_reward_address_test.go @@ -0,0 +1,499 @@ +package tests + +import ( + "bufio" + "context" + "fmt" + "os" + "strconv" + "strings" + "testing" + + "cosmossdk.io/math" + transfertypes "github.com/cosmos/ibc-go/v7/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" +) + +func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + 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" + dymintTomlOverrides["da_config"] = "{\"host\":\"grpc-da-container\",\"port\": 7980}" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + + modifyRAGenesisKV := append( + rollappEVMGenesisKV, + 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(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) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + StartDA(ctx, t, client, network) + + // 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, true, 1179360) + require.NoError(t, err) + + containerID := fmt.Sprintf("ra-rollappevm_1234-1-val-0-%s", t.Name()) + + // Get the container details + containerJSON, err := client.ContainerInspect(context.Background(), containerID) + require.NoError(t, err) + + // Extract the IP address from the network settings + // If the container is using a custom network, the IP might be under a specific network name + var ipAddress string + for _, network := range containerJSON.NetworkSettings.Networks { + ipAddress = network.IPAddress + break // Assuming we only need the IP from the first network + } + + nodeId, err := rollapp1.Validators[0].GetNodeId(ctx) + require.NoError(t, err) + nodeId = strings.TrimRight(nodeId, "\n") + p2p_bootstrap_node := fmt.Sprintf("/ip4/%s/tcp/26656/p2p/%s", ipAddress, nodeId) + + rollapp1HomeDir := strings.Split(rollapp1.FullNodes[0].HomeDir(), "/") + rollapp1FolderName := rollapp1HomeDir[len(rollapp1HomeDir)-1] + + file, err := os.Open(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() + + lines := []string{} + scanner := bufio.NewScanner(file) + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } + + for i, line := range lines { + if strings.HasPrefix(line, "p2p_bootstrap_nodes =") { + lines[i] = fmt.Sprintf("p2p_bootstrap_nodes = \"%s\"", p2p_bootstrap_node) + } + } + + output := strings.Join(lines, "\n") + file, err = os.Create(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() + + _, err = file.Write([]byte(output)) + require.NoError(t, err) + + // Start full node + err = rollapp1.FullNodes[0].StopContainer(ctx) + require.NoError(t, err) + + err = rollapp1.FullNodes[0].StartContainer(ctx) + require.NoError(t, err) + + addrDym, _ := r.GetWallet(dymension.GetChainID()) + err = dymension.GetNode().SendFunds(ctx, "faucet", ibc.WalletData{ + Address: addrDym.FormattedAddress(), + Amount: math.NewInt(10_000_000_000_000), + Denom: dymension.Config().Denom, + }) + require.NoError(t, err) + + addrRA, _ := r.GetWallet(rollapp1.GetChainID()) + err = rollapp1.GetNode().SendFunds(ctx, "faucet", ibc.WalletData{ + Address: addrRA.FormattedAddress(), + Amount: math.NewInt(10_000_000_000_000), + Denom: rollapp1.Config().Denom, + }) + 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() + + 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) + + // Send a normal ibc tx from RA -> Hub + 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) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + 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)) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + require.NoError(t, err) + + for _, packet := range res.RollappPackets { + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) + + fmt.Println(txhash) + } + + // 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() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + + // 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, dymensionOrigBal.Sub(transferData.Amount)) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + 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, dymensionOrigBal.Sub(transferData.Amount)) + erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") + require.NoError(t, err) + erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address + testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + + cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) + pub1, _, err := rollapp1.FullNodes[0].Exec(ctx, cmd, nil) + require.NoError(t, err) + + err = dymension.FullNodes[0].CreateKeyWithKeyDir(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()) + require.NoError(t, err) + + sequencer, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()) + require.NoError(t, err) + + fund := ibc.WalletData{ + Address: sequencer, + Denom: dymension.Config().Denom, + Amount: math.NewInt(10_000_000_000_000).MulRaw(100_000_000), + } + err = dymension.SendFunds(ctx, "faucet", fund) + require.NoError(t, err) + + resp0, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, len(resp0.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) + + // rollapp1HomeDir := strings.Split(rollapp1.FullNodes[0].HomeDir(), "/") + // rollapp1FolderName := rollapp1HomeDir[len(rollapp1HomeDir)-1] + + // stop proposer => slashing then + err = rollapp1.Validators[0].StopContainer(ctx) + require.NoError(t, err) + + testutil.WaitForBlocks(ctx, 2, dymension) + + err = rollapp1.Validators[0].StartContainer(ctx) + require.NoError(t, err) + + // full node B bond + command := []string{"sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, "100000000000000000000adym", rollapp1.GetSequencerKeyDir() + "/metadata_sequencer1.json", + "--broadcast-mode", "async", "--keyring-dir", rollapp1.FullNodes[0].HomeDir() + "/sequencer_keys"} + + _, err = dymension.FullNodes[0].ExecTx(ctx, "sequencer", command...) + require.NoError(t, err) + + cmd = append([]string{rollapp1.FullNodes[1].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[1].HomeDir()) + pub1, _, err = rollapp1.FullNodes[1].Exec(ctx, cmd, nil) + require.NoError(t, err) + + err = dymension.FullNodes[0].CreateKeyWithKeyDir(ctx, "sequencer", rollapp1.FullNodes[1].HomeDir()) + require.NoError(t, err) + + sequencerAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", rollapp1.FullNodes[1].HomeDir()) + require.NoError(t, err) + + remainingBond, err := dymension.GetBalance(ctx, sequencerAddr, dymension.Config().Denom) + require.NoError(t, err) + fmt.Printf("Remaining bond: %s\n", remainingBond.String()) + + resp, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, len(resp.Sequencers), 2, "should have 2 sequences") + + nextProposer, err := dymension.GetNode().GetNextProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) + require.NoError(t, err) + require.Equal(t, "sentinel", nextProposer.NextProposerAddr) + fmt.Printf("NextProposer: %+v\n", nextProposer) + + currentProposer, err := dymension.GetNode().GetProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) + require.NoError(t, err) + require.Equal(t, resp0.Sequencers[0].Address, currentProposer.ProposerAddr) + fmt.Printf("CurrentProposer: %+v\n", currentProposer) + + // kick current proposer + err = dymension.FullNodes[0].KickProposer(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()) + require.NoError(t, err) + + // check client was frozen after kicked + clientStatus, err := dymension.GetNode().QueryClientStatus(ctx, "07-tendermint-0") + require.NoError(t, err) + require.Equal(t, "Frozen", clientStatus.Status) + + rollapp1ValHomeDir := strings.Split(rollapp1.Validators[0].HomeDir(), "/") + rollapp1ValFolderName := rollapp1ValHomeDir[len(rollapp1ValHomeDir)-1] + + err = os.RemoveAll(fmt.Sprintf("/tmp/%s/data", rollapp1FolderName)) + require.NoError(t, err) + + err = os.RemoveAll(fmt.Sprintf("/tmp/%s/data", rollapp1ValFolderName)) + require.NoError(t, err) + + for i, fullNode := range rollapp1.FullNodes { + fmt.Printf("Stopping Full Node %d: %s\n", i, fullNode.Name()) + err := fullNode.StopContainer(ctx) + require.NoError(t, err) + } + + err = rollapp1.Validators[0].StopContainer(ctx) + require.NoError(t, err) + + err = rollapp1.FullNodes[0].StartContainer(ctx) + fmt.Printf("Start Full Node 0: \n") + require.NoError(t, err) + + err = rollapp1.FullNodes[1].StartContainer(ctx) + fmt.Printf("Start Full Node 1: \n") + require.NoError(t, err) + + err = rollapp1.FullNodes[2].StartContainer(ctx) + fmt.Printf("Start Full Node 2: \n") + require.NoError(t, err) + + err = rollapp1.Validators[0].StartContainer(ctx) + + if err != nil { + err = rollapp1.Validators[0].StopContainer(ctx) + require.NoError(t, err) + err = rollapp1.Validators[0].StartContainer(ctx) + } + + // check client was frozen after kicked + clientStatus, err = dymension.GetNode().QueryClientStatus(ctx, "07-tendermint-0") + require.NoError(t, err) + require.Equal(t, "Active", clientStatus.Status) + + err = r.StopRelayer(ctx, eRep) + 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) + + // Get original account balances + // 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() + + rollappOrigBal2, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + dymensionOrigBal2, err := dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) + require.NoError(t, err) + + // Send a normal ibc tx from RA -> Hub + transferData = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + _, err = rollapp1.SendIBCTransferAfterHardFork(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + 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, rollappOrigBal2.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) + + res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr) + fmt.Println(res) + require.NoError(t, err) + + for _, packet := range res.RollappPackets { + + proofHeight, _ := strconv.ParseInt(packet.ProofHeight, 10, 64) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), proofHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, packet.RollappId, fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence)) + require.NoError(t, err) + + fmt.Println(txhash) + } + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + // Minus 0.1% of transfer amount for bridge fee + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, dymensionOrigBal2.Add(transferData.Amount).Sub(bridgingFee)) +} From ae5f7daa4dd617ed2a609e8913d7bc1202d56b54 Mon Sep 17 00:00:00 2001 From: hungdinh82 Date: Tue, 3 Dec 2024 15:19:55 +0700 Subject: [PATCH 02/10] demo test --- tests/sequencer_reward_address_test.go | 128 +++++-------------------- 1 file changed, 22 insertions(+), 106 deletions(-) diff --git a/tests/sequencer_reward_address_test.go b/tests/sequencer_reward_address_test.go index e475459b..405b1eed 100644 --- a/tests/sequencer_reward_address_test.go +++ b/tests/sequencer_reward_address_test.go @@ -308,9 +308,9 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) - cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) - pub1, _, err := rollapp1.FullNodes[0].Exec(ctx, cmd, nil) - require.NoError(t, err) + // cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) + // pub1, _, err := rollapp1.FullNodes[0].Exec(ctx, cmd, nil) + // require.NoError(t, err) err = dymension.FullNodes[0].CreateKeyWithKeyDir(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()) require.NoError(t, err) @@ -329,119 +329,26 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { resp0, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) require.NoError(t, err) require.Equal(t, len(resp0.Sequencers), 1, "should have 1 sequences") + fmt.Printf("Type of resp0.Sequencers: %T\n", resp0.Sequencers) + fmt.Println("sequenceraaa: ", resp0.Sequencers) + fmt.Printf("Sequencer details: %+v\n", resp0.Sequencers[0].RewardAddr) + rewardAddress0 := resp0.Sequencers[0].RewardAddr + sequencerAddr := resp0.Sequencers[0].Address + + // Check Sequencer status before submitting fraud + sequencerStatus, err := dymension.GetNode().QuerySequencerStatus(ctx, sequencerAddr) + require.NotEmpty(t, sequencerStatus, "sequencers status is empty") + fmt.Printf("Sequencer2 details: %+v\n", sequencerStatus) // 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) - // rollapp1HomeDir := strings.Split(rollapp1.FullNodes[0].HomeDir(), "/") - // rollapp1FolderName := rollapp1HomeDir[len(rollapp1HomeDir)-1] - - // stop proposer => slashing then - err = rollapp1.Validators[0].StopContainer(ctx) - require.NoError(t, err) - - testutil.WaitForBlocks(ctx, 2, dymension) - - err = rollapp1.Validators[0].StartContainer(ctx) - require.NoError(t, err) - - // full node B bond - command := []string{"sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, "100000000000000000000adym", rollapp1.GetSequencerKeyDir() + "/metadata_sequencer1.json", - "--broadcast-mode", "async", "--keyring-dir", rollapp1.FullNodes[0].HomeDir() + "/sequencer_keys"} - - _, err = dymension.FullNodes[0].ExecTx(ctx, "sequencer", command...) - require.NoError(t, err) - - cmd = append([]string{rollapp1.FullNodes[1].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[1].HomeDir()) - pub1, _, err = rollapp1.FullNodes[1].Exec(ctx, cmd, nil) - require.NoError(t, err) - - err = dymension.FullNodes[0].CreateKeyWithKeyDir(ctx, "sequencer", rollapp1.FullNodes[1].HomeDir()) - require.NoError(t, err) - - sequencerAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", rollapp1.FullNodes[1].HomeDir()) - require.NoError(t, err) - - remainingBond, err := dymension.GetBalance(ctx, sequencerAddr, dymension.Config().Denom) - require.NoError(t, err) - fmt.Printf("Remaining bond: %s\n", remainingBond.String()) - - resp, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) - require.NoError(t, err) - require.Equal(t, len(resp.Sequencers), 2, "should have 2 sequences") - - nextProposer, err := dymension.GetNode().GetNextProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) - require.NoError(t, err) - require.Equal(t, "sentinel", nextProposer.NextProposerAddr) - fmt.Printf("NextProposer: %+v\n", nextProposer) - currentProposer, err := dymension.GetNode().GetProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) require.NoError(t, err) require.Equal(t, resp0.Sequencers[0].Address, currentProposer.ProposerAddr) fmt.Printf("CurrentProposer: %+v\n", currentProposer) - // kick current proposer - err = dymension.FullNodes[0].KickProposer(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()) - require.NoError(t, err) - - // check client was frozen after kicked - clientStatus, err := dymension.GetNode().QueryClientStatus(ctx, "07-tendermint-0") - require.NoError(t, err) - require.Equal(t, "Frozen", clientStatus.Status) - - rollapp1ValHomeDir := strings.Split(rollapp1.Validators[0].HomeDir(), "/") - rollapp1ValFolderName := rollapp1ValHomeDir[len(rollapp1ValHomeDir)-1] - - err = os.RemoveAll(fmt.Sprintf("/tmp/%s/data", rollapp1FolderName)) - require.NoError(t, err) - - err = os.RemoveAll(fmt.Sprintf("/tmp/%s/data", rollapp1ValFolderName)) - require.NoError(t, err) - - for i, fullNode := range rollapp1.FullNodes { - fmt.Printf("Stopping Full Node %d: %s\n", i, fullNode.Name()) - err := fullNode.StopContainer(ctx) - require.NoError(t, err) - } - - err = rollapp1.Validators[0].StopContainer(ctx) - require.NoError(t, err) - - err = rollapp1.FullNodes[0].StartContainer(ctx) - fmt.Printf("Start Full Node 0: \n") - require.NoError(t, err) - - err = rollapp1.FullNodes[1].StartContainer(ctx) - fmt.Printf("Start Full Node 1: \n") - require.NoError(t, err) - - err = rollapp1.FullNodes[2].StartContainer(ctx) - fmt.Printf("Start Full Node 2: \n") - require.NoError(t, err) - - err = rollapp1.Validators[0].StartContainer(ctx) - - if err != nil { - err = rollapp1.Validators[0].StopContainer(ctx) - require.NoError(t, err) - err = rollapp1.Validators[0].StartContainer(ctx) - } - - // check client was frozen after kicked - clientStatus, err = dymension.GetNode().QueryClientStatus(ctx, "07-tendermint-0") - require.NoError(t, err) - require.Equal(t, "Active", clientStatus.Status) - - err = r.StopRelayer(ctx, eRep) - 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) - // Get original account balances // Get the IBC denom for urax on Hub rollappTokenDenom = transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -496,4 +403,13 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { // Minus 0.1% of transfer amount for bridge fee testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, dymensionOrigBal2.Add(transferData.Amount).Sub(bridgingFee)) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + //Query reward address + testutil.AssertBalance(t, ctx, rollapp1, rewardAddress0, rollappIBCDenom, transferData.Amount) + // resp2, err = dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) + // require.NoError(t, err) + // require.Equal(t, len(resp.Sequencers), 2, "should have 2 sequences") } From edef4568efe58fbaa2c38813ebaa61e3db9eea78 Mon Sep 17 00:00:00 2001 From: hungdinh82 Date: Tue, 3 Dec 2024 18:42:50 +0700 Subject: [PATCH 03/10] query OperatorAddress and RewardAddress --- go.mod | 2 +- go.sum | 4 ++-- tests/sequencer_reward_address_test.go | 25 +++++++++++-------------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index 72f277b6..68169511 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ replace ( require ( github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869 - github.com/decentrio/rollup-e2e-testing v0.0.0-20241128151311-2c2569d907f6 + github.com/decentrio/rollup-e2e-testing v0.0.0-20241203113936-47d2934a7110 github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20241016085626-2b8c8898058b ) diff --git a/go.sum b/go.sum index c1bdc8e1..428cf557 100644 --- a/go.sum +++ b/go.sum @@ -742,8 +742,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 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-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-20241128151311-2c2569d907f6 h1:Zgsao3LGmWjTt9snaA4DEq15d3lGTX/toJFQO1oB4lE= -github.com/decentrio/rollup-e2e-testing v0.0.0-20241128151311-2c2569d907f6/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c= +github.com/decentrio/rollup-e2e-testing v0.0.0-20241203113936-47d2934a7110 h1:pC6rMDbIJxXtwlJ6vBcFn9iBjLbvPlYwRRvin4Ycz7g= +github.com/decentrio/rollup-e2e-testing v0.0.0-20241203113936-47d2934a7110/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c= 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.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= diff --git a/tests/sequencer_reward_address_test.go b/tests/sequencer_reward_address_test.go index 405b1eed..25421268 100644 --- a/tests/sequencer_reward_address_test.go +++ b/tests/sequencer_reward_address_test.go @@ -142,7 +142,7 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil, true, 1179360) + }, nil, "", nil, true, 1179360, true) require.NoError(t, err) containerID := fmt.Sprintf("ra-rollappevm_1234-1-val-0-%s", t.Name()) @@ -329,16 +329,16 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { resp0, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) require.NoError(t, err) require.Equal(t, len(resp0.Sequencers), 1, "should have 1 sequences") - fmt.Printf("Type of resp0.Sequencers: %T\n", resp0.Sequencers) - fmt.Println("sequenceraaa: ", resp0.Sequencers) - fmt.Printf("Sequencer details: %+v\n", resp0.Sequencers[0].RewardAddr) - rewardAddress0 := resp0.Sequencers[0].RewardAddr - sequencerAddr := resp0.Sequencers[0].Address - // Check Sequencer status before submitting fraud - sequencerStatus, err := dymension.GetNode().QuerySequencerStatus(ctx, sequencerAddr) - require.NotEmpty(t, sequencerStatus, "sequencers status is empty") - fmt.Printf("Sequencer2 details: %+v\n", sequencerStatus) + operatorAddress, err := rollapp1.GetNode().QueryOperatorAddress(ctx) + require.NoError(t, err) + fmt.Printf("OperatorAddress: %s\n", operatorAddress.Sequencers[0].OperatorAddress) + operatorAddr := operatorAddress.Sequencers[0].OperatorAddress + + rewardAddress, err := rollapp1.GetNode().QuerySequencersRewardAddressResponse(ctx, operatorAddr) + require.NoError(t, err) + rewardAddrStr := rewardAddress.RewardAddr + fmt.Printf("Reward Address: %s\n", rewardAddrStr) // Wait a few blocks for relayer to start and for user accounts to be created err = testutil.WaitForBlocks(ctx, 5, dymension) @@ -408,8 +408,5 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { require.NoError(t, err) //Query reward address - testutil.AssertBalance(t, ctx, rollapp1, rewardAddress0, rollappIBCDenom, transferData.Amount) - // resp2, err = dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) - // require.NoError(t, err) - // require.Equal(t, len(resp.Sequencers), 2, "should have 2 sequences") + testutil.AssertBalance(t, ctx, rollapp1, rewardAddrStr, rollappIBCDenom, transferData.Amount) } From 2ef984468538c7ae59910ce2b9617ca9c9e1ed09 Mon Sep 17 00:00:00 2001 From: hungdinh82 Date: Tue, 3 Dec 2024 18:45:57 +0700 Subject: [PATCH 04/10] query OperatorAddress and RewardAddress --- tests/sequencer_reward_address_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sequencer_reward_address_test.go b/tests/sequencer_reward_address_test.go index 25421268..fdd276df 100644 --- a/tests/sequencer_reward_address_test.go +++ b/tests/sequencer_reward_address_test.go @@ -404,7 +404,7 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { // Minus 0.1% of transfer amount for bridge fee testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, dymensionOrigBal2.Add(transferData.Amount).Sub(bridgingFee)) - err = testutil.WaitForBlocks(ctx, 10, dymension) + err = testutil.WaitForBlocks(ctx, 10, rollapp1) require.NoError(t, err) //Query reward address From 83fef5355be5a568143564e787051efb9d70d4f9 Mon Sep 17 00:00:00 2001 From: hungdinh82 Date: Thu, 5 Dec 2024 10:38:54 +0700 Subject: [PATCH 05/10] demo reward address --- go.mod | 2 +- go.sum | 4 ++-- tests/sequencer_reward_address_test.go | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6b5b6f8f..ad12dd8d 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ replace ( require ( github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869 - github.com/decentrio/rollup-e2e-testing v0.0.0-20241203163830-0ec6a256e05a + github.com/decentrio/rollup-e2e-testing v0.0.0-20241204082659-8fb6256b33b1 github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20241016085626-2b8c8898058b ) diff --git a/go.sum b/go.sum index 2dc486f8..6317fe10 100644 --- a/go.sum +++ b/go.sum @@ -742,8 +742,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 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-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-20241203163830-0ec6a256e05a h1:y1VChGtaMPIV5JYP6V4E4bfmhi0IFm9pELPD9X/GwhI= -github.com/decentrio/rollup-e2e-testing v0.0.0-20241203163830-0ec6a256e05a/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c= +github.com/decentrio/rollup-e2e-testing v0.0.0-20241204082659-8fb6256b33b1 h1:x1DvhPzPT6WQwl4QyoDReX+3VQ7NLmr2oZi755d+IyA= +github.com/decentrio/rollup-e2e-testing v0.0.0-20241204082659-8fb6256b33b1/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c= 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.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= diff --git a/tests/sequencer_reward_address_test.go b/tests/sequencer_reward_address_test.go index fdd276df..1e14a1c8 100644 --- a/tests/sequencer_reward_address_test.go +++ b/tests/sequencer_reward_address_test.go @@ -325,11 +325,21 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { } err = dymension.SendFunds(ctx, "faucet", fund) require.NoError(t, err) + + // resp, err := dymension.GetNode().GetProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) + // require.NoError(t, err) + // proposerAddr := resp.ProposerAddr + // fmt.Println("proposerAddr: ", proposerAddr) resp0, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) require.NoError(t, err) require.Equal(t, len(resp0.Sequencers), 1, "should have 1 sequences") + fmt.Println("sequenceeeee: ", resp0) + // rewardAddress, err := dymension.GetNode().QuerySequencersRewardAddressByDymResponse(ctx) + // require.NoError(t, err) + // rewardAddrStr := rewardAddress.RewardAddr + // fmt.Printf("RewardAddress2: %s\n", rewardAddrStr) operatorAddress, err := rollapp1.GetNode().QueryOperatorAddress(ctx) require.NoError(t, err) fmt.Printf("OperatorAddress: %s\n", operatorAddress.Sequencers[0].OperatorAddress) @@ -408,5 +418,8 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { require.NoError(t, err) //Query reward address + // balance, err := rollapp1.GetBalance(ctx, rewardAddrStr, dymensionIBCDenom) + // require.NoError(t, err) + // require.True(t, balance.Sign() > 0, fmt.Sprintf("Balance is not greater than 0. Actual balance: %s", balance.String())) testutil.AssertBalance(t, ctx, rollapp1, rewardAddrStr, rollappIBCDenom, transferData.Amount) } From ea7a278c9088a36d53a488cda5e78d795623092c Mon Sep 17 00:00:00 2001 From: hungdinh82 Date: Thu, 5 Dec 2024 14:45:32 +0700 Subject: [PATCH 06/10] update setup genesis proposer reward --- tests/sequencer_reward_address_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/sequencer_reward_address_test.go b/tests/sequencer_reward_address_test.go index 1e14a1c8..92973e6d 100644 --- a/tests/sequencer_reward_address_test.go +++ b/tests/sequencer_reward_address_test.go @@ -52,6 +52,14 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { Key: "app_state.rollappparams.params.da", Value: "grpc", }, + cosmos.GenesisKV{ + Key: "app_state.distribution.params.base_proposer_reward", + Value: "0.9999999999999", + }, + cosmos.GenesisKV{ + Key: "app_state.distribution.params.bonus_proposer_reward", + Value: "0.999999999987", + }, ) // Create chain factory with dymension @@ -348,7 +356,7 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { rewardAddress, err := rollapp1.GetNode().QuerySequencersRewardAddressResponse(ctx, operatorAddr) require.NoError(t, err) rewardAddrStr := rewardAddress.RewardAddr - fmt.Printf("Reward Address: %s\n", rewardAddrStr) + fmt.Printf("RewardAddress2: %s\n", rewardAddrStr) // Wait a few blocks for relayer to start and for user accounts to be created err = testutil.WaitForBlocks(ctx, 5, dymension) @@ -418,6 +426,7 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { require.NoError(t, err) //Query reward address + fmt.Printf("RewardAddress3: %s\n", rewardAddrStr) // balance, err := rollapp1.GetBalance(ctx, rewardAddrStr, dymensionIBCDenom) // require.NoError(t, err) // require.True(t, balance.Sign() > 0, fmt.Sprintf("Balance is not greater than 0. Actual balance: %s", balance.String())) From 542b3088ef7b02c83e9f067ac1d6dd9d025a428e Mon Sep 17 00:00:00 2001 From: hungdinh82 Date: Fri, 6 Dec 2024 13:50:43 +0700 Subject: [PATCH 07/10] update logic --- tests/sequencer_reward_address_test.go | 43 +++++++++++++++++--------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/tests/sequencer_reward_address_test.go b/tests/sequencer_reward_address_test.go index 92973e6d..28fce315 100644 --- a/tests/sequencer_reward_address_test.go +++ b/tests/sequencer_reward_address_test.go @@ -54,11 +54,11 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { }, cosmos.GenesisKV{ Key: "app_state.distribution.params.base_proposer_reward", - Value: "0.9999999999999", + Value: "0.9", }, cosmos.GenesisKV{ Key: "app_state.distribution.params.bonus_proposer_reward", - Value: "0.999999999987", + Value: "1", }, ) @@ -333,16 +333,11 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { } err = dymension.SendFunds(ctx, "faucet", fund) require.NoError(t, err) - - // resp, err := dymension.GetNode().GetProposerByRollapp(ctx, rollapp1.Config().ChainID, dymensionUserAddr) - // require.NoError(t, err) - // proposerAddr := resp.ProposerAddr - // fmt.Println("proposerAddr: ", proposerAddr) resp0, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) require.NoError(t, err) require.Equal(t, len(resp0.Sequencers), 1, "should have 1 sequences") - fmt.Println("sequenceeeee: ", resp0) + // fmt.Println("sequenceeeee: ", resp0) // rewardAddress, err := dymension.GetNode().QuerySequencersRewardAddressByDymResponse(ctx) // require.NoError(t, err) @@ -350,13 +345,13 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { // fmt.Printf("RewardAddress2: %s\n", rewardAddrStr) operatorAddress, err := rollapp1.GetNode().QueryOperatorAddress(ctx) require.NoError(t, err) - fmt.Printf("OperatorAddress: %s\n", operatorAddress.Sequencers[0].OperatorAddress) + // fmt.Printf("OperatorAddress: %s\n", operatorAddress.Sequencers[0].OperatorAddress) operatorAddr := operatorAddress.Sequencers[0].OperatorAddress rewardAddress, err := rollapp1.GetNode().QuerySequencersRewardAddressResponse(ctx, operatorAddr) require.NoError(t, err) rewardAddrStr := rewardAddress.RewardAddr - fmt.Printf("RewardAddress2: %s\n", rewardAddrStr) + // fmt.Printf("RewardAddress2: %s\n", rewardAddrStr) // Wait a few blocks for relayer to start and for user accounts to be created err = testutil.WaitForBlocks(ctx, 5, dymension) @@ -426,9 +421,27 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { require.NoError(t, err) //Query reward address - fmt.Printf("RewardAddress3: %s\n", rewardAddrStr) - // balance, err := rollapp1.GetBalance(ctx, rewardAddrStr, dymensionIBCDenom) - // require.NoError(t, err) - // require.True(t, balance.Sign() > 0, fmt.Sprintf("Balance is not greater than 0. Actual balance: %s", balance.String())) - testutil.AssertBalance(t, ctx, rollapp1, rewardAddrStr, rollappIBCDenom, transferData.Amount) + // fmt.Printf("RewardAddress3: %s\n", rewardAddrStr) + balance, err := rollapp1.GetBalance(ctx, rewardAddrStr, rollapp1.Config().Denom) + require.NoError(t, err) + // t.Logf("Balance retrieved: %s", balance.String()) + require.True(t, balance.Sign() > 0, fmt.Sprintf("Balance is not greater than 0. Actual balance: %s", balance.String())) + + var baseProposerReward float64 + for _, kv := range modifyRAGenesisKV { + if kv.Key == "app_state.distribution.params.base_proposer_reward" { + valueStr, ok := kv.Value.(string) + require.True(t, ok, "kv.Value should be a string") + value, err := strconv.ParseFloat(valueStr, 64) + require.NoError(t, err) + baseProposerReward = value + break + } + } + + feesCollected := float64(4000000000000000) + expectedAmount := int64(feesCollected * baseProposerReward) + expectedAmountInt := math.NewInt(expectedAmount) + + testutil.AssertBalance(t, ctx, rollapp1, rewardAddrStr, rollapp1.Config().Denom, expectedAmountInt) } From 9d1e33cbe37c85d552cd6b4d8175b32e5f7cf05c Mon Sep 17 00:00:00 2001 From: hungdinh82 Date: Fri, 6 Dec 2024 15:22:50 +0700 Subject: [PATCH 08/10] Test_SeqRewardsAddress_Register_EVM --- tests/sequencer_reward_address_test.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/sequencer_reward_address_test.go b/tests/sequencer_reward_address_test.go index 28fce315..ef2ae0fd 100644 --- a/tests/sequencer_reward_address_test.go +++ b/tests/sequencer_reward_address_test.go @@ -316,10 +316,6 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) - // cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) - // pub1, _, err := rollapp1.FullNodes[0].Exec(ctx, cmd, nil) - // require.NoError(t, err) - err = dymension.FullNodes[0].CreateKeyWithKeyDir(ctx, "sequencer", rollapp1.FullNodes[0].HomeDir()) require.NoError(t, err) @@ -337,21 +333,14 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { resp0, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) require.NoError(t, err) require.Equal(t, len(resp0.Sequencers), 1, "should have 1 sequences") - // fmt.Println("sequenceeeee: ", resp0) - // rewardAddress, err := dymension.GetNode().QuerySequencersRewardAddressByDymResponse(ctx) - // require.NoError(t, err) - // rewardAddrStr := rewardAddress.RewardAddr - // fmt.Printf("RewardAddress2: %s\n", rewardAddrStr) operatorAddress, err := rollapp1.GetNode().QueryOperatorAddress(ctx) require.NoError(t, err) - // fmt.Printf("OperatorAddress: %s\n", operatorAddress.Sequencers[0].OperatorAddress) operatorAddr := operatorAddress.Sequencers[0].OperatorAddress rewardAddress, err := rollapp1.GetNode().QuerySequencersRewardAddressResponse(ctx, operatorAddr) require.NoError(t, err) rewardAddrStr := rewardAddress.RewardAddr - // fmt.Printf("RewardAddress2: %s\n", rewardAddrStr) // Wait a few blocks for relayer to start and for user accounts to be created err = testutil.WaitForBlocks(ctx, 5, dymension) @@ -421,10 +410,8 @@ func Test_SeqRewardsAddress_Register_EVM(t *testing.T) { require.NoError(t, err) //Query reward address - // fmt.Printf("RewardAddress3: %s\n", rewardAddrStr) balance, err := rollapp1.GetBalance(ctx, rewardAddrStr, rollapp1.Config().Denom) require.NoError(t, err) - // t.Logf("Balance retrieved: %s", balance.String()) require.True(t, balance.Sign() > 0, fmt.Sprintf("Balance is not greater than 0. Actual balance: %s", balance.String())) var baseProposerReward float64 From b387805552630e8a42f67f95e13a05bae5f9f8b7 Mon Sep 17 00:00:00 2001 From: hungdinh82 Date: Fri, 6 Dec 2024 15:50:18 +0700 Subject: [PATCH 09/10] Test_SeqRewardsAddress_Register_EVM --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ad12dd8d..60ec6670 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ replace ( require ( github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869 - github.com/decentrio/rollup-e2e-testing v0.0.0-20241204082659-8fb6256b33b1 + github.com/decentrio/rollup-e2e-testing v0.0.0-20241206083746-e0730d19e731 github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20241016085626-2b8c8898058b ) diff --git a/go.sum b/go.sum index 6317fe10..1796a65b 100644 --- a/go.sum +++ b/go.sum @@ -742,8 +742,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 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-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-20241204082659-8fb6256b33b1 h1:x1DvhPzPT6WQwl4QyoDReX+3VQ7NLmr2oZi755d+IyA= -github.com/decentrio/rollup-e2e-testing v0.0.0-20241204082659-8fb6256b33b1/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c= +github.com/decentrio/rollup-e2e-testing v0.0.0-20241206083746-e0730d19e731 h1:+ZZm+5DOWiePMrLjtk69oSV3ZvRLB/zomHzkvTvhBq8= +github.com/decentrio/rollup-e2e-testing v0.0.0-20241206083746-e0730d19e731/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c= 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.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= From 65bc9fe531f0e0727c15b860eb03289e67780b7a Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Fri, 6 Dec 2024 16:05:15 +0700 Subject: [PATCH 10/10] update framework --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 60ec6670..c87e682f 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ replace ( require ( github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869 - github.com/decentrio/rollup-e2e-testing v0.0.0-20241206083746-e0730d19e731 + github.com/decentrio/rollup-e2e-testing v0.0.0-20241206090130-1ad748f0b1ec github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20241016085626-2b8c8898058b ) diff --git a/go.sum b/go.sum index 1796a65b..80aa8612 100644 --- a/go.sum +++ b/go.sum @@ -742,8 +742,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 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-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-20241206083746-e0730d19e731 h1:+ZZm+5DOWiePMrLjtk69oSV3ZvRLB/zomHzkvTvhBq8= -github.com/decentrio/rollup-e2e-testing v0.0.0-20241206083746-e0730d19e731/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c= +github.com/decentrio/rollup-e2e-testing v0.0.0-20241206090130-1ad748f0b1ec h1:ylphmWXNGzstU4YhthB7YDXSE+g+rndFwV9lp6riWU4= +github.com/decentrio/rollup-e2e-testing v0.0.0-20241206090130-1ad748f0b1ec/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c= 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.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y=