Skip to content

Commit

Permalink
add initial interface definitions and generator code
Browse files Browse the repository at this point in the history
  • Loading branch information
gupadhyaya committed Jul 17, 2024
1 parent d120328 commit 63ea304
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# go-sequencing

go-sequencing defines a generic sequencing interface for modular blockchains

## Sequencing Interface

## Implementations
10 changes: 10 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v1beta1

# The plugins to run.
plugins:
# The name of the plugin.
- name: gogofaster
# The the relative output directory.
out: types/pb
# Any options to provide to the plugin.
opt: plugins=grpc,paths=source_relative

Check failure on line 10 in buf.gen.yaml

View workflow job for this annotation

GitHub Actions / lint / yamllint

10:44 [new-line-at-end-of-file] no new line character at the end of file
27 changes: 27 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: v1beta1

build:
roots:
- proto
- third_party/proto
lint:
use:
- DEFAULT
- COMMENTS
- FILE_LOWER_SNAKE_CASE
except:
- COMMENT_ENUM
- COMMENT_ENUM_VALUE
- COMMENT_MESSAGE
- COMMENT_RPC
- COMMENT_SERVICE
- COMMENT_FIELD
- PACKAGE_VERSION_SUFFIX
- RPC_REQUEST_STANDARD_NAME
- SERVICE_SUFFIX
- UNARY_RPC
ignore:
- tendermint
breaking:
use:
- FILE

Check failure on line 27 in buf.yaml

View workflow job for this annotation

GitHub Actions / lint / yamllint

27:11 [new-line-at-end-of-file] no new line character at the end of file
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/rollkit/template-da-repo
module github.com/rollkit/go-sequencing

go 1.21.0
10 changes: 10 additions & 0 deletions proto/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

# see: https://stackoverflow.com/a/246128
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"/..
TARGET_DIR=./types/pb

cd $SCRIPT_DIR
mkdir -p $TARGET_DIR
rm -rf $TARGET_DIR/*
docker run -u $UID:$(id -g) -e XDG_CACHE_HOME=/tmp/.cache -v $PWD:/workspace --workdir /workspace tendermintdev/docker-build-proto sh ./proto/protoc.sh
5 changes: 5 additions & 0 deletions proto/protoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -eo pipefail

buf generate --path="./proto/sequencing" --template="buf.gen.yaml" --config="buf.yaml"
47 changes: 47 additions & 0 deletions proto/sequencing/sequencing.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
syntax = "proto3";
package rollkit;

// SequencerInput ...
service SequencerInput {
// SubmitRollupTransaction ...
rpc SubmitRollupTransaction(SubmitRollupTransactionRequest) returns (SubmitRollupTransactionResponse) {}
}

// SubmitRollupTransactionRequest ...
message SubmitRollupTransactionRequest {
// the unhashed rollup id
bytes rollup_id = 1;
// the raw data bytes of the rollup transaction
bytes data = 2;
}

// SubmitRollupTransactionResponse ...
message SubmitRollupTransactionResponse {
}

// SequencerOutput ...
service SequencerOutput {
// SubmitRollupTransaction ...
rpc GetNextBatch(BatchRequest) returns (BatchResponse) {}
}

// BatchRequest provides the last batch while requesting for the next batch
message BatchRequest {
repeated bytes transactions = 1;
}

// BatchResponse contains the transaction batch that is last sequenced
message BatchResponse {
repeated bytes transactions = 1;
}

// BatchVerifier
service BatchVerifier {
// VerifyBatch ...
rpc VerifyBatch(BatchRequest) returns VerificationResponse {}
}

// VerificationResponse
message VerificationResponse {
bool success = 1;
}
27 changes: 27 additions & 0 deletions sequencing.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package sequencing

// SequencerInput provides a method for submitting a transaction from rollup to sequencer
type SequencerInput interface {
// SubmitRollupTransaction submits a transaction from rollup to sequencer
SubmitRollupTransaction(rollupId RollupId, tx Tx) error
}

// SequencerOutput provides a method for getting the next batch of transactions from sequencer to rollup
type SequencerOutput interface {
// GetNextBatch returns the next batch of transactions from sequencer to rollup
// lastBatch is the last batch of transactions received from the sequencer
// returns the next batch of transactions and an error if any from the sequencer
GetNextBatch(lastBatch []Tx) ([]Tx, error)
}

// BatchVerifier provides a method for verifying a batch of transactions received from the sequencer
type BatchVerifier interface {
// VerifyBatch verifies a batch of transactions received from the sequencer
VerifyBatch(batch []Tx) (bool, error)
}

// RollupId is a unique identifier for a rollup chain
type RollupId = []byte

// Tx is a rollup transaction
type Tx = []byte

0 comments on commit 63ea304

Please sign in to comment.