Closed gupadhyaya closed 5 hours ago
The changes involve updates to the go.mod
file for new dependencies, modifications to the sequencing.proto
file to enhance service definitions, and significant alterations to the method signatures and internal logic in various Go files, including client.go
, server.go
, and sequencing.go
. The updates introduce structured request and response types across the sequencer interface, improving encapsulation and clarity. Additionally, a new method for hashing batches has been added, and unit tests have been introduced to validate the functionality of the updated sequencer.
Files | Change Summary |
---|---|
go.mod |
Added new dependencies: github.com/stretchr/testify , github.com/davecgh/go-spew , github.com/pmezard/go-difflib , and gopkg.in/yaml.v3 . |
proto/sequencing/sequencing.proto |
Updated service definitions: added max_bytes to GetNextBatchRequest and rollup_id to both request messages. |
proxy/grpc/client.go , proxy/grpc/server.go , sequencing.go , test/dummy.go |
Updated method signatures to use structured request and response types, enhancing encapsulation. |
serialization.go |
Introduced a Hash method in the Batch struct for generating a SHA-256 hash of serialized data. |
test/dummy_test.go |
Added unit tests for transaction queue and dummy sequencer operations, covering various scenarios. |
Objective | Addressed | Explanation |
---|---|---|
maxBytes parameter in GetNextBatch (Issue #6) | ✅ |
🐰 In the meadow, where changes bloom,
New fields added, dispelling gloom.
With structured requests, our code takes flight,
A hash for batches, all feels just right!
In tests we trust, our logic is clear,
Hopping along, we have nothing to fear!
🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
@gupadhyaya what do you think about keeping primitive or close aliases in the go interface, e.g.:
// SequencerInput provides a method for submitting a transaction from rollup to sequencer
type SequencerInput interface {
// SubmitRollupTransaction submits a transaction from rollup to sequencer
// RollupId is the unique identifier for the rollup chain
// Tx is the transaction to submit
// returns an error if any from the sequencer
SubmitRollupTransaction(ctx context.Context, 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
// RollupId is the unique identifier for the rollup chain
// LastBatchHash is the cryptographic hash of the last batch received by the rollup
// MaxBytes is the maximum number of bytes to return in the batch
// returns the next batch of transactions and an error if any from the sequencer
GetNextBatch(ctx context.Context, rollupId RollupId, lastBatchHash Hash, maxBytes uint64) (*Batch, time.Time, 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
// RollupId is the unique identifier for the rollup chain
// BatchHash is the cryptographic hash of the batch to verify
// returns a boolean indicating if the batch is valid and an error if any from the sequencer
VerifyBatch(ctx context.Context, rollupId RollupId, batchHash Hash) (bool, error)
}
then the grpc implementations can cast to their appropriate Request, Response
types. This allows the go interface to remain cleaner and not be dependent on protobuf types.
@gupadhyaya what do you think about keeping primitive or close aliases in the go interface, e.g.:
// SequencerInput provides a method for submitting a transaction from rollup to sequencer type SequencerInput interface { // SubmitRollupTransaction submits a transaction from rollup to sequencer // RollupId is the unique identifier for the rollup chain // Tx is the transaction to submit // returns an error if any from the sequencer SubmitRollupTransaction(ctx context.Context, 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 // RollupId is the unique identifier for the rollup chain // LastBatchHash is the cryptographic hash of the last batch received by the rollup // MaxBytes is the maximum number of bytes to return in the batch // returns the next batch of transactions and an error if any from the sequencer GetNextBatch(ctx context.Context, rollupId RollupId, lastBatchHash Hash, maxBytes uint64) (*Batch, time.Time, 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 // RollupId is the unique identifier for the rollup chain // BatchHash is the cryptographic hash of the batch to verify // returns a boolean indicating if the batch is valid and an error if any from the sequencer VerifyBatch(ctx context.Context, rollupId RollupId, batchHash Hash) (bool, error) }
then the grpc implementations can cast to their appropriate
Request, Response
types. This allows the go interface to remain cleaner and not be dependent on protobuf types.
totally agree. its currently not dependent on the protobuf types. instead just wrapped types within the sequencer interface instead of primitive types. see: https://github.com/rollkit/go-sequencing/blob/max_bytes/sequencing.go#L58, these wrapper types are not protobuf types. these wrapper types will help manage future updates to params and returns better. what do you think?
:tada: This PR is included in version 0.2.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:
Fixes #6 #10 #11
Summary by CodeRabbit
New Features
Batch
struct.Bug Fixes
Tests