From 559a6544f199bf465bbb601019e7c0643297120e Mon Sep 17 00:00:00 2001 From: RafilxTenfen Date: Fri, 31 Jan 2025 09:41:37 -0300 Subject: [PATCH] chore: add checks for fps prior to epoch finalization and removed gas auto flag from e2e txs --- app/include_upgrade_testnet.go | 2 - test/e2e/btc_rewards_distribution_e2e_test.go | 40 +++++++++++++++++-- test/e2e/configurer/chain/commands.go | 4 +- .../configurer/chain/commands_btcstaking.go | 8 ++-- test/e2e/containers/containers.go | 2 +- 5 files changed, 43 insertions(+), 13 deletions(-) diff --git a/app/include_upgrade_testnet.go b/app/include_upgrade_testnet.go index dbcc6e3b..3fe52678 100644 --- a/app/include_upgrade_testnet.go +++ b/app/include_upgrade_testnet.go @@ -1,5 +1,3 @@ -//go:build testnet - package app import ( diff --git a/test/e2e/btc_rewards_distribution_e2e_test.go b/test/e2e/btc_rewards_distribution_e2e_test.go index 5ce2f775..416dbfa9 100644 --- a/test/e2e/btc_rewards_distribution_e2e_test.go +++ b/test/e2e/btc_rewards_distribution_e2e_test.go @@ -260,12 +260,46 @@ func (s *BtcRewardsDistribution) Test4CommitPublicRandomnessAndSealed() { fp2CommitPubRandList.Sig, ) - n1.WaitUntilCurrentEpochIsSealedAndFinalized(1) + // needs to wait for a block to make sure the pub rand is committed + // prior to epoch finalization + n2.WaitForNextBlockWithSleep50ms() + + // check all FPs requirement to be active + // TotalBondedSat > 0 + // IsTimestamped + // !IsJailed + // !IsSlashed fp1CommitPubRand := n1.QueryListPubRandCommit(fp1CommitPubRandList.FpBtcPk) - s.Require().Equal(fp1CommitPubRand[commitStartHeight].NumPubRand, numPubRand) + fp1PubRand := fp1CommitPubRand[commitStartHeight] + s.Require().Equal(fp1PubRand.NumPubRand, numPubRand) + fp2CommitPubRand := n2.QueryListPubRandCommit(fp2CommitPubRandList.FpBtcPk) - s.Require().Equal(fp2CommitPubRand[commitStartHeight].NumPubRand, numPubRand) + fp2PubRand := fp2CommitPubRand[commitStartHeight] + s.Require().Equal(fp2PubRand.NumPubRand, numPubRand) + + finalizedEpoch := n1.WaitUntilCurrentEpochIsSealedAndFinalized(1) + s.Require().GreaterOrEqual(finalizedEpoch, fp1PubRand.EpochNum) + s.Require().GreaterOrEqual(finalizedEpoch, fp2PubRand.EpochNum) + + fps := n2.QueryFinalityProviders() + s.Require().Len(fps, 2) + for _, fp := range fps { + s.Require().False(fp.Jailed, "fp is jailed") + s.Require().Zero(fp.SlashedBabylonHeight, "fp is slashed") + fpDels := n2.QueryFinalityProviderDelegations(fp.BtcPk.MarshalHex()) + if fp.BtcPk.Equals(s.fp1.BtcPk) { + s.Require().Len(fpDels, 2) + } else { + s.Require().Len(fpDels, 1) + } + for _, fpDelStaker := range fpDels { + for _, fpDel := range fpDelStaker.Dels { + s.Require().True(fpDel.Active) + s.Require().GreaterOrEqual(fpDel.TotalSat, uint64(0)) + } + } + } s.finalityBlockHeightVoted = n1.WaitFinalityIsActivated() diff --git a/test/e2e/configurer/chain/commands.go b/test/e2e/configurer/chain/commands.go index 592501c3..75fb8cc0 100644 --- a/test/e2e/configurer/chain/commands.go +++ b/test/e2e/configurer/chain/commands.go @@ -262,7 +262,7 @@ func (n *NodeConfig) FinalizeSealedEpochs(startEpoch uint64, lastEpoch uint64) { func (n *NodeConfig) StoreWasmCode(wasmFile, from string) { n.LogActionF("storing wasm code from file %s", wasmFile) - cmd := []string{"babylond", "tx", "wasm", "store", wasmFile, fmt.Sprintf("--from=%s", from), "--gas=auto", "--gas-adjustment=1.3"} + cmd := []string{"babylond", "tx", "wasm", "store", wasmFile, fmt.Sprintf("--from=%s", from), "--gas-adjustment=1.3"} n.LogActionF("Executing command: %s", strings.Join(cmd, " ")) _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) @@ -271,7 +271,7 @@ func (n *NodeConfig) StoreWasmCode(wasmFile, from string) { func (n *NodeConfig) InstantiateWasmContract(codeId, initMsg, from string) { n.LogActionF("instantiating wasm contract %s with %s", codeId, initMsg) - cmd := []string{"babylond", "tx", "wasm", "instantiate", codeId, initMsg, fmt.Sprintf("--from=%s", from), "--no-admin", "--label=contract", "--gas=auto", "--gas-adjustment=1.3"} + cmd := []string{"babylond", "tx", "wasm", "instantiate", codeId, initMsg, fmt.Sprintf("--from=%s", from), "--no-admin", "--label=contract", "--gas-adjustment=1.3"} n.LogActionF("Executing command: %s", strings.Join(cmd, " ")) _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) diff --git a/test/e2e/configurer/chain/commands_btcstaking.go b/test/e2e/configurer/chain/commands_btcstaking.go index 701a9f2e..163b9443 100644 --- a/test/e2e/configurer/chain/commands_btcstaking.go +++ b/test/e2e/configurer/chain/commands_btcstaking.go @@ -119,13 +119,11 @@ func (n *NodeConfig) CreateBTCDelegation( } // gas price - cmd = append(cmd, "--gas-prices=0.002ubbn") + cmd = append(cmd, "--gas-prices=1ubbn") if generateOnly { cmd = append(cmd, "--generate-only") } else { - // gas - cmd = append(cmd, "--gas=auto", "--gas-adjustment=1.3") // broadcast stuff cmd = append(cmd, "-b=sync", "--yes") } @@ -176,7 +174,7 @@ func (n *NodeConfig) AddCovenantSigs( // used key cmd = append(cmd, fmt.Sprintf("--from=%s", fromWalletName)) // gas - cmd = append(cmd, "--gas=auto", "--gas-adjustment=2") + cmd = append(cmd, "--gas-adjustment=2") _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) @@ -240,7 +238,7 @@ func (n *NodeConfig) AddFinalitySig( finalitySigHex := finalitySig.ToHexStr() cmd := []string{"babylond", "tx", "finality", "add-finality-sig", fpBTCPKHex, blockHeightStr, pubRandHex, proofHex, appHashHex, finalitySigHex, "--gas=500000"} - additionalArgs := []string{fmt.Sprintf("--chain-id=%s", n.chainId), "--gas-prices=0.002ubbn", "-b=sync", "--yes", "--keyring-backend=test", "--log_format=json", "--home=/home/babylon/babylondata"} + additionalArgs := []string{fmt.Sprintf("--chain-id=%s", n.chainId), "--gas-prices=1ubbn", "-b=sync", "--yes", "--keyring-backend=test", "--log_format=json", "--home=/home/babylon/babylondata"} cmd = append(cmd, additionalArgs...) outBuff, _, err := n.containerManager.ExecCmd(n.t, n.Name, append(cmd, overallFlags...), "code: 0") diff --git a/test/e2e/containers/containers.go b/test/e2e/containers/containers.go index c1c60c9a..542ec46d 100644 --- a/test/e2e/containers/containers.go +++ b/test/e2e/containers/containers.go @@ -72,7 +72,7 @@ func (m *Manager) ExecTxCmd(t *testing.T, chainId string, nodeName string, comma // namely adding flags `--chain-id={chain-id} -b=block --yes --keyring-backend=test "--log_format=json"`, // and searching for `successStr` func (m *Manager) ExecTxCmdWithSuccessString(t *testing.T, chainId string, containerName string, command []string, successStr string) (bytes.Buffer, bytes.Buffer, error) { - additionalArgs := []string{fmt.Sprintf("--chain-id=%s", chainId), "--gas-prices=0.002ubbn", "-b=sync", "--yes", "--keyring-backend=test", "--log_format=json", "--home=/home/babylon/babylondata"} + additionalArgs := []string{fmt.Sprintf("--chain-id=%s", chainId), "--gas-prices=1ubbn", "-b=sync", "--yes", "--keyring-backend=test", "--log_format=json", "--home=/home/babylon/babylondata"} cmd := command cmd = append(cmd, additionalArgs...)