OffchainLabs / decentralized-timeboost-spec

6 stars 0 forks source link

Decentralized time boost sequencer

Goals:

Assumptions:

Submitting transactions

Submitters are encouraged to send their transactions to every member of the committee, to ensure the earliest inclusion in the chain. Any transaction received by at least F+1 honest committee members is guaranteed to be included eventually. (For purposes of this guarantee, “included” means that at some point in the chain’s canonical history, the transaction is either included in the chain or correctly rejected as invalid.)

Transactions can optionally be encrypted as a protection against front-running by malicious committee members.

Many users are expected to rely on intermediaries to encrypt their transactions and multicast them to the committee. Users’ legacy wallets would likely submit transactions via such an intermediary.

Members may discard any received transaction that is clearly invalid and cannot become valid within the next minute. They may also discard any received transaction after one minute if that transaction has not progressed in the protocol.

Background: threshold decryption

The protocol relies on a CCA-secure threshold encryption scheme that is not specified here. Transactions and bundles can be submitted in encrypted form, and these will be decrypted jointly by the members after their position in the sequencer’s output can no longer be manipulated.

Each member of the sequencer committee holds a key share, and F+1 decryption shares are needed to decrypt an encrypted item.

Background: timeboost

Within each one-minute priority epoch, there is a single priority controller address which is announced by an external protocol that is specified elsewhere. Each priority epoch starts at a predetermined time that is known to everyone, so given a timestamp anyone can compute which priority epoch it belongs to.

The address of the next epoch’s priority controller will be announced at least 15 seconds before the epoch begins, by a valid transaction to a special precompile. Members must always know the address of the current priority controller.

The priority controller can submit priority bundles which will be given favorable treatment in the sequencing. (Some bundles may be singletons containing only one transaction.) The time advantage of priority bundles is intended to guarantee that the priority controller can win any races to capture arbitrage value.

A priority bundle is submitted by wrapping the bundle into a transaction sent to a special reserved address called PriorityAddr. Transactions sent to PriorityAddr are consumed by sequencer committee members, and are never included directly in the chain. To process a transaction to PriorityAddr, a sequencer committee member does the following:

Transactions submitted to addresses other than PriorityAddr are called non-priority transactions and have the normal transaction semantics.

Configuration and key management

The protocol uses two sets of keys: signing keys and threshold decryption keys. Signing keys are used to authenticate messages from members, and to sign quorum certificates. Threshold decryption keys are used for the threshold decryption functionality as described below.

The authoritative source of information about keys is the key management contract, a smart contract on the parent chain. Users of the protocol, and the committee members themselves, rely on the key management contract for information about currently valid keys and any scheduled key changes.

Actions that change the state of the key management contract may be done only by chain governance or by the key manager address, an address which can be changed only by chain governance.

Implementation notes:

Managing signing keys

The protocol uses a signature scheme that supports threshold aggregation of signatures, so that Q signature shares are sufficient to produce a quorum signature.

These keys and this signature scheme are used in the core consensus protocol to authenticate messages. They are also used to produce quorum certificates on the blocks produced by the protocol.

The key management contract keeps track of the current keyset, along with a future keyset with a starting timestamp for when that future keyset will become active. (The future keyset and its starting timestamp may be null, if no keyset change has been scheduled.)

A signature keyset consists of:

Chain governance or the key manager address can:

Design note: A new signature keyset takes effect at a scheduled timestamp. This has two consequences:

Managing threshold decryption keys

The protocol uses a CCA-secure threshold decryption scheme. For this scheme, a "keyset" consists of:

Chain governance or the key manager address can:

At any given time, multiple keysets may be valid. Every ciphertext for threshold decryption is prepended with the 8-byte keyset ID of the keyset used to encrypt it.

Overview of the sequencing protocol

The protocol operates in rounds, which are not the same as priority epochs. There is no fixed ratio or synchronization between rounds and priority epochs.

