-
Notifications
You must be signed in to change notification settings - Fork 7
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 from consensus node #179
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request removes the coinbase error checks from consensus validation and introduces a new coinbase field for L2 block assembly. The changes update JSON serialization, logging, method signatures, and test invocations across multiple packages. In addition, miner work preparation now conditionally assigns the coinbase based on the Morph204 upgrade state, with a corresponding configuration enhancement in ChainConfig. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API as L2ConsensusAPI
participant Engine
participant Miner
participant Worker
participant Config as ChainConfig
Client->>API: AssembleL2Block(params with coinbase)
API->>Engine: Forward request with coinbase, transactions
Engine->>Miner: BuildBlock(parentHash, timestamp, coinbase, transactions)
Miner->>Worker: prepareWork(genParams with coinbase)
Worker->>Config: IsMorph204(timestamp)?
Config-->>Worker: true/false
Worker->>Miner: Update coinbase assignment based on Morph204 check
sequenceDiagram
participant Worker
participant ChainConfig
Worker->>ChainConfig: IsMorph204(now)
alt Morph204 active
ChainConfig-->>Worker: true
Worker->>Worker: Set coinbase from genParams
else Morph204 inactive
ChainConfig-->>Worker: false
Worker->>Worker: Skip coinbase assignment
end
Suggested Reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Nitpick comments (1)
ethclient/authclient/engine.go (1)
15-15
: Client API signature properly updated to include coinbase parameter.The AssembleL2Block method has been correctly updated to accept the coinbase parameter and pass it to the engine API. This completes the chain of modifications needed to pass the coinbase from the consensus node through to the block creation process.
Consider adding documentation comments to explain the purpose and expected format of the coinbase parameter to help API users.
-// AssembleL2Block assembles L2 Block used for L2 sequencer to propose a block in L2 consensus progress +// AssembleL2Block assembles L2 Block used for L2 sequencer to propose a block in L2 consensus progress +// The coinbase parameter specifies the address that will receive the mining rewards for the block.Also applies to: 27-28
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
consensus/l2/consensus.go
(0 hunks)eth/catalyst/api_types.go
(1 hunks)eth/catalyst/gen_l2blockparams.go
(4 hunks)eth/catalyst/l2_api.go
(2 hunks)eth/catalyst/l2_api_test.go
(3 hunks)ethclient/authclient/engine.go
(2 hunks)miner/miner.go
(1 hunks)miner/worker.go
(1 hunks)params/config.go
(2 hunks)
💤 Files with no reviewable changes (1)
- consensus/l2/consensus.go
🔇 Additional comments (10)
params/config.go (1)
541-541
: Field addition for Morph204 upgrade checkpointThe addition of
Morph204Time
field to the ChainConfig struct allows for a time-based activation of the coinbase passing feature.eth/catalyst/api_types.go (1)
41-45
:✅ Verification successful
Added Coinbase field to AssembleL2BlockParams struct
The addition of the
Coinbase
field to the AssembleL2BlockParams struct allows passing the coinbase address from the consensus node, which aligns with the PR objective.Make sure to update any JSON serialization/deserialization code for this struct if needed.
🏁 Script executed:
#!/bin/bash # Check if the generated code for this struct has been updated find . -name "gen_l2blockparams.go" -exec cat {} \; | grep -i "coinbase"Length of output: 253
Coinbase Field Addition Verified
The addition of the
Coinbase
field to theAssembleL2BlockParams
struct now correctly propagates into the generated JSON serialization/deserialization code. The verification script confirms that the Coinbase field is being encoded and decoded as expected, matching thejson:"coinbase"
tag.
- File:
eth/catalyst/api_types.go
(Lines 41-45) – The struct now includes the Coinbase field.- Generated code: The output from
gen_l2blockparams.go
confirms proper handling of Coinbase in both encoding and decoding.No further updates are required.
miner/worker.go (1)
171-172
: Conditional coinbase setting based on Morph204 activationThis change adds a feature gate for setting the coinbase based on the Morph204 upgrade activation status. This ensures the coinbase can only be set from the consensus node when the Morph204 feature is active.
The condition properly checks both for the Morph204 activation time and that the coinbase address is not empty.
eth/catalyst/l2_api_test.go (3)
114-115
: Updated BuildBlock call with empty coinbase parameterTests have been updated to pass an empty address instead of nil to match the updated method signature.
173-174
: Updated BuildBlock call with empty coinbase parameterTests have been updated to pass an empty address instead of nil to match the updated method signature.
226-227
: Updated BuildBlock call with empty coinbase parameterTests have been updated to pass an empty address instead of nil to match the updated method signature.
eth/catalyst/gen_l2blockparams.go (1)
9-9
: Looks good: Coinbase field implementation is correctly handled.The addition of the Coinbase field to the AssembleL2BlockParams struct is properly implemented for both JSON marshaling and unmarshaling. The implementation correctly handles both required fields and the new optional Coinbase field.
Also applies to: 19-19, 24-24, 38-38, 49-51
eth/catalyst/l2_api.go (2)
67-67
: Good: Enhanced logging with coinbase information.Adding the coinbase address to the log message provides better context for debugging and monitoring block assembly operations.
84-84
: Properly integrated coinbase parameter in BuildBlock call.The coinbase parameter is correctly passed to the BuildBlock method, ensuring the specified coinbase address is used in the block creation process.
miner/miner.go (1)
170-178
:✅ Verification successful
BuildBlock signature change is properly implemented.
The signature change to include the coinbase parameter is well implemented. This modification allows external callers to specify the coinbase address for block creation, which aligns with the PR objective of passing the coinbase from the consensus node.
You might want to verify that all existing call sites to this method have been updated to include the coinbase parameter to avoid breaking changes.
🏁 Script executed:
#!/bin/bash # Find all calls to BuildBlock to ensure they're updated with the new signature rg -A 2 "BuildBlock\(" --type goLength of output: 1599
Approved: BuildBlock signature update correctly integrates the coinbase parameter
The coinbase parameter has been properly added to the
Miner.BuildBlock
method, and our verification confirms that all call sites (e.g., ineth/catalyst/l2_api.go
andeth/catalyst/l2_api_test.go
) now include the coinbase argument. Note that theBuildBlock
function incmd/evm/internal/t8ntool/block.go
is unrelated and does not require this change.
func (c *ChainConfig) IsMorph204(now uint64) bool { | ||
return isForkedTime(now, c.Morph204Time) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
❓ Verification inconclusive
Consistent implementation for new fork activation check
The IsMorph204
method follows the established pattern for fork detection by leveraging the existing isForkedTime
helper function, maintaining codebase consistency.
Note that you'll need to update the CheckConfigForkOrder
method to include this new fork in the sequence to properly enforce fork ordering.
🏁 Script executed:
#!/bin/bash
# Check if Morph204Time has been added to the fork ordering check
grep -A 30 "CheckConfigForkOrder.*func" params/config.go | grep -B 5 -A 15 "for.*range.*fork" | grep "morph204Time"
Length of output: 115
Action Required: Update Fork Ordering in CheckConfigForkOrder
The new fork activation check in IsMorph204
is implemented consistently using the existing isForkedTime
helper. However, our verification indicates that CheckConfigForkOrder
has not yet been updated to include Morph204Time
. Please update the fork ordering logic in CheckConfigForkOrder
(located in params/config.go
) to incorporate this new fork, ensuring that fork activation is enforced in the intended sequence.
1. Purpose or design rationale of this PR
...
2. PR title
Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:
3. Deployment tag versioning
Has the version in
params/version.go
been updated?4. Breaking change label
Does this PR have the
breaking-change
label?Summary by CodeRabbit