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: pass coinbase to execution layer, and add coinbase to block context #731

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

Conversation

FletcherMan
Copy link
Collaborator

@FletcherMan FletcherMan commented Mar 7, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a new CLI option to configure the Morph 204 upgrade timing, providing users with enhanced control over scheduling.
  • Improvements
    • Streamlined block and batch processing to boost reliability and performance.
    • Enhanced error handling for improved block assembly stability.
  • Configuration Updates
    • Optimized governance and staking settings to better manage network timing.
    • Updated underlying platform dependencies to reinforce security and overall system consistency.

@FletcherMan FletcherMan requested a review from a team as a code owner March 7, 2025 11:39
@FletcherMan FletcherMan requested review from r3aker86 and removed request for a team March 7, 2025 11:39
Copy link

coderabbitai bot commented Mar 7, 2025

Walkthrough

This pull request updates the submodule branch in .gitmodules from “main” to “features/coinbase” and revises the dependency version of the go-ethereum library across multiple modules. The Makefile has been updated to change the target version and simplify its dependency chain. In addition, the PR simplifies batch processing logic in several node core files, improves the CLI configuration by adding a new flag, and adjusts genesis and Docker configurations. Updates to method signatures include adding a coinbase parameter for block assembly across various components.

Changes

File(s) Summary
.gitmodules Updated the “go-ethereum” submodule branch from main to features/coinbase.
Makefile Updated ETHEREUM_TARGET_VERSION and removed the submodules dependency from the devnet-up target.
bindings/go.mod, contracts/go.mod, node/go.mod, ops/.../go.mod (including ops/tools/go.mod, oracle/go.mod, tx-submitter/go.mod) Upgraded the github.com/morph-l2/go-ethereum dependency version from v1.10.14-0.20250218031646-de5160c106de to v1.10.14-0.20250225020901-6fe0ee6ffedd.
node/core/batch.go, node/core/batch_seal.go, node/core/config.go, node/core/executor.go, node/types/consensus_message.go Simplified batch processing logic, introduced a new UpgradeConfig struct, updated coinbase handling in block assembly, and modified block context serialization to include a miner address.
node/types/retryable_client.go Updated the AssembleL2Block method signature to include a new coinbase parameter.
node/sequencer/mock/sequencer.go Modified the call to AssembleL2Block to supply a new common.Address{} parameter.
node/flags/flags.go Added a new CLI flag Morph204Time for configuring the Morph 204 upgrade time.
ops/docker/Dockerfile.l1-beacon, ops/docker/docker-compose-4nodes.yml Added a date command in the Dockerfile and inserted a commented-out logging configuration in the docker-compose file.
ops/l2-genesis/deploy-config/devnet-deploy-config.json, ops/l2-genesis/…/genesis/config.go, ops/l2-genesis/…/genesis/genesis.go Adjusted governance timing values, introduced a new key l2StakingPks, and added Morph204Time parameters to the genesis configuration.

Sequence Diagram(s)

sequenceDiagram
    participant E as Executor
    participant M as TmPubKeyMap
    participant RC as RetryableClient
    participant AC as AuthClient

    E->>M: Lookup coinbase using tmKey
    alt Coinbase Found
        E->>RC: Call AssembleL2Block(ctx, number, coinbase, txs)
        RC->>AC: Forward call with coinbase
        AC-->>RC: Return assembled L2 block
        RC-->>E: Return assembled L2 block
    else Coinbase Not Found
        E-->>E: Log error and abort process
    end
Loading

Possibly related PRs

Suggested reviewers

  • chengwenxi
  • r3aker86

Poem

I'm a bunny in the code, hopping through each line,
Branches shift and updates flow, all working just fine.
Dependencies march ahead with a rhythmic, steady beat,
Configs and CLI flags now make our upgrades neat.
With a twitch of my nose and a joyful little hop,
I celebrate our changes—onward until we reach the top!
🥕🐇

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 golangci-lint (1.62.2)

level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package zstd: could not load export data: no export data for "morph-l2/node/zstd""
level=error msg="Running error: can't run linter goanalysis_metalinter\nbuildir: failed to load package zstd: could not load export data: no export data for "morph-l2/node/zstd""

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this 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.

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: 1

🔭 Outside diff range comments (2)
node/flags/flags.go (1)

