Skip to content

Commit

Permalink
chore: add checks for fps prior to epoch finalization and removed gas…
Browse files Browse the repository at this point in the history
… auto flag from e2e txs
  • Loading branch information
RafilxTenfen committed Jan 31, 2025
1 parent e5c8ffc commit 559a654
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 13 deletions.
2 changes: 0 additions & 2 deletions app/include_upgrade_testnet.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build testnet

package app

import (
Expand Down
40 changes: 37 additions & 3 deletions test/e2e/btc_rewards_distribution_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/configurer/chain/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions test/e2e/configurer/chain/commands_btcstaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/containers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down

0 comments on commit 559a654

Please sign in to comment.