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(proto): create v2 execution API #1962

Merged
merged 12 commits into from
Feb 26, 2025
803 changes: 803 additions & 0 deletions crates/astria-core/src/generated/astria.execution.v2.rs

Large diffs are not rendered by default.

1,220 changes: 1,220 additions & 0 deletions crates/astria-core/src/generated/astria.execution.v2.serde.rs

Large diffs are not rendered by default.

9 changes: 9 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.

18 changes: 18 additions & 0 deletions proto/executionapis/astria/execution/v2/block.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = 'proto3';

package astria.execution.v2;

import "google/protobuf/timestamp.proto";

// The set of information which deterministic driver of block production
// must know about a given rollup Block
message Block {
// The block number
uint64 number = 1;
// The hash of the block
bytes hash = 2;
// The hash from the parent block
bytes parent_hash = 3;
// Timestamp on the block, standardized to google protobuf standard.
google.protobuf.Timestamp timestamp = 4;
}
11 changes: 11 additions & 0 deletions proto/executionapis/astria/execution/v2/block_identifier.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = 'proto3';

package astria.execution.v2;

// Fields which are indexed for finding blocks on a blockchain.
message BlockIdentifier {
oneof identifier {
uint64 number = 1;
bytes hash = 2;
}
}
23 changes: 23 additions & 0 deletions proto/executionapis/astria/execution/v2/commitment_state.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
syntax = 'proto3';

package astria.execution.v2;

import "astria/execution/v2/block.proto";