304-367: ⚠️ Potential issue

Flag missing from Flags slice.

The newly added Morph204Time flag isn't included in the Flags slice, meaning it won't be recognized by the CLI parser.

Apply this diff to include the flag:

var Flags = []cli.Flag{
	Home,
	L1NodeAddr,
	L1ChainID,
	L1Confirmations,
	L2EthAddr,
	L2EngineAddr,
	L2EngineJWTSecret,
	MaxL1MessageNumPerBlock,
	L2CrossDomainMessengerContractAddr,
	L2SequencerAddr,
	GovAddr,

	// sync optioins
	SyncDepositContractAddr,
	SyncStartHeight,
	SyncPollInterval,
	SyncLogProgressInterval,
	SyncFetchBlockRange,

	// db options
	DBDataDir,
	DBNamespace,
	DBHandles,
	DBCache,
	DBFreezer,

	DevSequencer,
	TendermintConfigPath,
	MockEnabled,
	ValidatorEnable,
	ChallengeEnable,

	// validator
	ValidatorPrivateKey,

	// derivation
	RollupContractAddress,
	DerivationStartHeight,
	DerivationBaseHeight,
	DerivationPollInterval,
	DerivationLogProgressInterval,
	DerivationFetchBlockRange,
	DerivationConfirmations,
	L1BeaconAddr,

	// batch rules
	UpgradeBatchTime,
+	Morph204Time,
	MainnetFlag,
	HoleskyFlag,

	// logger
	LogLevel,
	LogFormat,
	LogFilename,
	LogFileMaxSize,
	LogFileMaxAge,
	LogCompress,

	// metrics
	MetricsServerEnable,
	MetricsPort,
	MetricsHostname,
}
node/types/consensus_message.go (1)

171-176: ⚠️ Potential issue

Potential issue: HeightFromBlockContextBytes function needs update

The HeightFromBlockContextBytes function checks for a strict length of 60 bytes, but with the new changes, the block context bytes can now be 80 bytes when the Miner address is included.

