-
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
[Feature]: Non-sequential x/auth
sequence numbers
#20617
Comments
@BrendanChou Have you seen ADR-070 on unordered transactions? |
Yes it looks pretty good except for the good-til-block semantics which don't solve the issue of having to query chain state (to get the current block number) before sending a transaction. I like the simplicity of the solution proposed above, but would be fine to use ADR-070 if it used good-til-time instead of good-til-block. |
we can look into time instead of height. we would like to move into a direction in which auth is deprecated and accounts is the way forward. this would allow you to write your own accounts with custom replay protection. |
Strong support for the problem description. I had to write a big funds distribution system with different distibutor accounts in order to implement a faucet just to be able to use it at higher frequency than once per ~ 2 blocks. I would stay away from using the term "nonce" as long as we don't support arbitrary unique values, which can be decreasing. Those values can come from an RNG and are used in various cryprtographic algorithms. I doubt we want to store all noces an account ever used. |
in the design proposed how is ordering of transactions kept? is this pushed to the client level, broadcast and wait for the inclusion? we are moving unordered tx to use time instead of blocks this should help fix the issue you conveyed. It will also make it simpler for users. |
completed with unordered txs |
Summary
Allow for non-sequential
x/auth
sequence numbers. That is, allow sequence numbers to skip values.Problem Definition
The main issue right now is that sending transactions is a stateful endeavor where you have to query the chain for your current sequence number, and this number may not even end up being correct if you have other transactions in-flight. This is annoying for developers to implement in the client, adds a round-trip time to the node for any transaction sending, and requires clients to attempt to remember how many transactions are in-flight.
There have been other issues (#8308, #13621) over the years pointing out the poor UX around this feature.
This would also make writing tests much easier. Other devs have asked things such as "does anyone have nice code snippet of an object to broadcast txs and update account sequence? Use case: send many transactions in tests".
Proposed Feature
Standard practice can be using the current unix time (in milliseconds) as the sequence number which is a stateless way to go about things (does not require querying the chain or keeping track of in-flight messages, assuming it takes at least 1 millisecond between signing new transactions).
The
x/auth/Params
can have three new fields:bool allow_sequence_skips
true
, allow sequence numbers to be skippedfalse
uint64 num_stored_sequences
1
uint64 sequence_buffer_milliseconds
ctx.BlockTime().UnixMilli() + sequence_buffer_ms
are considered invalid86,400,000
(1 day in milliseconds)Additionally, the
uint64 sequence
field on theBaseAccount
would be replaced with arepeated uint64 highest_sequences
field that is at-mostnum_stored_sequences
in length.Another solution is to avoid overloading the current
sequence
field and instead addrepeated uint64 nonces
field toBaseAccount
. Anytx.sequence
values greater-than2^40
will be assumed to be nonces. This allows dapps to use either traditional sequence numbers or the newer skippable nonce values without interfering with each other.The text was updated successfully, but these errors were encountered: