Skip to content

Commit

Permalink
feat(proto): add bundle and optimistic block apis (#1519)
Browse files Browse the repository at this point in the history
## Summary
This adds the protobuf definitions for optimistic block stream and the
bundle stream.

## Background
The Auctioneer will auction off a bundle slot which will be placed at
the top of the rollup block deterministically during execution. The APIs
in this PR are used to drive the bundle auction (detailed in [this
document](https://www.notion.so/astria-org/20240919-Status-Update-1066bd31a90c80b68bb2ea9b898645d0)).
At a high level:

The Auctioneer receives blocks optimistically from the sequencer in
order to maximize the auction duration.

While the auction is running, the Auctioneer receives orders from the
rollup node that have been validated against the optimistic block.

After a block is committed, the Auctioneer will submit the highest
paying bundle for inclusion by the sequencer.

### Optimistic Block Stream
1. The Sequencer will stream blocks to the Auctioneer optimistically,
i.e. before they are finalized (ProcessProposal).
2. The Sequencer will also stream block commitments to the Auctioneer,
which mark blocks as final thanks to CometBFT's single slot finality.

### Bundle Stream
1. The Auctioneer will stream optimistic blocks to the rollup node for
execution. The rollup will execute the block and return the resulting
header info.
2. The rollup node will stream bundles (indexed by parent block hash) to
the Auctioneer.

## Changes
- Add the bundle service to the composer apis
- Add the optimistic block service to the sequencer block apis

## Breaking Changelist
- Bulleted list of breaking changes, any notes on migration. Delete
section if none.

## Related Issues
closes #1553
  • Loading branch information
itamarreif authored Oct 2, 2024
1 parent ac68b01 commit b54ccb9
Show file tree
Hide file tree
Showing 8 changed files with 2,505 additions and 0 deletions.
762 changes: 762 additions & 0 deletions crates/astria-core/src/generated/astria.bundle.v1alpha1.rs

Large diffs are not rendered by default.

651 changes: 651 additions & 0 deletions crates/astria-core/src/generated/astria.bundle.v1alpha1.serde.rs

Large diffs are not rendered by default.

506 changes: 506 additions & 0 deletions crates/astria-core/src/generated/astria.sequencerblock.v1alpha1.rs

Large diffs are not rendered by default.

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions crates/astria-core/src/generated/mod.rs

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

36 changes: 36 additions & 0 deletions proto/executionapis/astria/bundle/v1alpha1/bundle.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
syntax = "proto3";

package astria.bundle.v1alpha1;

message GetBundleStreamRequest {}

// Information for the bundle submitter to know how to submit the bundle.
// The fee and base_sequencer_block_hash are not necessarily strictly necessary
// it allows for the case where the server doesn't always send the highest fee
// bundles after the previous but could just stream any confirmed bundles.
message Bundle {
// The fee that can be expected to be received for submitting this bundle.
// This allows the bundle producer to stream any confirmed bundles they would be ok
// with submitting. Used to avoid race conditions in received bundle packets. Could
// also be used by a bundle submitter to allow multiple entities to submit bundles.
uint64 fee = 1;
// The byte list of transactions to be included.
repeated bytes transactions = 2;
// The base_sequencer_block_hash is the hash from the base block this bundle
// is based on. This is used to verify that the bundle is based on the correct
// Sequencer block.
bytes base_sequencer_block_hash = 3;
// The hash of previous rollup block, on top of which the bundle will be executed as ToB.
bytes prev_rollup_block_hash = 4;
}

message GetBundleStreamResponse {
Bundle bundle = 1;
}

service BundleService {
// A bundle submitter requests bundles given a new optimistic Sequencer block,
// and receives a stream of potential bundles for submission, until either a timeout
// or the connection is closed by the client.
rpc GetBundleStream(GetBundleStreamRequest) returns (stream GetBundleStreamResponse);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
syntax = "proto3";

package astria.bundle.v1alpha1;

import "astria/execution/v1alpha2/execution.proto";
import "astria/sequencerblock/v1alpha1/block.proto";
import "google/protobuf/timestamp.proto";

// The "BaseBlock" is the information needed to simulate bundles on top of
// a Sequencer block which may not have been committed yet.
message BaseBlock {
// This is the block hash for the proposed block.
bytes sequencer_block_hash = 1;
// List of transactions to include in the new block.
repeated astria.sequencerblock.v1alpha1.RollupData transactions = 2;
// Timestamp to be used for new block.
google.protobuf.Timestamp timestamp = 3;
}

message ExecuteOptimisticBlockStreamRequest {
BaseBlock base_block = 1;
}

message ExecuteOptimisticBlockStreamResponse {
// Metadata identifying the block resulting from executing a block. Includes number, hash,
// parent hash and timestamp.
astria.execution.v1alpha2.Block block = 1;
// The base_sequencer_block_hash is the hash from the base sequencer block this block
// is based on. This is used to associate an optimistic execution result with the hash
// received once a sequencer block is committed.
bytes base_sequencer_block_hash = 2;
}

service OptimisticExecutionService {
// Stream blocks from the Auctioneer to Geth for optimistic execution. Geth will stream back
// metadata from the executed blocks.
rpc ExecuteOptimisticBlockStream(stream ExecuteOptimisticBlockStreamRequest) returns (stream ExecuteOptimisticBlockStreamResponse);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
syntax = "proto3";

package astria.sequencerblock.v1alpha1;

import "astria/primitive/v1/types.proto";
import "astria/sequencerblock/v1alpha1/block.proto";

message GetBlockCommitmentStreamRequest {}

// Identifying metadata for blocks that have been successfully committed in the Sequencer.
message SequencerBlockCommit {
// Height of the sequencer block that was committed.
uint64 height = 1;
// Hash of the sequencer block that was committed.
bytes block_hash = 2;
}

message GetBlockCommitmentStreamResponse {
SequencerBlockCommit commitment = 1;
}

message GetOptimisticBlockStreamRequest {
// The rollup id for which the Sequencer block is being streamed.
astria.primitive.v1.RollupId rollup_id = 1;
}

message GetOptimisticBlockStreamResponse {
// The optimistic Sequencer block that is being streamed, filtered for the provided rollup id.
astria.sequencerblock.v1alpha1.FilteredSequencerBlock block = 1;
}

// The Sequencer will serve this to the aucitoneer
service OptimisticBlockService {
// The Sequencer will stream the optimistic Sequencer block (filtered for the provided
// rollup id) to the Auctioneer.
rpc GetOptimisticBlockStream(GetOptimisticBlockStreamRequest) returns (stream GetOptimisticBlockStreamResponse);
// The Sequencer will stream the block commits to the Auctioneer.
rpc GetBlockCommitmentStream(GetBlockCommitmentStreamRequest) returns (stream GetBlockCommitmentStreamResponse);
}

0 comments on commit b54ccb9

Please sign in to comment.