Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
ref impl: return both refL1 and nextRefL1 for driver
Browse files Browse the repository at this point in the history
  • Loading branch information
protolambda committed Jan 19, 2022
1 parent 55426b4 commit f5d7631
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions opnode/l2/sync_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ var WrongChainErr = errors.New("wrong chain")

// FindSyncStart finds nextRefL1: the L1 block needed next for sync, to derive into a L2 block on top of refL2.
// If the L1 reorgs then this will find the common history to build on top of and then follow the first step of the reorg.
func FindSyncStart(ctx context.Context, reference SyncReference, genesis *Genesis) (nextRefL1 eth.BlockID, refL2 eth.BlockID, err error) {
var refL1 eth.BlockID // the L1 block that was derived into refL2
func FindSyncStart(ctx context.Context, reference SyncReference, genesis *Genesis) (refL1, nextRefL1, refL2 eth.BlockID, err error) {
var parentL2 common.Hash // the parent of refL2
// Start at L2 head
refL1, refL2, parentL2, err = reference.RefByL2Num(ctx, nil, genesis)
Expand Down
2 changes: 1 addition & 1 deletion opnode/l2/sync_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (c *syncStartTestCase) Run(t *testing.T) {
}
expectedRefL2 := mockID(c.ExpectedRefL2, expectedRefL2Num)

nextRefL1, refL2, err := FindSyncStart(context.Background(), msr, genesis)
_, nextRefL1, refL2, err := FindSyncStart(context.Background(), msr, genesis)
if c.ExpectedErr != nil {
assert.Error(t, err, "got next L1 %s (%d), onto L2: %s (%d)", nextRefL1.Hash[:1], nextRefL1.Number, refL2.Hash[:1], refL2.Number)
assert.ErrorIs(t, err, c.ExpectedErr)
Expand Down
3 changes: 1 addition & 2 deletions specs/rollup-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ First inputs are derived from L1 source data, then outputs are derived with L2 s
The L2 block has the same format as a L1 block: a block-header and a list of transactions.

The list of transaction carries:

- A *[L1 attributes transaction]* (always first item)
- L2 transactions deposited by users in the L1 block (*[deposits]*, if any)

Expand Down Expand Up @@ -86,7 +87,6 @@ These are then encoded as a [L1 attributes deposit] to update the [L1 Attributes
[L1 attributes deposit]: deposits.md#l1-attributes-deposit
[L1 Attributes Predeploy]: deposits.md#l1-attributes-predeploy


#### Transaction deposits derivation

A [transaction deposit][transaction deposits] is an L2 transaction that has been submitted on L1, via a call to the
Expand Down Expand Up @@ -115,7 +115,6 @@ The object properties must be set as follows:
[EIP-2718]: https://eips.ethereum.org/EIPS/eip-2718
[EIP-2930]: https://eips.ethereum.org/EIPS/eip-2930


### Output derivation

Building a full block requires the earlier [derived payload attributes](#payload-attributes-derivation)
Expand Down

0 comments on commit f5d7631

Please sign in to comment.