chore(v0.50.0): Migrating codebase to latest SDK version (#215)
This commit is contained in:
+7
-3
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
dbm "github.com/cometbft/cometbft-db"
|
||||
"github.com/cometbft/cometbft/libs/log"
|
||||
"cosmossdk.io/log"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
"github.com/skip-mev/pob/tests/app"
|
||||
@@ -40,7 +40,11 @@ type chain struct {
|
||||
}
|
||||
|
||||
func newChain() (*chain, error) {
|
||||
tmpDir, err := os.MkdirTemp("", "pob-e2e-testnet-")
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tmpDir, err := os.MkdirTemp(pwd, ".pob-e2e-testnet-")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+11
-10
@@ -11,6 +11,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
cometcfg "github.com/cometbft/cometbft/config"
|
||||
cometjson "github.com/cometbft/cometbft/libs/json"
|
||||
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
|
||||
@@ -31,9 +32,9 @@ import (
|
||||
|
||||
var (
|
||||
numValidators = 4
|
||||
minGasPrice = sdk.NewDecCoinFromDec(app.BondDenom, sdk.MustNewDecFromStr("0.02")).String()
|
||||
minGasPrice = sdk.NewDecCoinFromDec(app.BondDenom, math.LegacyMustNewDecFromStr("0.02")).String()
|
||||
initBalanceStr = sdk.NewInt64Coin(app.BondDenom, 1000000000000000000).String()
|
||||
stakeAmount, _ = sdk.NewIntFromString("100000000000")
|
||||
stakeAmount = math.NewInt(100000000000)
|
||||
stakeAmountCoin = sdk.NewCoin(app.BondDenom, stakeAmount)
|
||||
)
|
||||
|
||||
@@ -116,15 +117,12 @@ func (s *IntegrationTestSuite) initNodes() {
|
||||
val0ConfigDir := s.chain.validators[0].configDir()
|
||||
|
||||
// Define the builder module parameters
|
||||
escrowAddress, err := sdk.AccAddressFromBech32("cosmos14j5j2lsx7629590jvpk3vj0xe9w8203jf4yknk")
|
||||
s.Require().Nil(err, "Unexpected error decoding escrow address")
|
||||
|
||||
params := types.Params{
|
||||
MaxBundleSize: 5,
|
||||
EscrowAccountAddress: escrowAddress,
|
||||
ReserveFee: sdk.NewCoin(app.BondDenom, sdk.NewInt(1000000)),
|
||||
MinBidIncrement: sdk.NewCoin(app.BondDenom, sdk.NewInt(1000000)),
|
||||
ProposerFee: sdk.NewDecWithPrec(1, 2),
|
||||
EscrowAccountAddress: sdk.MustAccAddressFromBech32("cosmos14j5j2lsx7629590jvpk3vj0xe9w8203jf4yknk").Bytes(),
|
||||
ReserveFee: sdk.NewCoin(app.BondDenom, math.NewInt(1000000)),
|
||||
MinBidIncrement: sdk.NewCoin(app.BondDenom, math.NewInt(1000000)),
|
||||
ProposerFee: math.LegacyMustNewDecFromStr("0.1"),
|
||||
FrontRunningProtection: true,
|
||||
}
|
||||
|
||||
@@ -162,7 +160,7 @@ func (s *IntegrationTestSuite) initGenesis() {
|
||||
|
||||
votingPeriod := 5 * time.Second
|
||||
govGenState.Params.VotingPeriod = &votingPeriod
|
||||
govGenState.Params.MinDeposit = sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(100)))
|
||||
govGenState.Params.MinDeposit = sdk.NewCoins(sdk.NewCoin(app.BondDenom, math.NewInt(100)))
|
||||
|
||||
bz, err := cdc.MarshalJSON(&govGenState)
|
||||
s.Require().NoError(err)
|
||||
@@ -223,6 +221,9 @@ func (s *IntegrationTestSuite) initValidatorConfigs() {
|
||||
valConfig.RPC.ListenAddress = "tcp://0.0.0.0:26657"
|
||||
valConfig.StateSync.Enable = false
|
||||
valConfig.LogLevel = "info"
|
||||
valConfig.BaseConfig.Genesis = filepath.Join("config", "genesis.json")
|
||||
valConfig.RootDir = filepath.Join("root", ".simapp")
|
||||
valConfig.Consensus.TimeoutCommit = 2 * time.Second
|
||||
|
||||
var peers []string
|
||||
|
||||
|
||||
+182
-181
@@ -3,6 +3,7 @@
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/tests/app"
|
||||
)
|
||||
@@ -28,7 +29,7 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
accounts := s.createTestAccounts(numAccounts, initBalance)
|
||||
|
||||
// basic send amount
|
||||
defaultSendAmount := sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(10)))
|
||||
defaultSendAmount := sdk.NewCoins(sdk.NewCoin(app.BondDenom, math.NewInt(10)))
|
||||
|
||||
// auction parameters
|
||||
params := s.queryBuilderParams()
|
||||
@@ -39,7 +40,7 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
|
||||
// standard tx params
|
||||
gasLimit := uint64(5000000)
|
||||
fees := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(150000)))
|
||||
fees := sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(150000)))
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
@@ -56,15 +57,17 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
s.createMsgSendTx(accounts[0], accounts[1].Address.String(), defaultSendAmount, 1, 1000, gasLimit, fees),
|
||||
}
|
||||
|
||||
s.waitForABlock()
|
||||
|
||||
// Create a bid transaction that includes the bundle and is valid
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[0], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[0], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("Valid auction bid", bidTx, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
// Ensure that the block was correctly created and executed in the order expected
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
@@ -72,7 +75,7 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
bundleHashes[0]: true,
|
||||
bundleHashes[1]: true,
|
||||
}
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid)
|
||||
@@ -91,15 +94,17 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
bundle[i] = s.createMsgSendTx(accounts[0], accounts[1].Address.String(), defaultSendAmount, uint64(i), 1000, gasLimit, fees)
|
||||
}
|
||||
|
||||
// Wait for a block to ensure all transactions are included in the same block
|
||||
s.waitForABlock()
|
||||
|
||||
// Create a bid transaction that includes the bundle and is valid
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.displayExpectedBundle("gud auction bid", bidTx, bundle)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// broadcast the bid so that it can be included in a vote extension of a coming block
|
||||
s.waitForABlock()
|
||||
|
||||
// Execute a few other messages to be included in the block after the bid and bundle
|
||||
normalTxs := make([][]byte, 3)
|
||||
@@ -128,7 +133,7 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
expectedExecution[hash] = true
|
||||
}
|
||||
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid)
|
||||
@@ -147,32 +152,33 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
bundle[i] = s.createMsgSendTx(accounts[0], accounts[1].Address.String(), defaultSendAmount, uint64(i), 1000, gasLimit, fees)
|
||||
}
|
||||
|
||||
// Wait for a block to ensure all transactions are included in the same block
|
||||
s.waitForABlock()
|
||||
|
||||
// Create a bid transaction that includes the bundle and is valid
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.displayExpectedBundle("gud auction bid 1", bidTx, bundle)
|
||||
|
||||
// Create another bid transaction that includes the bundle and is valid from the same account
|
||||
// to verify that user can bid with the same account multiple times in the same block
|
||||
bid2 := bid.Add(minBidIncrement)
|
||||
bidTx2 := s.createAuctionBidTx(accounts[1], bid2, bundle, 0, height+1, gasLimit, fees)
|
||||
s.broadcastTx(bidTx2, 0)
|
||||
bidTx2 := s.createAuctionBidTx(accounts[1], bid2, bundle, 0, height+3, gasLimit, fees)
|
||||
s.displayExpectedBundle("gud auction bid 2", bidTx2, bundle)
|
||||
|
||||
// Create a third bid
|
||||
bid3 := bid2.Add(minBidIncrement)
|
||||
bidTx3 := s.createAuctionBidTx(accounts[1], bid3, bundle, 0, height+1, gasLimit, fees)
|
||||
s.broadcastTx(bidTx3, 0)
|
||||
bidTx3 := s.createAuctionBidTx(accounts[1], bid3, bundle, 0, height+3, gasLimit, fees)
|
||||
s.displayExpectedBundle("gud auction bid 3", bidTx3, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
// Wait for a block to ensure all transactions are included in the same block
|
||||
s.waitForABlock()
|
||||
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.broadcastTx(bidTx2, 0)
|
||||
s.broadcastTx(bidTx3, 0)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
// Ensure that the block was correctly created and executed in the order expected
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
bundleHashes2 := s.bundleToTxHashes(bidTx2, bundle)
|
||||
@@ -180,14 +186,13 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
expectedExecution := map[string]bool{
|
||||
bundleHashes[0]: false,
|
||||
bundleHashes2[0]: false,
|
||||
bundleHashes3[0]: true,
|
||||
}
|
||||
|
||||
for _, hash := range bundleHashes3[1:] {
|
||||
for _, hash := range bundleHashes3 {
|
||||
expectedExecution[hash] = true
|
||||
}
|
||||
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes3, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+3, bundleHashes3, expectedExecution)
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid3)
|
||||
@@ -212,17 +217,21 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
// Create a bid transaction that includes the bundle and is valid
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[2], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[2], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.displayExpectedBundle("gud auction bid", bidTx, bundle)
|
||||
|
||||
// Broadcast the bid transaction
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Wait for a block to broadcast other transactions so that the normal txs can be included in the
|
||||
// mempool before they are included in a proposal with the vote extensions
|
||||
s.waitForABlock()
|
||||
|
||||
// Broadcast all of the transactions in the bundle to the mempool
|
||||
for _, tx := range bundle {
|
||||
s.broadcastTx(tx, 0)
|
||||
}
|
||||
|
||||
// Broadcast the bid transaction
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Broadcast some other transactions to the mempool
|
||||
normalTxs := make([][]byte, 10)
|
||||
for i := 0; i < 10; i++ {
|
||||
@@ -247,7 +256,7 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
expectedExecution[hash] = true
|
||||
}
|
||||
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid)
|
||||
@@ -272,9 +281,13 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
// Create a bid transaction that includes the bundle and is valid
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Wait for a block to broadcast other transactions so that the normal txs can be included in the
|
||||
// mempool before they are included in a proposal with the vote extensions
|
||||
s.waitForABlock()
|
||||
|
||||
// Execute a few other messages to be included in the block after the bid and bundle
|
||||
normalTxs := make([][]byte, 3)
|
||||
normalTxs[0] = s.createMsgSendTx(accounts[1], accounts[1].Address.String(), defaultSendAmount, 0, 1000, gasLimit, fees)
|
||||
@@ -306,7 +319,7 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
expectedExecution[hash] = true
|
||||
}
|
||||
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid)
|
||||
@@ -338,7 +351,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
accounts := s.createTestAccounts(numAccounts, initBalance)
|
||||
|
||||
// basic send amount
|
||||
defaultSendAmount := sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(10)))
|
||||
defaultSendAmount := sdk.NewCoins(sdk.NewCoin(app.BondDenom, math.NewInt(10)))
|
||||
|
||||
// auction parameters
|
||||
params := s.queryBuilderParams()
|
||||
@@ -349,7 +362,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
|
||||
// standard tx params
|
||||
gasLimit := uint64(5000000)
|
||||
fees := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(150000)))
|
||||
fees := sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(150000)))
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
@@ -378,7 +391,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
bidTx := s.createAuctionBidTx(accounts[2], bid, bundle, 0, height+5, gasLimit, fees)
|
||||
|
||||
// Createa a second bid transaction that includes the bundle and is valid
|
||||
bid2 := reserveFee.Add(sdk.NewCoin(app.BondDenom, sdk.NewInt(10)))
|
||||
bid2 := reserveFee.Add(sdk.NewCoin(app.BondDenom, math.NewInt(10)))
|
||||
bidTx2 := s.createAuctionBidTx(accounts[3], bid2, bundle2, 0, height+5, gasLimit, fees)
|
||||
|
||||
// Wait for a block to ensure all transactions are included in the same block
|
||||
@@ -413,7 +426,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
}
|
||||
|
||||
// Pass in nil since we don't know the order of transactions that ill be executed
|
||||
s.verifyTopOfBlockAuction(height+2, nil, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+3, nil, expectedExecution)
|
||||
|
||||
// Ensure that the escrow account has the correct balance (both bids should have been extracted by this point)
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid).Add(s.calculateProposerEscrowSplit(bid2))
|
||||
@@ -443,18 +456,18 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
// Create a bid transaction that includes the bundle and is valid
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[2], bid, bundle, 0, height+2, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[2], bid, bundle, 0, height+5, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("gud auction bid 1", bidTx, bundle)
|
||||
|
||||
// Create another bid transaction that includes the bundle and is valid from a different account
|
||||
bid2 := bid.Add(minBidIncrement)
|
||||
bidTx2 := s.createAuctionBidTx(accounts[3], bid2, bundle2, 0, height+1, gasLimit, fees)
|
||||
s.broadcastTx(bidTx2, 0)
|
||||
bidTx2 := s.createAuctionBidTx(accounts[3], bid2, bundle2, 0, height+5, gasLimit, fees)
|
||||
s.broadcastTx(bidTx2, 1)
|
||||
s.displayExpectedBundle("gud auction bid 2", bidTx2, bundle2)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
s.waitForNBlocks(3)
|
||||
|
||||
// Ensure that the block was correctly created and executed in the order expected
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
@@ -467,10 +480,10 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
expectedExecution[hash] = true
|
||||
}
|
||||
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes2, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes2, expectedExecution)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
s.waitForNBlocks(3)
|
||||
|
||||
// Ensure that the block was correctly created and executed in the order expected
|
||||
expectedExecution = map[string]bool{
|
||||
@@ -481,7 +494,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
expectedExecution[hash] = true
|
||||
}
|
||||
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+4, bundleHashes, expectedExecution)
|
||||
|
||||
// Ensure that the escrow account has the correct balance (both bids should have been extracted by this point)
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid).Add(s.calculateProposerEscrowSplit(bid2))
|
||||
@@ -499,21 +512,23 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
s.createMsgSendTx(accounts[0], accounts[1].Address.String(), defaultSendAmount, 1, 1000, gasLimit, fees),
|
||||
}
|
||||
|
||||
s.waitForABlock()
|
||||
|
||||
// Create a bid transaction that includes the bundle and is valid
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[0], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[0], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("bid 1", bidTx, bundle)
|
||||
|
||||
// Create a second bid transaction that includes the bundle and is valid (but smaller than the min bid increment)
|
||||
badBid := reserveFee.Add(sdk.NewInt64Coin(app.BondDenom, 10))
|
||||
bidTx2 := s.createAuctionBidTx(accounts[0], badBid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx2 := s.createAuctionBidTx(accounts[0], badBid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx2, 0)
|
||||
s.displayExpectedBundle("bid 2", bidTx2, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
// Ensure only the first bid was executed
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
@@ -523,7 +538,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
bundleHashes[1]: true,
|
||||
bundleHashes2[0]: false,
|
||||
}
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid)
|
||||
@@ -531,7 +546,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
|
||||
// Wait another block to make sure the second bid is not executed
|
||||
s.waitForABlock()
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes2, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+4, bundleHashes2, expectedExecution)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -545,21 +560,23 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
s.createMsgSendTx(accounts[2], accounts[1].Address.String(), defaultSendAmount, 0, 1000, gasLimit, fees),
|
||||
}
|
||||
|
||||
s.waitForABlock()
|
||||
|
||||
// Create a bid transaction that includes the bundle and is valid
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[0], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[0], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("bid 1", bidTx, bundle)
|
||||
|
||||
// Create a second bid transaction that includes the bundle and is valid (but smaller than the min bid increment)
|
||||
badBid := reserveFee.Add(sdk.NewInt64Coin(app.BondDenom, 10))
|
||||
bidTx2 := s.createAuctionBidTx(accounts[1], badBid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx2 := s.createAuctionBidTx(accounts[1], badBid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx2, 0)
|
||||
s.displayExpectedBundle("bid 2", bidTx2, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
// Ensure only the first bid was executed
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
@@ -569,7 +586,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
bundleHashes[1]: true,
|
||||
bundleHashes2[0]: false,
|
||||
}
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid)
|
||||
@@ -577,99 +594,55 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
|
||||
// Wait another block to make sure the second bid is not executed
|
||||
s.waitForABlock()
|
||||
s.verifyTopOfBlockAuction(height+4, bundleHashes2, expectedExecution)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Multiple transactions with increasing bids but first bid has same bundle so it should fail in later block (different accounts)",
|
||||
test: func() {
|
||||
// Get escrow account balance
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a single transaction
|
||||
bundle := [][]byte{
|
||||
s.createMsgSendTx(accounts[2], accounts[1].Address.String(), defaultSendAmount, 0, 1000, gasLimit, fees),
|
||||
}
|
||||
|
||||
s.waitForABlock()
|
||||
|
||||
// Create a bid transaction that includes the bundle and is valid
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("bid 1", bidTx, bundle)
|
||||
|
||||
// Create a second bid transaction that includes the bundle and is valid
|
||||
bid2 := reserveFee.Add(minBidIncrement)
|
||||
bidTx2 := s.createAuctionBidTx(accounts[0], bid2, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx2, 1)
|
||||
s.displayExpectedBundle("bid 2", bidTx2, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
// Ensure only the second bid was executed
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
bundleHashes2 := s.bundleToTxHashes(bidTx2, bundle)
|
||||
expectedExecution := map[string]bool{
|
||||
bundleHashes[0]: false,
|
||||
bundleHashes2[0]: true,
|
||||
bundleHashes2[1]: true,
|
||||
}
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes2, expectedExecution)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Multiple transactions with increasing bids but first bid has same bundle so it should fail in later block (same account)",
|
||||
test: func() {
|
||||
// Get escrow account balance
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a single transaction
|
||||
bundle := [][]byte{
|
||||
s.createMsgSendTx(accounts[0], accounts[1].Address.String(), defaultSendAmount, 1, 1000, gasLimit, fees),
|
||||
}
|
||||
|
||||
// Create a bid transaction that includes the bundle and is valid
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[0], bid, bundle, 0, height+2, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("bid 1", bidTx, bundle)
|
||||
|
||||
// Create a second bid transaction that includes the bundle and is valid
|
||||
bid2 := reserveFee.Add(minBidIncrement)
|
||||
bidTx2 := s.createAuctionBidTx(accounts[0], bid2, bundle, 0, height+1, gasLimit, fees)
|
||||
s.broadcastTx(bidTx2, 0)
|
||||
s.displayExpectedBundle("bid 2", bidTx2, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
|
||||
// Ensure only the second bid was executed
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
bundleHashes2 := s.bundleToTxHashes(bidTx2, bundle)
|
||||
expectedExecution := map[string]bool{
|
||||
bundleHashes[0]: false,
|
||||
bundleHashes2[0]: true,
|
||||
bundleHashes2[1]: true,
|
||||
}
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes2, expectedExecution)
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid2)
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
|
||||
// Wait for a block to be created and ensure that the first bid was not executed
|
||||
s.waitForABlock()
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Multiple transactions with increasing bids but first bid has same bundle so it should fail in later block (different account)",
|
||||
test: func() {
|
||||
// Get escrow account balance
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a single transaction
|
||||
bundle := [][]byte{
|
||||
s.createMsgSendTx(accounts[0], accounts[1].Address.String(), defaultSendAmount, 0, 1000, gasLimit, fees),
|
||||
}
|
||||
|
||||
// Create a bid transaction that includes the bundle and is valid
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[2], bid, bundle, 0, height+2, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("bid 1", bidTx, bundle)
|
||||
|
||||
// Create a second bid transaction that includes the bundle and is valid
|
||||
bid2 := reserveFee.Add(minBidIncrement)
|
||||
bidTx2 := s.createAuctionBidTx(accounts[1], bid2, bundle, 0, height+1, gasLimit, fees)
|
||||
s.broadcastTx(bidTx2, 0)
|
||||
s.displayExpectedBundle("bid 2", bidTx2, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
|
||||
// Ensure only the second bid was executed
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
bundleHashes2 := s.bundleToTxHashes(bidTx2, bundle)
|
||||
expectedExecution := map[string]bool{
|
||||
bundleHashes[0]: false,
|
||||
bundleHashes2[0]: true,
|
||||
bundleHashes2[1]: true,
|
||||
}
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes2, expectedExecution)
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid2)
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
|
||||
// Wait for a block to be created and ensure that the first bid was not executed
|
||||
s.waitForABlock()
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
s.waitForNBlocks(2)
|
||||
s.verifyTopOfBlockAuction(height+4, bundleHashes, expectedExecution)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -688,21 +661,23 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
s.createMsgSendTx(accounts[1], accounts[0].Address.String(), defaultSendAmount, 0, 1000, gasLimit, fees),
|
||||
}
|
||||
|
||||
s.waitForABlock()
|
||||
|
||||
// Create a bid transaction that includes the bundle and is valid
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[2], bid, firstBundle, 0, height+1, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[2], bid, firstBundle, 0, height+2, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("bid 1", bidTx, firstBundle)
|
||||
|
||||
// Create a second bid transaction that includes the bundle and is valid
|
||||
bid2 := reserveFee.Add(minBidIncrement)
|
||||
bidTx2 := s.createAuctionBidTx(accounts[3], bid2, secondBundle, 0, height+1, gasLimit, fees)
|
||||
bidTx2 := s.createAuctionBidTx(accounts[3], bid2, secondBundle, 0, height+2, gasLimit, fees)
|
||||
s.broadcastTx(bidTx2, 0)
|
||||
s.displayExpectedBundle("bid 2", bidTx2, secondBundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
// Ensure only the second bid was executed
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, firstBundle)
|
||||
@@ -713,15 +688,15 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
bundleHashes2[0]: true,
|
||||
bundleHashes2[1]: true,
|
||||
}
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes2, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes2, expectedExecution)
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid2)
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
|
||||
// Wait for a block to be created and ensure that the second bid is executed
|
||||
// Wait for a block to be created and ensure that the second bid is not executed
|
||||
s.waitForABlock()
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+4, bundleHashes, expectedExecution)
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -742,7 +717,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
accounts := s.createTestAccounts(numAccounts, initBalance)
|
||||
|
||||
// basic send amount
|
||||
defaultSendAmount := sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(10)))
|
||||
defaultSendAmount := sdk.NewCoins(sdk.NewCoin(app.BondDenom, math.NewInt(10)))
|
||||
|
||||
// auction parameters
|
||||
params := s.queryBuilderParams()
|
||||
@@ -752,7 +727,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
|
||||
// standard tx params
|
||||
gasLimit := uint64(5000000)
|
||||
fees := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(150000)))
|
||||
fees := sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(150000)))
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
@@ -772,10 +747,12 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
// Create a bid transaction that includes the bundle
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("bad auction bid", bidTx, bundle)
|
||||
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
// Ensure that the block was built correctly and that the bid was not executed
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
expectedExecution := map[string]bool{
|
||||
@@ -783,7 +760,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
bundleHashes[1]: false,
|
||||
}
|
||||
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -794,15 +771,18 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
s.createMsgSendTx(accounts[0], accounts[1].Address.String(), defaultSendAmount, 0, 1000, gasLimit, fees),
|
||||
}
|
||||
|
||||
// Wait for a block to ensure all transactions are included in the same block
|
||||
s.waitForABlock()
|
||||
|
||||
// Create a bid transaction that includes the bundle that is attempting to bid more than their balance
|
||||
bid := sdk.NewCoin(app.BondDenom, sdk.NewInt(999999999999999999))
|
||||
bid := sdk.NewCoin(app.BondDenom, math.NewInt(999999999999999999))
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("bad auction bid", bidTx, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
expectedExecution := map[string]bool{
|
||||
@@ -811,7 +791,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
}
|
||||
|
||||
// Ensure that the block was built correctly and that the bid was not executed
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -824,15 +804,17 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
s.createMsgSendTx(accounts[2], accounts[1].Address.String(), defaultSendAmount, 0, 1000, gasLimit, fees),
|
||||
}
|
||||
|
||||
s.waitForABlock()
|
||||
|
||||
// Create a bid transaction that includes the bundle
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("front-running auction bid", bidTx, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
expectedExecution := map[string]bool{
|
||||
@@ -843,7 +825,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
}
|
||||
|
||||
// Ensure that the block was built correctly and that the bid was not executed
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -854,15 +836,17 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
s.createMsgSendTx(accounts[0], accounts[1].Address.String(), defaultSendAmount, 1000, 1000, gasLimit, fees),
|
||||
}
|
||||
|
||||
s.waitForABlock()
|
||||
|
||||
// Create a bid transaction that includes the bundle
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("invalid auction bid", bidTx, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
expectedExecution := map[string]bool{
|
||||
@@ -871,7 +855,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
}
|
||||
|
||||
// Ensure that the block was built correctly and that the bid was not executed
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -882,15 +866,17 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
s.createMsgSendTx(accounts[0], accounts[1].Address.String(), defaultSendAmount, 1, 1000, gasLimit, fees),
|
||||
}
|
||||
|
||||
s.waitForABlock()
|
||||
|
||||
// Create a bid transaction that includes a bid that is smaller than the reserve fee
|
||||
bid := reserveFee.Sub(sdk.NewInt64Coin(app.BondDenom, 1))
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[0], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[0], bid, bundle, 0, height+3, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("invalid auction bid", bidTx, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
// Ensure that no transactions were executed
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
@@ -899,7 +885,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
bundleHashes[1]: false,
|
||||
}
|
||||
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -911,15 +897,17 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
bundle = append(bundle, s.createMsgSendTx(accounts[0], accounts[1].Address.String(), defaultSendAmount, uint64(i+1), 1000, gasLimit, fees))
|
||||
}
|
||||
|
||||
s.waitForABlock()
|
||||
|
||||
// Create a bid transaction that includes the bundle
|
||||
bid := reserveFee
|
||||
height := s.queryCurrentHeight()
|
||||
bidTx := s.createAuctionBidTx(accounts[0], bid, bundle, 0, height+1, gasLimit, fees)
|
||||
bidTx := s.createAuctionBidTx(accounts[0], bid, bundle, 0, height+2, gasLimit, fees)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
s.displayExpectedBundle("invalid auction bid", bidTx, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
// Ensure that no transactions were executed
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
@@ -928,7 +916,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
for _, hash := range bundleHashes {
|
||||
expectedExecution[hash] = false
|
||||
}
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -947,7 +935,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
s.displayExpectedBundle("invalid auction bid", bidTx, bundle)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
s.waitForNBlocks(2)
|
||||
|
||||
// Ensure that no transactions were executed
|
||||
bundleHashes := s.bundleToTxHashes(bidTx, bundle)
|
||||
@@ -956,7 +944,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
bundleHashes[1]: false,
|
||||
}
|
||||
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+2, bundleHashes, expectedExecution)
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -977,14 +965,16 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
// Wait for a block to ensure all transactions are included in the same block
|
||||
s.waitForABlock()
|
||||
|
||||
// Broadcast the bid transaction
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
s.waitForABlock()
|
||||
|
||||
// Broadcast all of the transactions in the bundle
|
||||
for _, tx := range bundle {
|
||||
s.broadcastTx(tx, 0)
|
||||
}
|
||||
|
||||
// Broadcast the bid transaction
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
|
||||
@@ -998,7 +988,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
|
||||
expectedExecution[bundleHashes[0]] = false
|
||||
|
||||
s.verifyTopOfBlockAuction(height+1, bundleHashes, expectedExecution)
|
||||
s.verifyTopOfBlockAuction(height+3, bundleHashes, expectedExecution)
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1025,13 +1015,13 @@ func (s *IntegrationTestSuite) TestFreeLane() {
|
||||
numAccounts := 4
|
||||
accounts := s.createTestAccounts(numAccounts, initBalance)
|
||||
|
||||
defaultSendAmount := sdk.NewCoin(app.BondDenom, sdk.NewInt(10))
|
||||
defaultStakeAmount := sdk.NewCoin(app.BondDenom, sdk.NewInt(10))
|
||||
defaultSendAmount := sdk.NewCoin(app.BondDenom, math.NewInt(10))
|
||||
defaultStakeAmount := sdk.NewCoin(app.BondDenom, math.NewInt(10))
|
||||
defaultSendAmountCoins := sdk.NewCoins(defaultSendAmount)
|
||||
|
||||
// standard tx params
|
||||
gasLimit := uint64(5000000)
|
||||
fees := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(150000)))
|
||||
fees := sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(150000)))
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
@@ -1146,8 +1136,8 @@ func (s *IntegrationTestSuite) TestLanes() {
|
||||
numAccounts := 4
|
||||
accounts := s.createTestAccounts(numAccounts, initBalance)
|
||||
|
||||
defaultSendAmount := sdk.NewCoin(app.BondDenom, sdk.NewInt(10))
|
||||
defaultStakeAmount := sdk.NewCoin(app.BondDenom, sdk.NewInt(10))
|
||||
defaultSendAmount := sdk.NewCoin(app.BondDenom, math.NewInt(10))
|
||||
defaultStakeAmount := sdk.NewCoin(app.BondDenom, math.NewInt(10))
|
||||
defaultSendAmountCoins := sdk.NewCoins(defaultSendAmount)
|
||||
|
||||
// auction parameters
|
||||
@@ -1156,7 +1146,7 @@ func (s *IntegrationTestSuite) TestLanes() {
|
||||
|
||||
// standard tx params
|
||||
gasLimit := uint64(5000000)
|
||||
fees := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(150000)))
|
||||
fees := sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(150000)))
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
@@ -1182,11 +1172,13 @@ func (s *IntegrationTestSuite) TestLanes() {
|
||||
bidTx := s.createAuctionBidTx(accounts[2], bid, bundle, 0, height+5, gasLimit, fees)
|
||||
s.displayExpectedBundle("Valid auction bid", bidTx, bundle)
|
||||
|
||||
s.waitForABlock()
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Broadcast the transactions
|
||||
s.waitForABlock()
|
||||
s.broadcastTx(freeTx, 0)
|
||||
s.broadcastTx(normalTx, 0)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
@@ -1234,11 +1226,14 @@ func (s *IntegrationTestSuite) TestLanes() {
|
||||
bidTx := s.createAuctionBidTx(accounts[2], bid, bundle, 0, height+5, gasLimit, fees)
|
||||
s.displayExpectedBundle("Valid auction bid", bidTx, bundle)
|
||||
|
||||
s.waitForABlock()
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Broadcast the transactions
|
||||
s.waitForABlock()
|
||||
|
||||
s.broadcastTx(freeTx, 0)
|
||||
s.broadcastTx(normalTx, 0)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
@@ -1282,11 +1277,13 @@ func (s *IntegrationTestSuite) TestLanes() {
|
||||
bidTx := s.createAuctionBidTx(accounts[2], bid, bundle, 0, height+5, gasLimit, fees)
|
||||
s.displayExpectedBundle("Valid auction bid", bidTx, bundle)
|
||||
|
||||
s.waitForABlock()
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Broadcast the transactions
|
||||
s.waitForABlock()
|
||||
s.broadcastTx(freeTx, 0)
|
||||
s.broadcastTx(normalTx, 0)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
@@ -1316,7 +1313,7 @@ func (s *IntegrationTestSuite) TestLanes() {
|
||||
// basic free transaction
|
||||
validators := s.queryValidators()
|
||||
validator := validators[0]
|
||||
freeTx := s.createMsgDelegateTx(accounts[0], validator.OperatorAddress, defaultStakeAmount, 0, 1000, gasLimit, sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(0)))) // Free transaction with no fees
|
||||
freeTx := s.createMsgDelegateTx(accounts[0], validator.OperatorAddress, defaultStakeAmount, 0, 1000, gasLimit, sdk.NewCoins(sdk.NewCoin(app.BondDenom, math.NewInt(0)))) // Free transaction with no fees
|
||||
|
||||
// Create a bid transaction that includes the bundle and is invalid (out of sequence number)
|
||||
bundle := [][]byte{
|
||||
@@ -1328,10 +1325,12 @@ func (s *IntegrationTestSuite) TestLanes() {
|
||||
bidTx := s.createAuctionBidTx(accounts[1], bid, bundle, 0, height+5, gasLimit, fees)
|
||||
s.displayExpectedBundle("Valid auction bid", bidTx, bundle)
|
||||
|
||||
s.waitForABlock()
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Broadcast the transactions
|
||||
s.waitForABlock()
|
||||
s.broadcastTx(freeTx, 0)
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Wait for a block to be created
|
||||
s.waitForABlock()
|
||||
@@ -1359,10 +1358,10 @@ func (s *IntegrationTestSuite) TestLanes() {
|
||||
// basic free transaction
|
||||
validators := s.queryValidators()
|
||||
validator := validators[0]
|
||||
freeTx := s.createMsgDelegateTx(accounts[0], validator.OperatorAddress, defaultStakeAmount, 0, 1000, gasLimit, sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(0)))) // Free transaction with no fees
|
||||
freeTx := s.createMsgDelegateTx(accounts[0], validator.OperatorAddress, defaultStakeAmount, 0, 1000, gasLimit, sdk.NewCoins(sdk.NewCoin(app.BondDenom, math.NewInt(0)))) // Free transaction with no fees
|
||||
|
||||
// Another free transaction that should be included in the block
|
||||
freeTx2 := s.createMsgDelegateTx(accounts[0], validator.OperatorAddress, defaultStakeAmount, 1, 1000, gasLimit, sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(0)))) // Free transaction with no fees
|
||||
freeTx2 := s.createMsgDelegateTx(accounts[0], validator.OperatorAddress, defaultStakeAmount, 1, 1000, gasLimit, sdk.NewCoins(sdk.NewCoin(app.BondDenom, math.NewInt(0)))) // Free transaction with no fees
|
||||
|
||||
// Create a bid transaction that includes the bundle and is invalid (out of sequence number)
|
||||
bundle := [][]byte{
|
||||
@@ -1376,9 +1375,11 @@ func (s *IntegrationTestSuite) TestLanes() {
|
||||
|
||||
normalTx := s.createMsgSendTx(accounts[3], accounts[2].Address.String(), defaultSendAmountCoins, 0, 1000, gasLimit, fees)
|
||||
|
||||
// Broadcast the transactions (including the ones in the bundle)
|
||||
s.waitForABlock()
|
||||
s.broadcastTx(bidTx, 0)
|
||||
|
||||
// Broadcast the transactions (including the ones in the bundle)
|
||||
s.waitForABlock()
|
||||
s.broadcastTx(freeTx, 0)
|
||||
s.broadcastTx(bundle[1], 0)
|
||||
s.broadcastTx(freeTx2, 0)
|
||||
|
||||
+35
-23
@@ -7,8 +7,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clienttx "github.com/cosmos/cosmos-sdk/client/tx"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
@@ -49,7 +49,7 @@ func (s *IntegrationTestSuite) execMsgSendTx(valIdx int, to sdk.AccAddress, amou
|
||||
amount.String(), // amount
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.chain.validators[valIdx].keyInfo.Name),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagChainID, s.chain.id),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoin(app.BondDenom, sdk.NewInt(1000000000)).String()),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoin(app.BondDenom, math.NewInt(1000000000)).String()),
|
||||
"--keyring-backend=test",
|
||||
"--broadcast-mode=sync",
|
||||
"-y",
|
||||
@@ -127,41 +127,53 @@ func (s *IntegrationTestSuite) createTx(account TestAccount, msgs []sdk.Msg, seq
|
||||
baseAccount := s.queryAccount(account.Address)
|
||||
sequenceNumber := baseAccount.Sequence + sequenceOffset
|
||||
|
||||
// Set the messages, fees, and timeout.
|
||||
txBuilder.SetMsgs(msgs...)
|
||||
txBuilder.SetGasLimit(5000000)
|
||||
txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(150000))))
|
||||
s.Require().NoError(txBuilder.SetMsgs(msgs...))
|
||||
txBuilder.SetFeeAmount(fees)
|
||||
txBuilder.SetGasLimit(gasLimit)
|
||||
txBuilder.SetTimeoutHeight(height)
|
||||
|
||||
sigV2 := signing.SignatureV2{
|
||||
signerData := authsigning.SignerData{
|
||||
ChainID: app.ChainID,
|
||||
AccountNumber: baseAccount.AccountNumber,
|
||||
Sequence: sequenceNumber,
|
||||
PubKey: account.PrivateKey.PubKey(),
|
||||
}
|
||||
|
||||
sig := signing.SignatureV2{
|
||||
PubKey: account.PrivateKey.PubKey(),
|
||||
Data: &signing.SingleSignatureData{
|
||||
SignMode: txConfig.SignModeHandler().DefaultMode(),
|
||||
SignMode: signing.SignMode_SIGN_MODE_DIRECT,
|
||||
Signature: nil,
|
||||
},
|
||||
Sequence: sequenceNumber,
|
||||
}
|
||||
|
||||
s.Require().NoError(txBuilder.SetSignatures(sigV2))
|
||||
s.Require().NoError(txBuilder.SetSignatures(sig))
|
||||
|
||||
signerData := authsigning.SignerData{
|
||||
ChainID: s.chain.id,
|
||||
AccountNumber: baseAccount.AccountNumber,
|
||||
Sequence: sequenceNumber,
|
||||
}
|
||||
|
||||
sigV2, err := clienttx.SignWithPrivKey(
|
||||
txConfig.SignModeHandler().DefaultMode(),
|
||||
bytesToSign, err := authsigning.GetSignBytesAdapter(
|
||||
context.Background(),
|
||||
encodingConfig.TxConfig.SignModeHandler(),
|
||||
signing.SignMode_SIGN_MODE_DIRECT,
|
||||
signerData,
|
||||
txBuilder,
|
||||
account.PrivateKey,
|
||||
txConfig,
|
||||
sequenceNumber,
|
||||
txBuilder.GetTx(),
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
s.Require().NoError(txBuilder.SetSignatures(sigV2))
|
||||
|
||||
bz, err := txConfig.TxEncoder()(txBuilder.GetTx())
|
||||
sigBytes, err := account.PrivateKey.Sign(bytesToSign)
|
||||
s.Require().NoError(err)
|
||||
|
||||
sig = signing.SignatureV2{
|
||||
PubKey: account.PrivateKey.PubKey(),
|
||||
Data: &signing.SingleSignatureData{
|
||||
SignMode: signing.SignMode_SIGN_MODE_DIRECT,
|
||||
Signature: sigBytes,
|
||||
},
|
||||
Sequence: sequenceNumber,
|
||||
}
|
||||
s.Require().NoError(txBuilder.SetSignatures(sig))
|
||||
|
||||
signedTx := txBuilder.GetTx()
|
||||
bz, err := encodingConfig.TxConfig.TxEncoder()(signedTx)
|
||||
s.Require().NoError(err)
|
||||
|
||||
return bz
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
tmclient "github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
|
||||
cmtclient "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
@@ -116,6 +116,18 @@ func (s *IntegrationTestSuite) waitForABlock() {
|
||||
)
|
||||
}
|
||||
|
||||
// waitForNBlocks will wait until the current block height has increased by n blocks.
|
||||
func (s *IntegrationTestSuite) waitForNBlocks(n int) {
|
||||
height := s.queryCurrentHeight()
|
||||
s.Require().Eventually(
|
||||
func() bool {
|
||||
return s.queryCurrentHeight() >= height+uint64(n)
|
||||
},
|
||||
10*time.Second,
|
||||
50*time.Millisecond,
|
||||
)
|
||||
}
|
||||
|
||||
// bundleToTxHashes converts a bundle to a slice of transaction hashes.
|
||||
func (s *IntegrationTestSuite) bundleToTxHashes(bidTx []byte, bundle [][]byte) []string {
|
||||
hashes := make([]string, len(bundle)+1)
|
||||
@@ -163,7 +175,7 @@ func (s *IntegrationTestSuite) verifyTopOfBlockAuction(height uint64, bundle []s
|
||||
|
||||
// Check that the block contains the expected transactions in the expected order
|
||||
// iff the bid transaction was expected to execute.
|
||||
if len(bundle) > 0 && expectedExecution[bundle[0]] {
|
||||
if len(bundle) > 0 && len(expectedExecution) > 0 && expectedExecution[bundle[0]] && len(txs) > 0 {
|
||||
if expectedExecution[bundle[0]] {
|
||||
hashBz := sha256.Sum256(txs[0])
|
||||
hash := hex.EncodeToString(hashBz[:])
|
||||
@@ -259,12 +271,12 @@ func (s *IntegrationTestSuite) broadcastTx(tx []byte, valIdx int) {
|
||||
gRPCURI,
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
)
|
||||
s.Require().NoError(err)
|
||||
|
||||
client := txtypes.NewServiceClient(grpcConn)
|
||||
|
||||
req := &txtypes.BroadcastTxRequest{TxBytes: tx, Mode: txtypes.BroadcastMode_BROADCAST_MODE_SYNC}
|
||||
_, err = client.BroadcastTx(context.Background(), req)
|
||||
s.Require().NoError(err)
|
||||
client.BroadcastTx(context.Background(), req)
|
||||
}
|
||||
|
||||
// queryTx queries a transaction by its hash and returns whether there was an
|
||||
@@ -335,9 +347,9 @@ func (s *IntegrationTestSuite) queryAccount(address sdk.AccAddress) *authtypes.B
|
||||
|
||||
// queryCurrentHeight returns the current block height.
|
||||
func (s *IntegrationTestSuite) queryCurrentHeight() uint64 {
|
||||
queryClient := tmclient.NewServiceClient(s.createClientContext())
|
||||
queryClient := cmtclient.NewServiceClient(s.createClientContext())
|
||||
|
||||
req := &tmclient.GetLatestBlockRequest{}
|
||||
req := &cmtclient.GetLatestBlockRequest{}
|
||||
resp, err := queryClient.GetLatestBlock(context.Background(), req)
|
||||
s.Require().NoError(err)
|
||||
|
||||
@@ -346,13 +358,35 @@ func (s *IntegrationTestSuite) queryCurrentHeight() uint64 {
|
||||
|
||||
// queryBlockTxs returns the txs of the block at the given height.
|
||||
func (s *IntegrationTestSuite) queryBlockTxs(height uint64) [][]byte {
|
||||
queryClient := tmclient.NewServiceClient(s.createClientContext())
|
||||
queryClient := cmtclient.NewServiceClient(s.createClientContext())
|
||||
|
||||
req := &tmclient.GetBlockByHeightRequest{Height: int64(height)}
|
||||
req := &cmtclient.GetBlockByHeightRequest{Height: int64(height)}
|
||||
resp, err := queryClient.GetBlockByHeight(context.Background(), req)
|
||||
s.Require().NoError(err)
|
||||
|
||||
return resp.GetSdkBlock().Data.Txs
|
||||
txs := resp.GetSdkBlock().Data.Txs
|
||||
|
||||
// The first transaction is the vote extension.
|
||||
s.Require().Greater(len(txs), 0)
|
||||
|
||||
return txs[1:]
|
||||
}
|
||||
|
||||
// queryTx returns information about a transaction.
|
||||
func (s *IntegrationTestSuite) queryTx(txHash string) *txtypes.GetTxResponse {
|
||||
queryClient := txtypes.NewServiceClient(s.createClientContext())
|
||||
|
||||
req := &txtypes.GetTxRequest{Hash: txHash}
|
||||
resp, err := queryClient.GetTx(context.Background(), req)
|
||||
s.Require().NoError(err)
|
||||
|
||||
return resp
|
||||
}
|
||||
|
||||
// queryTxExecutionHeight returns the block height at which a transaction was executed.
|
||||
func (s *IntegrationTestSuite) queryTxExecutionHeight(txHash string) uint64 {
|
||||
txResp := s.queryTx(txHash)
|
||||
return uint64(txResp.TxResponse.Height)
|
||||
}
|
||||
|
||||
// queryValidators returns the validators of the network.
|
||||
|
||||
+36
-16
@@ -1,12 +1,14 @@
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
cometcfg "github.com/cometbft/cometbft/config"
|
||||
"github.com/cometbft/cometbft/p2p"
|
||||
"github.com/cometbft/cometbft/privval"
|
||||
@@ -18,9 +20,10 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdktx "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
txsigning "github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
genutilstypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/skip-mev/pob/tests/app"
|
||||
)
|
||||
@@ -74,7 +77,16 @@ func (v *validator) init() error {
|
||||
genDoc.Validators = nil
|
||||
genDoc.AppState = appState
|
||||
|
||||
if err = genutil.ExportGenesisFile(genDoc, config.GenesisFile()); err != nil {
|
||||
if err := genDoc.SaveAs(config.GenesisFile()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
genAppState, err := genutilstypes.AppGenesisFromFile(config.GenesisFile())
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
|
||||
}
|
||||
|
||||
if err = genutil.ExportGenesisFile(genAppState, config.GenesisFile()); err != nil {
|
||||
return fmt.Errorf("failed to export app genesis state: %w", err)
|
||||
}
|
||||
|
||||
@@ -167,15 +179,15 @@ func (v *validator) createKey(name string) error {
|
||||
func (v *validator) buildCreateValidatorMsg(amount sdk.Coin) (sdk.Msg, error) {
|
||||
description := stakingtypes.NewDescription(v.moniker, "", "", "", "")
|
||||
commissionRates := stakingtypes.CommissionRates{
|
||||
Rate: sdk.MustNewDecFromStr("0.1"),
|
||||
MaxRate: sdk.MustNewDecFromStr("0.2"),
|
||||
MaxChangeRate: sdk.MustNewDecFromStr("0.01"),
|
||||
Rate: math.LegacyMustNewDecFromStr("0.1"),
|
||||
MaxRate: math.LegacyMustNewDecFromStr("0.2"),
|
||||
MaxChangeRate: math.LegacyMustNewDecFromStr("0.01"),
|
||||
}
|
||||
|
||||
// get the initial validator min self delegation
|
||||
minSelfDelegation, _ := sdk.NewIntFromString("1")
|
||||
minSelfDelegation := math.NewInt(1)
|
||||
|
||||
valPubKey, err := cryptocodec.FromTmPubKeyInterface(v.consensusKey.PubKey)
|
||||
valPubKey, err := cryptocodec.FromCmtPubKeyInterface(v.consensusKey.PubKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -205,10 +217,16 @@ func (v *validator) signMsg(msgs ...sdk.Msg) (*sdktx.Tx, error) {
|
||||
txBuilder.SetFeeAmount(sdk.NewCoins())
|
||||
txBuilder.SetGasLimit(200_000)
|
||||
|
||||
pubKey, err := v.keyInfo.GetPubKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
signerData := authsigning.SignerData{
|
||||
ChainID: v.chain.id,
|
||||
AccountNumber: 0,
|
||||
Sequence: 0,
|
||||
PubKey: pubKey,
|
||||
}
|
||||
|
||||
// For SIGN_MODE_DIRECT, calling SetSignatures calls setSignerInfos on
|
||||
@@ -219,14 +237,14 @@ func (v *validator) signMsg(msgs ...sdk.Msg) (*sdktx.Tx, error) {
|
||||
// Note: This line is not needed for SIGN_MODE_LEGACY_AMINO, but putting it
|
||||
// also doesn't affect its generated sign bytes, so for code's simplicity
|
||||
// sake, we put it here.
|
||||
pubKey, err := v.keyInfo.GetPubKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sig := txsigning.SignatureV2{
|
||||
|
||||
sig := signing.SignatureV2{
|
||||
PubKey: pubKey,
|
||||
Data: &txsigning.SingleSignatureData{
|
||||
SignMode: txsigning.SignMode_SIGN_MODE_DIRECT,
|
||||
Data: &signing.SingleSignatureData{
|
||||
SignMode: signing.SignMode_SIGN_MODE_DIRECT,
|
||||
Signature: nil,
|
||||
},
|
||||
Sequence: 0,
|
||||
@@ -236,8 +254,10 @@ func (v *validator) signMsg(msgs ...sdk.Msg) (*sdktx.Tx, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bytesToSign, err := encodingConfig.TxConfig.SignModeHandler().GetSignBytes(
|
||||
txsigning.SignMode_SIGN_MODE_DIRECT,
|
||||
bytesToSign, err := authsigning.GetSignBytesAdapter(
|
||||
context.Background(),
|
||||
encodingConfig.TxConfig.SignModeHandler(),
|
||||
signing.SignMode_SIGN_MODE_DIRECT,
|
||||
signerData,
|
||||
txBuilder.GetTx(),
|
||||
)
|
||||
@@ -250,10 +270,10 @@ func (v *validator) signMsg(msgs ...sdk.Msg) (*sdktx.Tx, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sig = txsigning.SignatureV2{
|
||||
sig = signing.SignatureV2{
|
||||
PubKey: pubKey,
|
||||
Data: &txsigning.SingleSignatureData{
|
||||
SignMode: txsigning.SignMode_SIGN_MODE_DIRECT,
|
||||
Data: &signing.SingleSignatureData{
|
||||
SignMode: signing.SignMode_SIGN_MODE_DIRECT,
|
||||
Signature: sigBytes,
|
||||
},
|
||||
Sequence: 0,
|
||||
|
||||
Reference in New Issue
Block a user