-	if len(blockContextBytes) != 60 {
+	if len(blockContextBytes) != 60 && len(blockContextBytes) != 80 {
 		return 0, fmt.Errorf("wrong block context bytes length, input: %x", blockContextBytes)
 	}
🧹 Nitpick comments (3)
ops/docker/Dockerfile.l1-beacon (1)

3-3: Added RUN date Command.
The addition of RUN date prints the current date during the Docker build. This can be useful for debugging or build timestamping. Please verify that this output is intentional and documented (or remove it if not required in production builds).

ops/docker/docker-compose-4nodes.yml (1)

253-253: Commented-out Logging Configuration.
A new commented-out line ## --log.level="consensus:debug,*:info" has been introduced. This appears to suggest a logging configuration option for debugging. Confirm whether you want to keep it for future use (with proper documentation on how to enable it) or remove it entirely to avoid confusion.

node/core/batch.go (1)

345-347: Remove unused function isBatchUpgraded.

This function is flagged as unused in the pipeline failures and appears to be leftover from the previous conditional logic that was simplified.

-func (e *Executor) isBatchUpgraded(blockTime uint64) bool {
-	return blockTime >= e.UpgradeBatchTime
-}
🧰 Tools
🪛 GitHub Actions: Node

[warning] 345-345: func (*Executor).isBatchUpgraded is unused (unused)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db42adc and 15ce92d.

⛔ Files ignored due to path filters (8)
  • bindings/go.sum is excluded by !**/*.sum
  • contracts/go.sum is excluded by !**/*.sum
  • go.work.sum is excluded by !**/*.sum
  • node/go.sum is excluded by !**/*.sum
  • ops/l2-genesis/go.sum is excluded by !**/*.sum
  • ops/tools/go.sum is excluded by !**/*.sum
  • oracle/go.sum is excluded by !**/*.sum
  • tx-submitter/go.sum is excluded by !**/*.sum
📒 Files selected for processing (24)
  • .gitmodules (1 hunks)
  • Makefile (2 hunks)
  • bindings/go.mod (1 hunks)
  • contracts/go.mod (1 hunks)
  • contracts/src/deploy-config/l1.ts (1 hunks)
  • go-ethereum (1 hunks)
  • node/core/batch.go (1 hunks)
  • node/core/batch_seal.go (2 hunks)
  • node/core/config.go (3 hunks)
  • node/core/executor.go (2 hunks)
  • node/flags/flags.go (1 hunks)
  • node/go.mod (1 hunks)
  • node/sequencer/mock/sequencer.go (2 hunks)
  • node/types/consensus_message.go (2 hunks)
  • node/types/retryable_client.go (1 hunks)
  • ops/docker/Dockerfile.l1-beacon (1 hunks)
  • ops/docker/docker-compose-4nodes.yml (1 hunks)
  • ops/l2-genesis/deploy-config/devnet-deploy-config.json (2 hunks)
  • ops/l2-genesis/go.mod (1 hunks)
  • ops/l2-genesis/morph-chain-ops/genesis/config.go (1 hunks)
  • ops/l2-genesis/morph-chain-ops/genesis/genesis.go (2 hunks)
  • ops/tools/go.mod (1 hunks)
  • oracle/go.mod (1 hunks)
  • tx-submitter/go.mod (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Node
node/core/batch.go

[warning] 345-345: func (*Executor).isBatchUpgraded is unused (unused)

🔇 Additional comments (33)
node/go.mod (1)

13-13: Update of go-ethereum Dependency Version.
The dependency on github.com/morph-l2/go-ethereum has been updated to v1.10.14-0.20250225020901-6fe0ee6ffedd, aligning with similar updates across other modules. Considering the PR’s objectives—to pass the coinbase to the execution layer and add coinbase to the block context—please verify that this new version provides the necessary support for those features.

ops/tools/go.mod (1)

8-8: Updated go-ethereum Dependency Version in Tools Module.
The change to github.com/morph-l2/go-ethereum v1.10.14-0.20250225020901-6fe0ee6ffedd ensures consistency with the overall dependency updates. Double-check that this version meets all feature requirements (including handling coinbase parameters) for the tools module.

contracts/go.mod (1)

9-9: Dependency Version Update in Contracts Module.
The update of github.com/morph-l2/go-ethereum here to v1.10.14-0.20250225020901-6fe0ee6ffedd brings consistency across modules. Given the PR’s focus on coinbase integration, please confirm that this new version offers the necessary improvements and supports the added coinbase parameter in block context.

ops/l2-genesis/go.mod (1)

9-9: Version updated for go-ethereum dependency.

The dependency on github.com/morph-l2/go-ethereum has been updated to version v1.10.14-0.20250225020901-6fe0ee6ffedd. This aligns with similar updates across multiple modules in this PR.

tx-submitter/go.mod (1)

10-10: Version updated for go-ethereum dependency.

The dependency on github.com/morph-l2/go-ethereum has been updated to version v1.10.14-0.20250225020901-6fe0ee6ffedd. This aligns with similar updates across multiple modules in this PR.

oracle/go.mod (1)

10-10: Version updated for go-ethereum dependency.

The dependency on github.com/morph-l2/go-ethereum has been updated to version v1.10.14-0.20250225020901-6fe0ee6ffedd. This aligns with similar updates across multiple modules in this PR.

bindings/go.mod (1)

7-7: Version updated for go-ethereum dependency.

The dependency on github.com/morph-l2/go-ethereum has been updated to version v1.10.14-0.20250225020901-6fe0ee6ffedd. This aligns with similar updates across multiple modules in this PR.

node/flags/flags.go (1)

229-233: New flag added for Morph 204 upgrade time.

The new flag is properly defined and follows the same pattern as other flags in the file.

ops/l2-genesis/deploy-config/devnet-deploy-config.json (2)

24-25: Governance batch parameters significantly increased

The govBatchBlockInterval and govBatchTimeout have been substantially increased (from 20 to 600 and from 600 to 1200 respectively). These changes will result in less frequent batch processing and longer timeouts.

Could you confirm if this change was intentional and whether it could impact system responsiveness? The significant increase suggests a fundamental change in governance batch processing frequency.


46-51: New staking public keys added

The addition of l2StakingPks with four public keys aligns with the PR objective of adding coinbase support. These keys likely correspond to the l2StakingAddresses defined above.

Make sure these public keys are properly secured in production environments, as they're sensitive cryptographic material.

Makefile (1)

3-3: Updated Ethereum target version

The ETHEREUM_TARGET_VERSION has been updated to a newer version, which aligns with the PR objective of updating dependency versions.

contracts/src/deploy-config/l1.ts (1)

30-30: Updated batch header value

The batchHeader hexadecimal value has been updated, which is likely related to the changes in batch processing mentioned in the PR description.

Since this is a large hexadecimal value that's difficult to verify by visual inspection, can you confirm this value was generated correctly and matches the expected format for the updated system?

go-ethereum (1)

1-1: Submodule Commit Updated Correctly.

The submodule pointer has been updated to commit 6039a12094aa91bc711d7296341f58ded34f3077, which aligns with the updated branch features/coinbase as specified in the PR objectives. Please ensure that the associated changes in the .gitmodules and build configurations (e.g., Makefile) are thoroughly tested with this new commit.

.gitmodules (1)

4-4: Branch update for go-ethereum submodule

The change from "main" branch to "features/coinbase" branch aligns with the PR's objective to pass coinbase to the execution layer. This change will ensure that the project uses the specific feature branch that contains the required coinbase functionality.

node/types/consensus_message.go (1)

108-125: Good implementation of coinbase in block context

The implementation correctly appends the Miner address to the block context bytes when it's not empty. The comment has been updated to reflect the new structure including the Miner field (20 bytes).

A few observations:

  1. The conditional check for non-empty Miner address is appropriate
  2. The byte slice is extended to accommodate the additional 20 bytes
  3. The Miner address bytes are copied to the correct position in the extended array

This implementation supports the PR objective of adding coinbase to the block context.

ops/l2-genesis/morph-chain-ops/genesis/config.go (1)

131-131: Addition of Morph204Time configuration field

The new field Morph204Time follows the same pattern as the existing Morph203Time field, with appropriate type (*uint64) and JSON tag. This addition allows for configuration of the Morph204 upgrade time.

ops/l2-genesis/morph-chain-ops/genesis/genesis.go (2)

38-47: Good implementation of Morph204Time handling

The new variable block declaration improves code readability and the initialization logic for morph204Time follows the established pattern for morph203Time. The implementation correctly checks if the configuration value is not nil before assigning it.


70-70: Properly extending chain configuration with Morph204Time

The Morph204Time field is correctly integrated into the params.ChainConfig structure, maintaining consistency with how other upgrade times are configured.

node/sequencer/mock/sequencer.go (2)

8-8: Necessary addition for new coinbase functionality.

The import of the common package is required for using the common.Address type in the updated AssembleL2Block call.


43-43:

❓ Verification inconclusive

New coinbase parameter added to AssembleL2Block.

The method call now includes a coinbase parameter (empty address), aligning with the updated method signature in node/types/retryable_client.go.

Consider whether an empty address is appropriate as the coinbase parameter or if a specific address should be used for the mock sequencer.


🏁 Script executed:

#!/bin/bash
# Check for other usages of AssembleL2Block to understand expected coinbase values
rg -A 1 "AssembleL2Block" --type go

Length of output: 1183


Action: Verify the appropriateness of the default empty coinbase value in the mock sequencer.

After reviewing the code:

  • In node/types/retryable_client.go, the updated method signature for AssembleL2Block now requires an explicit coinbase parameter.
  • In node/core/executor.go, a specific coinbase value is provided, whereas in the mock sequencer (node/sequencer/mock/sequencer.go), an empty address (common.Address{}) is used.

Please verify whether passing an empty address in the mock context accurately reflects the desired behavior for tests. If the intention is to simulate a real sequencer, you might consider using a representative coinbase value instead.

node/core/batch.go (1)

181-181: Code simplification for batch size checking.

The logic for determining if a batch exceeds the compressed size limit has been simplified by removing conditional checks related to batch upgrades.

node/types/retryable_client.go (2)

48-48: Updated method signature to include coinbase address.

The AssembleL2Block method now takes a coinbase parameter of type common.Address, which is important for block assembly.


50-50: Properly forwarded coinbase parameter.

The coinbase parameter is correctly passed to the underlying authClient.AssembleL2Block method.

node/core/config.go (4)

25-28: Well-structured upgrade configuration.

The new UpgradeConfig struct provides a cleaner way to manage upgrade-related parameters by grouping them together.


31-37: Network-specific upgrade configurations.

Predefined configurations for Mainnet and Holesky networks with Morph204Time initialized to 0. This approach allows for network-specific defaults.


47-47: Config struct field updated to use new UpgradeConfig.

Changed from a direct uint64 field to a pointer to UpgradeConfig struct, allowing for more structured configuration management.


170-189: Enhanced CLI configuration handling.

The upgrade configuration now supports:

  1. Setting network-specific configs (Mainnet/Holesky)
  2. Creating a custom config with values from CLI flags
  3. Proper logging of configuration values

This provides more flexibility while maintaining good defaults.

node/core/executor.go (2)

123-123: Configuration refactoring improvement.

The change to use config.UpgradeConfig.BatchTime instead of a direct field improves organization by grouping upgrade-related configurations together.


178-187:

✅ Verification successful

Implementation of coinbase address retrieval for block assembly.

The code correctly retrieves the validator's address from valsByTmKey to use as coinbase and passes it to AssembleL2Block. This aligns with the PR objective of passing coinbase to the execution layer.


🏁 Script executed:

#!/bin/bash
# Check if all AssembleL2Block calls now use the coinbase parameter
rg "AssembleL2Block\(" -A 1 -B 1

Length of output: 1071


Action Required: Confirm proper coinbase usage in production and mock contexts

The changes in node/core/executor.go correctly retrieve the validator’s coinbase from valsByTmKey and pass it to AssembleL2Block(). Our verification confirms that in production code—such as in node/types/retryable_client.go—the coinbase parameter is properly provided. Note that in the mock implementation (node/sequencer/mock/sequencer.go), the coinbase defaults to an empty address, which appears intentional for test scenarios.

  • node/core/executor.go: Correctly assembles coinbase from validator data.
  • node/types/retryable_client.go: Uses the coinbase parameter as expected.
  • node/sequencer/mock/sequencer.go: Continues to pass an empty address, aligning with mock design.
node/core/batch_seal.go (4)

64-64: Parameter usage clarification.

The blockTimestamp parameter has been replaced with an underscore, indicating it's no longer used in the function. This is good practice for documenting unused parameters.


72-75: Simplification of batch compression logic.

The conditional checks for batch version have been removed in favor of directly using V2 methods, which simplifies the code.


77-82: Direct usage of V2 hash calculation.

Similar to the compression logic, this simplifies the code by removing version checks and directly using V2 methods for data hash calculation.


99-115:

✅ Verification successful

Simplified batch header creation.

The batch header creation has been streamlined to directly create a BatchHeaderV1 structure without conditional version checking, making the code cleaner and more maintainable.


🏁 Script executed:

#!/bin/bash
# Check for any remaining references to conditionally creating different batch header versions
rg "BatchHeaderV0.*?Bytes\(\)" --no-filename

Length of output: 147


Batch header creation simplified verified; conditional version check removed.

The changes in node/core/batch_seal.go now directly create a BatchHeaderV1 without any conditional version checking logic. The shell script search did not uncover any lingering conditional references in this context—the remaining BatchHeaderV0.Bytes() implementation is separate and expected.

@@ -128,7 +128,7 @@ go-ubuntu-builder:

################## devnet 4 nodes ####################

devnet-up: submodules go-ubuntu-builder
devnet-up: go-ubuntu-builder
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Simplified dependency chain for devnet-up target

The dependency on submodules has been removed from the devnet-up target, which simplifies the build process but might affect dependency management.

This simplification means developers will need to manually update submodules before running this target. Consider adding a comment or documentation update if this change is intentional.


🏁 Script executed:

#!/bin/bash
# Check if there are any uninitialized or outdated submodules
git submodule status | grep -E '^\-|^\+'

Length of output: 96


Attention: Update Documentation for Manual Submodule Refresh in devnet-up Target

The dependency on submodules has been removed from the devnet-up target—as evidenced by the outdated go-ethereum submodule in your verification—which means submodules now need to be updated manually. Please add a comment in the Makefile and update the relevant documentation (e.g., README) to remind developers that running devnet-up no longer auto-updates submodules.

  • The output from git submodule status | grep -E '^\-|^\+' shows an outdated go-ethereum submodule.
  • If the removal of automatic submodule updates is intentional, document this behavior to avoid confusion.

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

Successfully merging this pull request may close these issues.

1 participant