Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(tx)!: make timeout_height time based #20870

Merged
merged 51 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
8d367e6
add timestamp field
sontrinh16 Jul 1, 2024
6de6ec3
add time based field for tx body
sontrinh16 Jul 4, 2024
cce6b54
update snapshotter
sontrinh16 Jul 4, 2024
6a1fe37
minor
sontrinh16 Jul 4, 2024
6b142ec
minor
sontrinh16 Jul 4, 2024
6e2aa27
fix test
sontrinh16 Jul 4, 2024
ae1ca05
fix tests
sontrinh16 Jul 5, 2024
59248f5
lint
sontrinh16 Jul 5, 2024
ce2c7d2
fix tests
sontrinh16 Jul 5, 2024
559e0be
fix more test
sontrinh16 Jul 5, 2024
a178e9a
add tests
sontrinh16 Jul 8, 2024
02d63dc
remove unnecessary code
sontrinh16 Jul 8, 2024
efcb0b9
fix tests
sontrinh16 Jul 8, 2024
ca0b587
lint
sontrinh16 Jul 8, 2024
4810fd1
add more test
sontrinh16 Jul 9, 2024
e17ddc8
lint
sontrinh16 Jul 9, 2024
975c968
Merge branch 'main' into son/timeout_height_time_based
sontrinh16 Jul 9, 2024
2f69f6f
remove testing print
sontrinh16 Jul 9, 2024
f978027
unordered tx use time based timeout
sontrinh16 Jul 9, 2024
1013006
minor
sontrinh16 Jul 9, 2024
c1ba08e
Merge branch 'son/timeout_height_time_based' of https://github.com/co…
sontrinh16 Jul 9, 2024
680082e
fix tests
sontrinh16 Jul 9, 2024
4c00978
lint
sontrinh16 Jul 9, 2024
96507c5
add changelog
sontrinh16 Jul 9, 2024
d6d2a40
Merge branch 'main' into son/timeout_height_time_based
sontrinh16 Jul 10, 2024
b439a8a
Update x/auth/tx/gogotx.go
sontrinh16 Jul 10, 2024
b5b3031
Merge branch 'main' into son/timeout_height_time_based
sontrinh16 Jul 11, 2024
424724b
Update UPGRADING.md
sontrinh16 Jul 15, 2024
70f772d
address comments
sontrinh16 Jul 16, 2024
b3a89f5
resolve conflicts
sontrinh16 Jul 16, 2024
3724d9d
resolve conflicts
sontrinh16 Jul 16, 2024
0fe0792
fix test
sontrinh16 Jul 16, 2024
c74e08f
fix tests
sontrinh16 Jul 16, 2024
6edb58e
use eventually
sontrinh16 Jul 16, 2024
7b2d554
update ADR
sontrinh16 Jul 16, 2024
234d250
Merge branch 'main' into son/timeout_height_time_based
sontrinh16 Jul 17, 2024
4297c62
Merge branch 'main' into son/timeout_height_time_based
sontrinh16 Jul 22, 2024
db37bfa
address comment
sontrinh16 Jul 22, 2024
1657027
address comments
sontrinh16 Jul 22, 2024
55f24fb
Merge branch 'son/timeout_height_time_based' of https://github.com/co…
sontrinh16 Jul 22, 2024
9ac9527
minor
sontrinh16 Jul 22, 2024
e5b2a8e
remove timeout_height flag in CLI
sontrinh16 Jul 23, 2024
4323483
fix tests
sontrinh16 Jul 23, 2024
0272673
Update client/flags/flags.go
sontrinh16 Jul 23, 2024
a85d969
fix tests
sontrinh16 Jul 24, 2024
f6c0df5
fix test
sontrinh16 Jul 24, 2024
bc94df3
Merge branch 'main' into son/timeout_height_time_based
sontrinh16 Jul 25, 2024
2074128
update changelog
sontrinh16 Jul 29, 2024
48c0c5f
Merge branch 'main' into son/timeout_height_time_based
sontrinh16 Jul 29, 2024
4c6c03f
lint
sontrinh16 Jul 29, 2024
ff273d1
Merge branch 'son/timeout_height_time_based' of https://github.com/co…
sontrinh16 Jul 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ transactions in your application:
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(),
// ...
ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxUnOrderedTTL, app.UnorderedTxManager),
ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxUnOrderedTTL, unorderedtx.DefaultmaxTimeoutDuration, app.UnorderedTxManager),
sontrinh16 marked this conversation as resolved.
Show resolved Hide resolved
// ...
}

