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: initial implementation #3

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat: initial implementation #3

wants to merge 3 commits into from

Conversation

tzdybal
Copy link
Member

@tzdybal tzdybal commented Aug 9, 2024

Overview

Resolves #4
Resolves #5

Summary by CodeRabbit

  • New Features

    • Introduced a copyright notice for "Astria Sequencer" to clarify ownership and intellectual property rights.
    • Added a new module for the Astria Sequencer, specifying dependencies and Go version for improved project management.
    • Implemented a foundational Sequencer interface for the Astria sequencing network, enabling transaction submissions and preparing for future batch processing.
  • Bug Fixes

    • Addressed error handling in the transaction submission process to enhance reliability.

@tzdybal tzdybal self-assigned this Aug 9, 2024
Copy link

coderabbitai bot commented Aug 9, 2024

Walkthrough

The changes introduce a new Go module for the Astria Sequencer, including a copyright notice, a go.mod file with dependencies, and the implementation of a Sequencer type in sequencer.go. This type provides foundational methods for transaction handling within the Astria ecosystem, including the ability to submit rollup transactions and prepare for batch processing.

Changes

Files Change Summary
NOTICE Introduced copyright notice for "Astria Sequencer" by Strange Loop Labs AG, effective 2024.
go.mod Created new module with dependencies listed and Go version set to 1.22.5.
sequencer.go Implemented Sequencer type with methods for transaction submission and placeholders for batch handling.

Assessment against linked issues

Objective Addressed Explanation
Create go module with dependencies (#4)
Create empty implementation of Sequencer (#4)

Poem

🐰 In the meadow where code does play,
A sequencer hops in a brand new way.
With transactions to send and batches to find,
Our software grows clever, swift, and kind.
A copyright shield, so bright and bold,
Protects our treasure, a story told! 🌼


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tzdybal tzdybal changed the title Initial drafts of implementation feat: initial implementation Aug 9, 2024
@tzdybal tzdybal marked this pull request as ready for review August 30, 2024 12:18
@RollkitBot RollkitBot requested review from a team, yarikbratashchuk, gupadhyaya and Manav-Aggarwal and removed request for a team August 30, 2024 12:18
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d64244f and 27807a2.

Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
Files selected for processing (3)
  • NOTICE (1 hunks)
  • go.mod (1 hunks)
  • sequencer.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • NOTICE
Additional comments not posted (3)
sequencer.go (2)

1-12: Review of package and imports:

The package name astria_sequencer and the imports are appropriate for the functionality being implemented. The use of specific imports like astriaproto and txproto indicates a well-structured approach to handling specific protocol buffer models, which is crucial for the sequencer's functionality.

The structure and imports are approved.


22-38: Review of New constructor:

The constructor function New is well-implemented with proper error handling and initialization of the Sequencer type. The use of Go's error wrapping in lines 26 and 31 enhances the error information, aiding in debugging and maintenance.

The constructor implementation is approved.

go.mod (1)

1-64: Review of Go module and dependencies:

The go.mod file is well-structured with a clear definition of the module path and required dependencies. The specified Go version, 1.22.5, is appropriate for the current standards. The dependencies are well-documented with specific versions, ensuring reproducible builds and compatibility.

The Go module configuration and dependencies are approved.

Comment on lines +66 to +78
// 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
func (s *Sequencer) GetNextBatch(ctx context.Context, lastBatch *sequencing.Batch) (*sequencing.Batch, error) {
//TODO implement me
panic("implement me")
}

// VerifyBatch verifies a batch of transactions received from the sequencer
func (s *Sequencer) VerifyBatch(ctx context.Context, batch *sequencing.Batch) (bool, error) {
//TODO implement me
panic("implement me")
}
Copy link

Choose a reason for hiding this comment

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

Implement stub methods:

Both GetNextBatch and VerifyBatch methods are currently implemented as stubs with panic("implement me"). These methods are essential for the sequencer's operation and need to be fully implemented to handle batch transactions effectively.

Would you like me to help with the implementation or open a GitHub issue to track this task?

Comment on lines +40 to +64
// SubmitRollupTransaction submits a transaction from rollup to sequencer
func (s *Sequencer) SubmitRollupTransaction(ctx context.Context, rollupId sequencing.RollupId, tx sequencing.Tx) error {
unsignedTx := &txproto.UnsignedTransaction{
Actions: []*txproto.Action{
{
Value: &txproto.Action_SequenceAction{
SequenceAction: &txproto.SequenceAction{
RollupId: &astriaproto.RollupId{Inner: rollupId[:]},
Data: []byte("test-data"),
// TODO(tzdybal): what about `FeeAsset`?
},
},
},
},
}

signed, err := s.signer.SignTransaction(unsignedTx)
if err != nil {
panic(err)
}

_, err = s.client.BroadcastTxAsync(ctx, signed)

return err
}
Copy link

Choose a reason for hiding this comment

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

Address TODO and verify transaction logic:

The SubmitRollupTransaction method is crucial for the functionality of the sequencer. However, there is a TODO comment on line 49 regarding the handling of FeeAsset. This needs to be addressed to ensure complete transaction processing. Additionally, the method uses panic for error handling on line 58, which is not advisable in production code as it can terminate the program unexpectedly.

Consider replacing panic with more robust error handling. Also, resolve the TODO about FeeAsset to ensure the transaction logic is complete.

- panic(err)
+ return fmt.Errorf("failed to sign transaction: %w", err)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// SubmitRollupTransaction submits a transaction from rollup to sequencer
func (s *Sequencer) SubmitRollupTransaction(ctx context.Context, rollupId sequencing.RollupId, tx sequencing.Tx) error {
unsignedTx := &txproto.UnsignedTransaction{
Actions: []*txproto.Action{
{
Value: &txproto.Action_SequenceAction{
SequenceAction: &txproto.SequenceAction{
RollupId: &astriaproto.RollupId{Inner: rollupId[:]},
Data: []byte("test-data"),
// TODO(tzdybal): what about `FeeAsset`?
},
},
},
},
}
signed, err := s.signer.SignTransaction(unsignedTx)
if err != nil {
panic(err)
}
_, err = s.client.BroadcastTxAsync(ctx, signed)
return err
}
// SubmitRollupTransaction submits a transaction from rollup to sequencer
func (s *Sequencer) SubmitRollupTransaction(ctx context.Context, rollupId sequencing.RollupId, tx sequencing.Tx) error {
unsignedTx := &txproto.UnsignedTransaction{
Actions: []*txproto.Action{
{
Value: &txproto.Action_SequenceAction{
SequenceAction: &txproto.SequenceAction{
RollupId: &astriaproto.RollupId{Inner: rollupId[:]},
Data: []byte("test-data"),
// TODO(tzdybal): what about `FeeAsset`?
},
},
},
},
}
signed, err := s.signer.SignTransaction(unsignedTx)
if err != nil {
return fmt.Errorf("failed to sign transaction: %w", err)
}
_, err = s.client.BroadcastTxAsync(ctx, signed)
return err
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Implement SubmitRollupTransaction Create stub of Sequencer
2 participants