-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
refactor: PoC for unordered txs per new spec #24010
base: release/v0.53.x
Are you sure you want to change the base?
refactor: PoC for unordered txs per new spec #24010
Conversation
GOBIN=/home/runner/work/cosmos-sdk/cosmos-sdk/build go install golang.org/x/vuln/cmd/govulncheck@latest Vulnerability #1: GO-2025-3443 Your code is affected by 1 vulnerability from 1 module. |
GOBIN=/home/runner/work/cosmos-sdk/cosmos-sdk/build go install golang.org/x/vuln/cmd/govulncheck@latest Vulnerability #1: GO-2025-3443 Your code is affected by 1 vulnerability from 1 module. |
x/auth/ante/expected_keepers.go
Outdated
@@ -19,6 +20,13 @@ type AccountKeeper interface { | |||
AddressCodec() address.Codec | |||
} | |||
|
|||
// UnorderedSequenceManager defines the contract needed for UnorderedSequence management. | |||
type UnorderedSequenceManager interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about UnorderedNonce
? It's not really a sequence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, updated to nonce
x/auth/ante/unordered.go
Outdated
const DefaultSha256GasCost = 25 | ||
const ( | ||
// MaxTimeoutDuration defines the maximum TTL a transaction can define. | ||
MaxTimeoutDuration = 10 * time.Minute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be configurable in the ante handler options with a default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, added the ability to set options on the ante. let me know if that works
x/auth/keeper/keeper.go
Outdated
|
||
// ContainsUnorderedSequence reports whether the sender has used this timestamp already. | ||
func (ak AccountKeeper) ContainsUnorderedSequence(ctx sdk.Context, sender []byte, timestamp time.Time) (bool, error) { | ||
return ak.UnorderedSequences.Has(ctx, collections.Join(uint64(timestamp.UnixNano()), sender)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to cast to uint64
, can we just use int64
as the collections type?
Also FWIW UnixNano
will cause this code to break after 2262 😜
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, switched to int64 keys
GOBIN=/home/runner/work/cosmos-sdk/cosmos-sdk/build go install golang.org/x/vuln/cmd/govulncheck@latest Vulnerability #1: GO-2025-3443 Your code is affected by 1 vulnerability from 1 module. |
GOBIN=/home/runner/work/cosmos-sdk/cosmos-sdk/build go install golang.org/x/vuln/cmd/govulncheck@latest Vulnerability #1: GO-2025-3443 Your code is affected by 1 vulnerability from 1 module. |
GOBIN=/home/runner/work/cosmos-sdk/cosmos-sdk/build go install golang.org/x/vuln/cmd/govulncheck@latest Vulnerability #1: GO-2025-3443 Your code is affected by 1 vulnerability from 1 module. |
@@ -536,6 +532,7 @@ func NewSimApp( | |||
// NOTE: upgrade module is required to be prioritized | |||
app.ModuleManager.SetOrderPreBlockers( | |||
upgradetypes.ModuleName, | |||
authtypes.ModuleName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to make sure we have this added in the upgrade guide for adding utx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opened #24078
x/auth/keeper/keeper.go
Outdated
// ------------------------------------- | ||
|
||
// ContainsUnorderedNonce reports whether the sender has used this timestamp already. | ||
func (ak AccountKeeper) ContainsUnorderedNonce(ctx sdk.Context, sender []byte, timestamp time.Time) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to me it is more clear if the timestamp
is called timeout
because thats what they always are right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in comments, renames, gas
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as resolved.
This comment was marked as resolved.
1 similar comment
This comment was marked as spam.
This comment was marked as spam.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving - I left one small comment and looks like we just have a formatting lint
…hub.com/cosmos/cosmos-sdk into technicallyty/23976/unordered-tx-refactor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API looks good but left one comment. I did not get a chance to thoroughly review the tests yet. I'd like to do that before ACKing but otherwise ACK
x/auth/ante/expected_keepers.go
Outdated
type UnorderedNonceManager interface { | ||
RemoveExpiredUnorderedNonces(ctx sdk.Context) error | ||
AddUnorderedNonce(ctx sdk.Context, sender []byte, timestamp time.Time) error | ||
ContainsUnorderedNonce(ctx sdk.Context, sender []byte, timestamp time.Time) (bool, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably feasible to collapse this into a single TryAdd method - that's a bit safer, but this is okay. TryAdd is safer because Add should actually fail if the entry exists and we want to avoid calling Has twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made adjustment here: TryAdd
makes the ante code simpler 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also check that if a sequence is provided by any signer and unordered is also true, then this is an error. What do you think?
reset := func() { | ||
mockStoreKey := storetypes.NewKVStoreKey("test") | ||
storeService := runtime.NewKVStoreService(mockStoreKey) | ||
ctx = testutil.DefaultContextWithDB(t, mockStoreKey, storetypes.NewTransientStoreKey("transient_test")).Ctx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why TransientStoreKey? It should be a regular one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the 2nd key is intended to be a transient key. this is the function signature:
DefaultContextWithDB(tb testing.TB, key, tkey storetypes.StoreKey)
hmm.. this sounds sane, but this would require some careful consideration of where sequences are set/signed and changing this based on the unordered in txbody. if we really want to do this, should probably be another PR |
Separate PR is fine, but conceptually does it make sense that if someone sets a sequence plus unordered that should be interpreted as user error? Basically unclear intent |
Description
Closes: #23976
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...