Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on May 2, 2025. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 2
feat: extend api to include rollup id, add Hash function to Batch, add maxBytes#13
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
50fe9a6
extend api to include rollup id, add Hash function to Batch, add maxB…
gupadhyaya 245e653
minor fixes
gupadhyaya 79a6630
fix issues
gupadhyaya 67ff8ae
fix test and comments
gupadhyaya 6f55326
concurrency safe
gupadhyaya 22349c4
fix verify batch
gupadhyaya b7c2c51
remove rollup id storage
gupadhyaya 86e7a61
Merge branch 'main' into max_bytes
gupadhyaya fef5601
minor fixes to test
gupadhyaya a98e57c
fix GetNextBatch for max bytes and add additional tests
gupadhyaya b30eec5
reintroduce rollupId, but as a config in the constructor
gupadhyaya ad1c339
minor
gupadhyaya 2923ec8
fix
gupadhyaya a13a943
minor fixes to submit tx in client
gupadhyaya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,7 +2,6 @@ package grpc | ||
| import ( | ||
| "context" | ||
| "time" | ||
| "google.golang.org/grpc" | ||
| @@ -46,34 +45,39 @@ func (c *Client) Stop() error { | ||
| } | ||
| // SubmitRollupTransaction submits a transaction from rollup to sequencer. | ||
| func (c *Client) SubmitRollupTransaction(ctx context.Context, rollupId []byte, tx []byte) error { | ||
| func (c *Client) SubmitRollupTransaction(ctx context.Context, req sequencing.SubmitRollupTransactionRequest) (*sequencing.SubmitRollupTransactionResponse, error) { | ||
| _, err := c.SequencerInputClient.SubmitRollupTransaction(ctx, &pbseq.SubmitRollupTransactionRequest{ | ||
| RollupId: rollupId, | ||
| Data: tx, | ||
| RollupId: req.RollupId, | ||
| Data: req.Tx, | ||
| }) | ||
| return err | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &sequencing.SubmitRollupTransactionResponse{}, nil | ||
| } | ||
| // GetNextBatch returns the next batch of transactions from sequencer to rollup. | ||
| func (c *Client) GetNextBatch(ctx context.Context, lastBatchHash []byte) (*sequencing.Batch, time.Time, error) { | ||
| resp, err := c.SequencerOutputClient.GetNextBatch(ctx, &pbseq.GetNextBatchRequest{LastBatchHash: lastBatchHash[:]}) | ||
| func (c *Client) GetNextBatch(ctx context.Context, req sequencing.GetNextBatchRequest) (*sequencing.GetNextBatchResponse, error) { | ||
| resp, err := c.SequencerOutputClient.GetNextBatch(ctx, &pbseq.GetNextBatchRequest{RollupId: req.RollupId, LastBatchHash: req.LastBatchHash}) | ||
| if err != nil { | ||
| return nil, time.Now(), err | ||
| return nil, err | ||
| } | ||
| b := &sequencing.Batch{} | ||
| b.FromProto(resp.Batch) | ||
| t, err := types.TimestampFromProto(resp.Timestamp) | ||
| if err != nil { | ||
| return nil, time.Now(), err | ||
| return nil, err | ||
| } | ||
| return b, t, nil | ||
| return &sequencing.GetNextBatchResponse{Batch: b, Timestamp: t}, nil | ||
| } | ||
| // VerifyBatch verifies a batch of transactions received from the sequencer. | ||
| func (c *Client) VerifyBatch(ctx context.Context, batchHash []byte) (bool, error) { | ||
| resp, err := c.BatchVerifierClient.VerifyBatch(ctx, &pbseq.VerifyBatchRequest{BatchHash: batchHash[:]}) | ||
| func (c *Client) VerifyBatch(ctx context.Context, req sequencing.VerifyBatchRequest) (*sequencing.VerifyBatchResponse, error) { | ||
| resp, err := c.BatchVerifierClient.VerifyBatch(ctx, &pbseq.VerifyBatchRequest{RollupId: req.RollupId, BatchHash: req.BatchHash}) | ||
| if err != nil { | ||
| return false, err | ||
| return nil, err | ||
| } | ||
| return resp.Status, nil | ||
| return &sequencing.VerifyBatchResponse{Status: resp.Status}, nil | ||
gupadhyaya marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| var _ sequencing.Sequencer = &Client{} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -15,21 +15,29 @@ type Sequencer interface { | ||
| // SequencerInput provides a method for submitting a transaction from rollup to sequencer | ||
| type SequencerInput interface { | ||
| // SubmitRollupTransaction submits a transaction from rollup to sequencer | ||
| SubmitRollupTransaction(ctx context.Context, rollupId RollupId, tx Tx) error | ||
| // 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, req SubmitRollupTransactionRequest) (*SubmitRollupTransactionResponse, error) | ||
gupadhyaya marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| // 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 | ||
| // 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, lastBatchHash Hash) (*Batch, time.Time, error) | ||
| GetNextBatch(ctx context.Context, req GetNextBatchRequest) (*GetNextBatchResponse, error) | ||
gupadhyaya marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| // 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(ctx context.Context, batchHash Hash) (bool, error) | ||
| // 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, req VerifyBatchRequest) (*VerifyBatchResponse, error) | ||
gupadhyaya marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| // RollupId is a unique identifier for a rollup chain | ||
| @@ -45,3 +53,37 @@ type Hash = []byte | ||
| type Batch struct { | ||
| Transactions []Tx | ||
| } | ||
| // SubmitRollupTransactionRequest is a request to submit a transaction from rollup to sequencer | ||
| type SubmitRollupTransactionRequest struct { | ||
| RollupId RollupId | ||
| Tx Tx | ||
| } | ||
| // SubmitRollupTransactionResponse is a response to submitting a transaction from rollup to sequencer | ||
| type SubmitRollupTransactionResponse struct { | ||
MSevey marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
gupadhyaya marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // GetNextBatchRequest is a request to get the next batch of transactions from sequencer to rollup | ||
| type GetNextBatchRequest struct { | ||
| RollupId RollupId | ||
| LastBatchHash Hash | ||
| MaxBytes uint64 | ||
| } | ||
| // GetNextBatchResponse is a response to getting the next batch of transactions from sequencer to rollup | ||
| type GetNextBatchResponse struct { | ||
| Batch *Batch | ||
| Timestamp time.Time | ||
| } | ||
| // VerifyBatchRequest is a request to verify a batch of transactions received from the sequencer | ||
| type VerifyBatchRequest struct { | ||
| RollupId RollupId | ||
| BatchHash Hash | ||
| } | ||
| // VerifyBatchResponse is a response to verifying a batch of transactions received from the sequencer | ||
| type VerifyBatchResponse struct { | ||
| Status bool | ||
| } | ||
gupadhyaya marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.