Each round operates in three phases, and results in pushing a sequence of transactions into a queue which will be consumed by the block-building engine.

The block-building engine consumes the queue of transactions produced by the ordering phases of all rounds, and produces the final sequence of blocks by executing the transactions, filtering out invalid ones, and packing them into blocks. This process is deterministic, so all honest members can do it separately in parallel, and they are guaranteed to get the same result. At the end they sign the resulting blocks, and these signatures can be aggregated into quorum certificates on the blocks.

The inclusion phase operates on its own cadence, starting the next consensus round without waiting for the other phases to finish processing the previous round’s transaction list. The decryption and ordering phases can be pipelined, subject to the timing constraints described below. The block-building engine executes independently, consuming the transactions enqueued by the ordering phases of rounds.

Inclusion phase

The inclusion phase is specified in a separate document.

Decryption phase

Some or all of the transactions and bundles in the consensus inclusion list may be encrypted. The decryption phase will decrypt them. This phase consumes the results of the inclusion phase, which will be the same for all honest members, and all honest members will produce the same output for this phase.

The decryption phases of multiple rounds can be done concurrently.

If any of the transactions or bundles in the inclusion list are encrypted, the committee member multicasts its decryption shares for the encrypted items. It then awaits the arrival of decryption shares from other committee members. As soon as it has received F+1 decryption shares for an encrypted item (including its own share), it can use those shares to decrypt the item.

(Note that decryption of a non-priority transaction could lead to duplicate copies of the same transaction, because the result of decryption could be identical to a transaction that is already present. This cannot happen for priority bundles, nor for delayed inbox messages, because they have sequence numbers that have already been de-duplicated.)

As soon as the member has decrypted all of the encrypted items in the inclusion list (or immediately, if there were no encrypted items), it first de-duplicates the set of non-priority transactions by removing all but one instance of any transaction that is duplicated in the set, and then the member passes the de-duplicated inclusion list, tagged with the round number, to the next, ordering phase.

Ordering phase

Each honest committee member runs a separate instance of the ordering phase. This phase is deterministic, and consumes inputs that will be the same for all honest members, so it will produce the same sequence of outputs for every honest member.

The ordering phase consumes the inclusion lists produced by the decryption phase, and produces an ordered sequence of timestamped transactions, which are pushed into a queue that will be consumed by the block building engine.

The inclusion lists from multiple rounds can be processed concurrently, however the results must be emitted from the ordering phase in round order.

An honest member sorts the transactions and bundles in the inclusion list as follows:

At this point, the ordering phase waits until the ordering phases of all previous rounds have completed, and then:

This completes the ordering phase for the round.

Block building engine

Each honest committee member runs an instance of the block building engine.

The job of the block building engine is to consume timestamped transactions from its input queue and use them to build blocks. This uses the same block-building logic already included in “back end” of the current Arbitrum sequencer, which executes the transactions, filters out transactions that are invalid or unfunded, and packs the transactions into blocks.

This would use the ProduceBlockAdvanced function in the Nitro code, or something similar. However, this operation must be deterministic, which probably requires updates to the existing code, for example to use the timestamps on transactions rather than reading the current clock.

This phase may optionally (but for either all members or no members) include a nonce reordering cache, which remembers transactions that would generate nonce-too-large errors, in the hope that the missing nonce will arrive soon, allowing the erroring transaction to be re-sequenced successfully. (This corrects for out-of-order arrival of transactions.) The cache operates as follows:

All honest members will see the same sequence of transactions in their local input queue, and this phase is deterministic, so honest members can do this phase independently and asynchronously, and they are guaranteed to produce the same sequence of blocks.

Honest members sign the hashes of the blocks they produce, and multicast their signature shares. F+1 signature shares can be aggregated to make a quorum certificate for the block. (This is sufficient because at least one of the signers is honest, and therefore an honest member must have signed the blocks that result from correct processing of the unique result of the inclusion round.)