Expand Down
6 changes: 5 additions & 1 deletion api/cosmos/staking/v1beta1/query.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

455 changes: 279 additions & 176 deletions api/cosmos/tx/v1beta1/tx.pulsar.go

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1597,19 +1597,29 @@ func TestABCI_PrepareProposal_ReachedMaxBytes(t *testing.T) {
})
require.NoError(t, err)

expectedTxs := 8
var expectedTxBytes int64

for i := 0; i < 100; i++ {
tx2 := newTxCounter(t, suite.txConfig, int64(i), int64(i))
err := pool.Insert(sdk.Context{}, tx2)
require.NoError(t, err)

txBz, err := suite.txConfig.TxEncoder()(tx2)
require.NoError(t, err)
txDataSize := int(cmttypes.ComputeProtoSizeForTxs([]cmttypes.Tx{txBz}))
if i < expectedTxs {
expectedTxBytes += int64(txDataSize)
}
}

reqPrepareProposal := abci.PrepareProposalRequest{
MaxTxBytes: 1500,
MaxTxBytes: expectedTxBytes,
Height: 1,
}
resPrepareProposal, err := suite.baseApp.PrepareProposal(&reqPrepareProposal)
require.NoError(t, err)
require.Equal(t, 8, len(resPrepareProposal.Txs))
require.Equal(t, expectedTxs, len(resPrepareProposal.Txs))
}

func TestABCI_PrepareProposal_BadEncoding(t *testing.T) {
Expand Down
34 changes: 17 additions & 17 deletions baseapp/abci_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,10 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection()
tx := builder.GetTx()
txBz, err := txConfig.TxEncoder()(tx)
s.Require().NoError(err)
s.Require().Len(txBz, 152)
s.Require().Len(txBz, 165)

txDataSize := int(cmttypes.ComputeProtoSizeForTxs([]cmttypes.Tx{txBz}))
s.Require().Equal(txDataSize, 155)
s.Require().Equal(txDataSize, 168)

testCases := map[string]struct {
ctx sdk.Context
Expand Down Expand Up @@ -532,15 +532,15 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection()
Txs: [][]byte{txBz, txBz, txBz, txBz, txBz},
MaxTxBytes: 465,
},
expectedTxs: 3,
expectedTxs: 2,
},
"large max tx bytes len calculation": {
ctx: s.ctx,
req: &abci.PrepareProposalRequest{
Txs: [][]byte{txBz, txBz, txBz, txBz, txBz},
MaxTxBytes: 456,
MaxTxBytes: 504,
},
expectedTxs: 2,
expectedTxs: 3,
},
"max gas and tx bytes": {
ctx: s.ctx.WithConsensusParams(cmtproto.ConsensusParams{
Expand Down Expand Up @@ -619,15 +619,15 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSe
testTxs[i].size = int(cmttypes.ComputeProtoSizeForTxs([]cmttypes.Tx{bz}))
}

s.Require().Equal(180, testTxs[0].size)
s.Require().Equal(190, testTxs[1].size)
s.Require().Equal(181, testTxs[2].size)
s.Require().Equal(181, testTxs[3].size)
s.Require().Equal(263, testTxs[4].size)
s.Require().Equal(273, testTxs[5].size)
s.Require().Equal(264, testTxs[6].size)
s.Require().Equal(264, testTxs[7].size)
s.Require().Equal(264, testTxs[8].size)
s.Require().Equal(193, testTxs[0].size)
s.Require().Equal(203, testTxs[1].size)
s.Require().Equal(194, testTxs[2].size)
s.Require().Equal(194, testTxs[3].size)
s.Require().Equal(276, testTxs[4].size)
s.Require().Equal(286, testTxs[5].size)
s.Require().Equal(277, testTxs[6].size)
s.Require().Equal(277, testTxs[7].size)
s.Require().Equal(277, testTxs[8].size)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR but these types of tests are fragile and hard to maintain.


testCases := map[string]struct {
ctx sdk.Context
Expand All @@ -640,15 +640,15 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSe
ctx: s.ctx,
txInputs: []testTx{testTxs[0], testTxs[1], testTxs[2], testTxs[3]},
req: &abci.PrepareProposalRequest{
MaxTxBytes: 180 + 181,
MaxTxBytes: 193 + 194,
},
expectedTxs: []int{0, 3},
},
"skip multi-signers msg non-sequential sequence": {
ctx: s.ctx,
txInputs: []testTx{testTxs[4], testTxs[5], testTxs[6], testTxs[7], testTxs[8]},
req: &abci.PrepareProposalRequest{
MaxTxBytes: 263 + 264,
MaxTxBytes: 276 + 277,
},
expectedTxs: []int{4, 8},
},
Expand All @@ -657,7 +657,7 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSe
ctx: s.ctx,
txInputs: []testTx{testTxs[9], testTxs[10], testTxs[11]},
req: &abci.PrepareProposalRequest{
MaxTxBytes: 263 + 264,
MaxTxBytes: 276 + 277,
},
expectedTxs: []int{9},
},
Expand Down
2 changes: 2 additions & 0 deletions client/flags/flags.go
Copy link
Member

@julienrbrt julienrbrt Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, mark timeout height and timeout timestamp mutually exclusive: cmd.MarkFlagsMutuallyExclusive(flag1, flag2)

EDIT: should the height flag even stay??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need it for ordered tx ? if not then we can remove the height flag all together

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id remove height flag and just go with time. Its slightly breaking but b etter to push people to the better design

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also remove timeout_height in txbody or keep it for now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't remove anything from tx body. We can't do that type of breakage in production proto types. We also should still support it in the state machine even if we remove from CLI

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the timeout_height flag

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we do need to flag this as CLI breaking

Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const (
FlagOffset = "offset"
FlagCountTotal = "count-total"
FlagTimeoutHeight = "timeout-height"
FlagTimeoutTimestamp = "timeout-timestamp"
FlagUnordered = "unordered"
FlagKeyAlgorithm = "algo"
FlagKeyType = "key-type"
Expand Down Expand Up @@ -137,6 +138,7 @@ func AddTxFlagsToCmd(cmd *cobra.Command) {
f.BoolP(FlagSkipConfirmation, "y", false, "Skip tx broadcasting prompt confirmation")
f.String(FlagSignMode, "", "Choose sign mode (direct|amino-json|direct-aux|textual), this is an advanced feature")
f.Uint64(FlagTimeoutHeight, 0, "Set a block timeout height to prevent the tx from being committed past a certain height")
f.Int64(FlagTimeoutTimestamp, 0, "Set a block timeout timestamp to prevent the tx from being committed past a certain time")
sontrinh16 marked this conversation as resolved.
Show resolved Hide resolved
f.Bool(FlagUnordered, false, "Enable unordered transaction delivery; must be used in conjunction with --timeout-height")
f.String(FlagFeePayer, "", "Fee payer pays fees for the transaction instead of deducting from the signer")
f.String(FlagFeeGranter, "", "Fee granter grants fees for the transaction")
Expand Down
17 changes: 14 additions & 3 deletions client/tx/aux_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package tx

import (
"context"
"time"

"github.com/cosmos/gogoproto/proto"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/timestamppb"

txv1beta1 "cosmossdk.io/api/cosmos/tx/v1beta1"
txsigning "cosmossdk.io/x/tx/signing"
Expand Down Expand Up @@ -58,6 +60,14 @@ func (b *AuxTxBuilder) SetTimeoutHeight(height uint64) {
b.auxSignerData.SignDoc.BodyBytes = nil
}

// SetTimeoutTimestamp sets a timeout timestamp in the tx.
func (b *AuxTxBuilder) SetTimeoutTimestamp(timestamp time.Time) {
b.checkEmptyFields()

b.body.TimeoutTimestamp = timestamppb.New(timestamp)
b.auxSignerData.SignDoc.BodyBytes = nil
}

// SetMsgs sets an array of Msgs in the tx.
func (b *AuxTxBuilder) SetMsgs(msgs ...sdk.Msg) error {
anys := make([]*anypb.Any, len(msgs))
Expand Down Expand Up @@ -209,9 +219,10 @@ func (b *AuxTxBuilder) GetSignBytes() ([]byte, error) {
})

auxBody := &txv1beta1.TxBody{
Messages: body.Messages,
Memo: body.Memo,
TimeoutHeight: body.TimeoutHeight,
Messages: body.Messages,
Memo: body.Memo,
TimeoutHeight: body.TimeoutHeight,
TimeoutTimestamp: body.TimeoutTimestamp,
// AuxTxBuilder has no concern with extension options, so we set them to nil.
// This preserves pre-PR#16025 behavior where extension options were ignored, this code path:
// https://github.com/cosmos/cosmos-sdk/blob/ac3c209326a26b46f65a6cc6f5b5ebf6beb79b38/client/tx/aux_builder.go#L193
Expand Down
15 changes: 15 additions & 0 deletions client/tx/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math/big"
"os"
"strings"
"time"

"github.com/cosmos/go-bip39"
"github.com/spf13/pflag"
Expand Down Expand Up @@ -33,6 +34,7 @@ type Factory struct {
sequence uint64
gas uint64
timeoutHeight uint64
timeoutTimestamp time.Time
gasAdjustment float64
chainID string
fromName string
Expand Down Expand Up @@ -87,6 +89,8 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) (Factory, e
gasAdj := clientCtx.Viper.GetFloat64(flags.FlagGasAdjustment)
memo := clientCtx.Viper.GetString(flags.FlagNote)
timeoutHeight := clientCtx.Viper.GetUint64(flags.FlagTimeoutHeight)
timestampUnix := clientCtx.Viper.GetInt64(flags.FlagTimeoutTimestamp)
timeoutTimestamp := time.Unix(timestampUnix, 0)
unordered := clientCtx.Viper.GetBool(flags.FlagUnordered)

gasStr := clientCtx.Viper.GetString(flags.FlagGas)
Expand All @@ -105,6 +109,7 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) (Factory, e
accountNumber: accNum,
sequence: accSeq,
timeoutHeight: timeoutHeight,
timeoutTimestamp: timeoutTimestamp,
unordered: unordered,
gasAdjustment: gasAdj,
memo: memo,
Expand Down Expand Up @@ -135,6 +140,7 @@ func (f Factory) Fees() sdk.Coins { return f.fees }
func (f Factory) GasPrices() sdk.DecCoins { return f.gasPrices }
func (f Factory) AccountRetriever() client.AccountRetriever { return f.accountRetriever }
func (f Factory) TimeoutHeight() uint64 { return f.timeoutHeight }
func (f Factory) TimeoutTimestamp() time.Time { return f.timeoutTimestamp }
func (f Factory) Unordered() bool { return f.unordered }
func (f Factory) FromName() string { return f.fromName }

Expand Down Expand Up @@ -249,6 +255,12 @@ func (f Factory) WithTimeoutHeight(height uint64) Factory {
return f
}

// WithTimeoutTimestamp returns a copy of the Factory with an updated timeout timestamp.
func (f Factory) WithTimeoutTimestamp(timestamp time.Time) Factory {
f.timeoutTimestamp = timestamp
return f
}

// WithUnordered returns a copy of the Factory with an updated unordered field.
func (f Factory) WithUnordered(v bool) Factory {
f.unordered = v
Expand Down Expand Up @@ -361,6 +373,7 @@ func (f Factory) BuildUnsignedTx(msgs ...sdk.Msg) (client.TxBuilder, error) {
tx.SetFeeGranter(f.feeGranter)
tx.SetFeePayer(f.feePayer)
tx.SetTimeoutHeight(f.TimeoutHeight())
tx.SetTimeoutTimestamp(f.TimeoutTimestamp())

if etx, ok := tx.(client.ExtendedTxBuilder); ok {
etx.SetExtensionOptions(f.extOptions...)
Expand Down Expand Up @@ -400,6 +413,8 @@ func (f Factory) PrintUnsignedTx(clientCtx client.Context, msgs ...sdk.Msg) erro
return err
}

fmt.Println(unsignedTx)
sontrinh16 marked this conversation as resolved.
Show resolved Hide resolved

encoder := f.txConfig.TxJSONEncoder()
if encoder == nil {
return errors.New("cannot print unsigned tx: tx json encoder is nil")
Expand Down
3 changes: 3 additions & 0 deletions client/tx_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package client

import (
"time"

"cosmossdk.io/x/auth/signing"
txsigning "cosmossdk.io/x/tx/signing"

Expand Down Expand Up @@ -48,6 +50,7 @@ type (
SetFeePayer(feePayer sdk.AccAddress)
SetGasLimit(limit uint64)
SetTimeoutHeight(height uint64)
SetTimeoutTimestamp(timestamp time.Time)
SetUnordered(v bool)
SetFeeGranter(feeGranter sdk.AccAddress)
AddAuxSignerData(tx.AuxSignerData) error
Expand Down
1 change: 1 addition & 0 deletions client/v2/autocli/testdata/help-echo-msg.golden
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Flags:
-s, --sequence uint The sequence number of the signing account (offline mode only)
--sign-mode string Choose sign mode (direct|amino-json|direct-aux|textual), this is an advanced feature
--timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height
--timeout-timestamp int Set a block timeout timestamp to prevent the tx from being committed past a certain time
--tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator
--unordered Enable unordered transaction delivery; must be used in conjunction with --timeout-height
-y, --yes Skip tx broadcasting prompt confirmation
2 changes: 1 addition & 1 deletion client/v2/autocli/testdata/msg-output.golden
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk","to_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk","amount":[{"denom":"foo","amount":"1"}]}]},"auth_info":{"fee":{"gas_limit":"200000"}}}
{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk","to_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk","amount":[{"denom":"foo","amount":"1"}]}],"timeout_timestamp":"1970-01-01T00:00:00Z"},"auth_info":{"fee":{"gas_limit":"200000"}}}
1 change: 1 addition & 0 deletions client/v2/offchain/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (b *builder) GetSigningTxData() (txsigning.TxData, error) {
Messages: msgs,
Memo: body.Memo,
TimeoutHeight: body.TimeoutHeight,
TimeoutTimestamp: body.TimeoutTimestamp,
ExtensionOptions: extOptions,
NonCriticalExtensionOptions: nonCriticalExtOptions,
}
Expand Down
13 changes: 11 additions & 2 deletions proto/cosmos/tx/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "cosmos/crypto/multisig/v1beta1/multisig.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/tx/signing/v1beta1/signing.proto";
import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/cosmos/cosmos-sdk/types/tx";

Expand Down Expand Up @@ -122,11 +123,19 @@ message TxBody {
// incremented, which allows for fire-and-forget as well as concurrent
// transaction execution.
//
// Note, when set to true, the existing 'timeout_height' value must be set and
// will be used to correspond to a height in which the transaction is deemed
// Note, when set to true, the existing 'timeout_height' or 'timeout_timestamp' value must
// be set and will be used to correspond to a height/time_stamp in which the transaction is deemed
// valid.
bool unordered = 4;

// timeout_timestamp is the block time after which this transaction will not
// be processed by the chain.
//
// Note, if unordered=true this value MUST be set
// and will act as a short-lived TTL in which the transaction is deemed valid
// and kept in memory to prevent duplicates.
google.protobuf.Timestamp timeout_timestamp = 5 [(gogoproto.nullable) = true, (gogoproto.stdtime) = true];

// extension_options are arbitrary options that can be added by chains
// when the default options are not sufficient. If any of these are present
// and can't be handled, the transaction will be rejected
Expand Down
2 changes: 1 addition & 1 deletion simapp/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(options.Environment),
ante.NewTxTimeoutHeightDecorator(options.Environment),
ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxUnOrderedTTL, options.TxManager, options.Environment),
ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxUnOrderedHeight, unorderedtx.DefaultmaxTimeoutDuration, options.TxManager, options.Environment),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
require.Equal(t, []byte("ok"), okValue)
}
// check block gas is always consumed
baseGas := uint64(38012) // baseGas is the gas consumed before tx msg
baseGas := uint64(38142) // baseGas is the gas consumed before tx msg
sontrinh16 marked this conversation as resolved.
Show resolved Hide resolved
expGasConsumed := addUint64Saturating(tc.gasToConsume, baseGas)
if expGasConsumed > uint64(simtestutil.DefaultConsensusParams.Block.MaxGas) {
// capped by gasLimit
Expand Down
7 changes: 7 additions & 0 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ func (c Context) WithBlockHeight(height int64) Context {
return c.WithBlockHeader(newHeader)
}

// WithBlockTime returns a Context with an updated block time.
func (c Context) WithBlockTime(time time.Time) Context {
newHeader := c.BlockHeader()
newHeader.Time = time
sontrinh16 marked this conversation as resolved.
Show resolved Hide resolved
return c.WithBlockHeader(newHeader)
}

// WithChainID returns a Context with an updated chain identifier.
func (c Context) WithChainID(chainID string) Context {
c.chainID = chainID
Expand Down
4 changes: 4 additions & 0 deletions types/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,8 @@ var (

// ErrPanic should only be set when we recovering from a panic
ErrPanic = errorsmod.ErrPanic

// ErrTxTimeout defines an error for when a tx is rejected out due to an
// explicitly set timeout timestamp.
ErrTxTimeout = errorsmod.Register(RootCodespace, 42, "tx timeout")
Comment on lines +145 to +148
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add documentation for ErrTxTimeout.

The new error constant ErrTxTimeout is added correctly. However, it lacks documentation. Ensure it follows the existing pattern of documenting errors.

// ErrTxTimeout defines an error for when a tx is rejected due to an
// explicitly set timeout timestamp.
ErrTxTimeout = errorsmod.Register(RootCodespace, 42, "tx timeout")

)
Loading
Loading