// The CommitmentState holds the block at each stage of sequencer commitment
// level
//
// A Valid CommitmentState:
// - Block numbers are such that soft >= firm.
// - No blocks ever decrease in block number.
// - The chain defined by soft is the head of the canonical chain the firm block
// must belong to.
message CommitmentState {
// Soft commitment is the rollup block matching latest sequencer block.
Block soft = 1;
// Firm commitment is achieved when data has been seen in DA.
Block firm = 2;
// The lowest block number of celestia chain to be searched for rollup blocks
Copy link
Member

Choose a reason for hiding this comment

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

This field is confusing. How should this work in practice?

Is this intended to interact with the celestia block variance that we have define in the execution config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This field is the first height that Conductor begins fetching Celestia data at. I think we could clarify this, but additionally, it seems a bit pointless to include in CommitmentState I think? It should stay the same for an entire execution session, so I think maybe we should move it there

Copy link
Contributor

Choose a reason for hiding this comment

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

it doesn't stay the same. it's part of the commitment state because afaik, conductor updates it when updating the commitment state. If it did not then if the rollup restarted, conductor would have to start searching from the initial base celestia height. If the rollup has been running for awhile, this could be months of data it doesn't need to look through

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see, you're right. Perhaps base_celestia_height is a bit of a misnomer then? Perhaps something like current_celestia_height, latest_celestia_height, or just celestia_height?

Copy link
Member

Choose a reason for hiding this comment

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

We could at best do something like firm_found_at_celestia_height.

It's important to remember that we don't even have a guarantee that if the sequencer height S gets included at Celestia height C, that then S+1 gets included at C' >= C.

We have this guarantee right now in practice due to how we run the relayer, but for distributed relayer designs we might end up with another scenario (delays, latencies, network issues with resubmission attempts).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like latest_celestia_height could reflect that it represents the latest height that a firm block has been found at, but maybe it's too confusing. I personally think firm_found_at_celestia_height sounds a bit more confusing, perhaps we just leave as is and update the description

Copy link
Contributor

Choose a reason for hiding this comment

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

I think if firm_found_at_celestia_height means the firm in this commitment state was found at this celestia height, then the meaning is pretty clear. base, current, latest, etc are all a bit more vague.

Copy link
Contributor

Choose a reason for hiding this comment

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

but in that case I think celestia_height carries the same meaning and is more concise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to celestia_height in 0c2992d and added a more detailed description of how this is updated and why.

// given current state
uint64 base_celestia_height = 3;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = 'proto3';

package astria.execution.v2;

import "astria/sequencerblock/v1/block.proto";
import "google/protobuf/timestamp.proto";

// ExecuteBlockRequest contains all the information needed to create a new rollup
// block.
//
// This information comes from previous rollup blocks, as well as from sequencer
// blocks.
message ExecuteBlockRequest {
// The session within which the block is intended to be executed.
string session_id = 1;
// The hash of previous block, which new block will be created on top of.
bytes prev_block_hash = 2;
// List of transactions to include in the new block.
repeated astria.sequencerblock.v1.RollupData transactions = 3;
// Timestamp to be used for new block.
google.protobuf.Timestamp timestamp = 4;
}
39 changes: 39 additions & 0 deletions proto/executionapis/astria/execution/v2/execution_config.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
syntax = 'proto3';

package astria.execution.v2;

import "astria/primitive/v1/types.proto";

// ExecutionConfig contains the information needed to map sequencer block height
// to rollup block number for driving execution.
//
// This information is used to determine which sequencer & celestia data to
// use from the Astria & Celestia networks, as well as define shutdown/restart
// behavior of the Conductor.
message ExecutionConfig {
// The rollup_id is the unique identifier for the rollup chain.
astria.primitive.v1.RollupId rollup_id = 1;
// The first rollup block number to be executed. This is mapped to `sequencer_first_block_height`.
// The minimum first block number is 1, since 0 represents the genesis block.
uint64 rollup_first_block_number = 2;
// The final rollup block number to execute before either re-fetching sequencer
// info (restarting) or shutting down (determined by `halt_at_rollup_stop_number`).
// If 0, no stop block will be set.
uint64 rollup_stop_block_number = 3;
// The ID of the Astria Sequencer network to retrieve Sequencer blocks from.
// Conductor implementations should verify that the Sequencer network they are
// connected to have this chain ID (if fetching soft Sequencer blocks), and verify
// that the Sequencer metadata blobs retrieved from Celestia contain this chain
// ID (if extracting firm Sequencer blocks from Celestia blobs).
string sequencer_chain_id = 4;
// The first block height on the sequencer chain to use for rollup transactions.
// This is mapped to `rollup_first_block_number`.
uint64 sequencer_first_block_height = 5;
// The ID of the Celestia network to retrieve blobs from.
// Conductor implementations should verify that the Celestia network they are
// connected to have this chain ID (if extracting firm Sequencer blocks from
// Celestia blobs).
string celestia_chain_id = 6;
// The allowed variance in celestia for sequencer blocks to have been posted.
uint64 celestia_block_variance = 7;
Copy link
Member

Choose a reason for hiding this comment

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

@joroshiba I think we should define a fixed variance here and not perform a calculation inside conductor. Right now it's 6x this value, but I don't see a reason to not just set it here without extra conductor shenanigans.

}
33 changes: 33 additions & 0 deletions proto/executionapis/astria/execution/v2/execution_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
syntax = 'proto3';

package astria.execution.v2;

import "astria/execution/v2/block.proto";
import "astria/execution/v2/commitment_state.proto";
import "astria/execution/v2/execute_block_request.proto";
import "astria/execution/v2/execution_session.proto";
import "astria/execution/v2/get_block_request.proto";
import "astria/execution/v2/new_execution_session_request.proto";
import "astria/execution/v2/update_commitment_state_request.proto";

// ExecutionService is used to drive deterministic production of blocks.
//
// The service can be implemented by any blockchain which wants to utilize the
// Astria Shared Sequencer, and will have block production driven via the Astria
// "Conductor".
service ExecutionService {
// GetSequencerInfo returns the necessary information for mapping sequencer block
// height to rollup block number.
rpc NewExecutionSession(NewExecutionSessionRequest) returns (ExecutionSession);

// GetBlock will return a block given an identifier.
rpc GetBlock(GetBlockRequest) returns (Block);

// ExecuteBlock is called to deterministically derive a rollup block from
// filtered sequencer block information.
rpc ExecuteBlock(ExecuteBlockRequest) returns (Block);

// UpdateCommitmentState replaces the whole CommitmentState with a new
// CommitmentState.
rpc UpdateCommitmentState(UpdateCommitmentStateRequest) returns (CommitmentState);
}
22 changes: 22 additions & 0 deletions proto/executionapis/astria/execution/v2/execution_session.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = 'proto3';

package astria.execution.v2;

import "astria/execution/v2/commitment_state.proto";
import "astria/execution/v2/execution_config.proto";

// ExecutionSession contains the information needed to drive the full execution
// of a rollup chain in the rollup.
//
// The execution session is only valid for the execution config params with
// which it was created. Once all blocks within the session have been executed,
// the execution client must request a new session. The session_id is used to
// to track which session is being used.
message ExecutionSession {
// A UUID for the session.
string session_id = 1;
// The commitment state for executing client to start from.
CommitmentState commitment_state = 2;
// The configuration for the execution session.
ExecutionConfig execution_config = 3;
}
10 changes: 10 additions & 0 deletions proto/executionapis/astria/execution/v2/get_block_request.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
syntax = 'proto3';

package astria.execution.v2;

import "astria/execution/v2/block_identifier.proto";

// Used in GetBlock to find a single block.
message GetBlockRequest {
BlockIdentifier identifier = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
syntax = 'proto3';

package astria.execution.v2;

// There is only one CommitmentState object, so the request is empty.
message GetCommitmentStateRequest {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = 'proto3';

package astria.execution.v2;

// NewExecutionSessionRequest is used to create a new execution session on the
// rollup.
message NewExecutionSessionRequest {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = 'proto3';

package astria.execution.v2;

import "astria/execution/v2/commitment_state.proto";

// The CommitmentState to set, must include complete state.
message UpdateCommitmentStateRequest {
// The session which the commitment state is being updated within.
string session_id = 1;
// The new commitment state to set.
CommitmentState commitment_state = 2;
}
Loading