Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
4d1c917e
Commit
4d1c917e
authored
Feb 27, 2025
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug for genesis
parent
1b908768
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
27 deletions
+74
-27
alloc.json
exchain/genesis/alloc.json
+11
-0
genesis.go
exchain/genesis/genesis.go
+2
-2
genesis_test.go
exchain/genesis/genesis_test.go
+11
-0
cmd.go
op-node/cmd/genesis/cmd.go
+1
-1
l1_block_info.go
op-node/rollup/derive/l1_block_info.go
+13
-0
payload_util.go
op-node/rollup/derive/payload_util.go
+31
-19
build_start.go
op-node/rollup/engine/build_start.go
+5
-5
No files found.
exchain/genesis/alloc.json
0 → 100644
View file @
4d1c917e
{
"0x905D5E8F7db76bCA91fdcA0990be7263dfD23335"
:
{
"signerProxy"
:
"0x"
,
"assets"
:
{
"usdc"
:
{
"balance"
:
"0x20000000000"
,
"frozen"
:
"0x10"
}
}
}
}
exchain/genesis/genesis.go
View file @
4d1c917e
...
...
@@ -116,8 +116,8 @@ func LoadGenesisAllocs(allocsPath string) (GenesisAlloc, error) {
}
defer
f
.
Close
()
var
out
=
make
(
GenesisAlloc
)
if
err
:=
json
.
NewDecoder
(
f
)
.
Decode
(
out
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to json-decode
forge
allocs %q: %w"
,
allocsPath
,
err
)
if
err
:=
json
.
NewDecoder
(
f
)
.
Decode
(
&
out
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to json-decode
genesis
allocs %q: %w"
,
allocsPath
,
err
)
}
return
out
,
nil
}
exchain/genesis/genesis_test.go
View file @
4d1c917e
...
...
@@ -62,3 +62,14 @@ func TestGenesisBlock_ToBlock(t *testing.T) {
block
:=
gen
.
ToBlock
()
fmt
.
Println
(
"genesis block is "
,
block
.
String
())
}
func
TestLoadGenesisAllocs
(
t
*
testing
.
T
)
{
genesis
,
err
:=
LoadGenesisAllocs
(
"alloc.json"
)
if
err
!=
nil
{
t
.
Fatal
(
"load genesis allocs failed"
,
"err"
,
err
)
}
for
addr
,
info
:=
range
genesis
{
data
,
_
:=
info
.
MarshalJSON
()
fmt
.
Printf
(
"user[%s]={%s}
\n
"
,
addr
.
String
(),
string
(
data
))
}
}
op-node/cmd/genesis/cmd.go
View file @
4d1c917e
...
...
@@ -169,7 +169,7 @@ var Subcommands = cli.Commands{
}
config
.
SetDeployments
(
deployments
)
var
l2Allocs
chaingenesis
.
GenesisAlloc
var
l2Allocs
=
make
(
chaingenesis
.
GenesisAlloc
)
if
l2AllocsPath
:=
ctx
.
String
(
l2AllocsFlag
.
Name
);
l2AllocsPath
!=
""
{
l2Allocs
,
err
=
chaingenesis
.
LoadGenesisAllocs
(
l2AllocsPath
)
if
err
!=
nil
{
...
...
op-node/rollup/derive/l1_block_info.go
View file @
4d1c917e
...
...
@@ -5,6 +5,7 @@ import (
"encoding/binary"
"errors"
"fmt"
nebulav1
"github.com/exchain/go-exchain/exchain/protocol/gen/go/nebula/v1"
"math/big"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -308,6 +309,18 @@ func L1BlockInfoFromBytes(rollupCfg *rollup.Config, l2BlockTime uint64, data []b
return
&
info
,
info
.
unmarshalBinaryBedrock
(
data
)
}
// L1BlockInfoFromBytes is the inverse of L1InfoDeposit, to see where the L2 chain is derived from
func
L1BlockInfoFromNebula
(
rollupCfg
*
rollup
.
Config
,
l2BlockTime
uint64
,
tx
*
nebulav1
.
ProtocolTransaction
)
(
*
L1BlockInfo
,
error
)
{
info
:=
&
L1BlockInfo
{
Number
:
tx
.
L1Number
,
Time
:
tx
.
L1Time
,
BlockHash
:
common
.
BytesToHash
(
tx
.
L1BlockHash
),
SequenceNumber
:
tx
.
SequenceNumber
,
BatcherAddr
:
common
.
BytesToAddress
(
tx
.
BatcherAddr
),
}
return
info
,
nil
}
// L1InfoDeposit creates a L1 Info deposit transaction based on the L1 block,
// and the L2 block-height difference with the start of the epoch.
func
L1InfoDeposit
(
rollupCfg
*
rollup
.
Config
,
sysCfg
eth
.
SystemConfig
,
seqNumber
uint64
,
block
eth
.
BlockInfo
,
l2Timestamp
uint64
)
(
*
types
.
DepositTx
,
error
)
{
...
...
op-node/rollup/derive/payload_util.go
View file @
4d1c917e
...
...
@@ -3,6 +3,7 @@ package derive
import
(
"encoding/binary"
"fmt"
nebulav1
"github.com/exchain/go-exchain/exchain/protocol/gen/go/nebula/v1"
"github.com/exchain/go-exchain/op-node/rollup"
"github.com/exchain/go-exchain/op-service/eth"
)
...
...
@@ -20,22 +21,22 @@ func PayloadToBlockRef(rollupCfg *rollup.Config, payload *eth.ExecutionPayload)
l1Origin
=
genesis
.
L1
sequenceNumber
=
0
}
else
{
// todo: vicotor implement this.
//if len(payload.Transaction
s) == 0 {
// return eth.L2BlockRef{}, fmt.Errorf("l2 block is missing L1 info deposit tx
, block hash: %s", payload.BlockHash)
//
}
//var tx types.Transaction
//if err := tx.UnmarshalBinary(payload.Transactions[0]); err != nil
{
// return eth.L2BlockRef{}, fmt.Errorf("failed to decode first tx to read l1 info from: %w", err
)
//
}
//if tx.Type() != types.DepositTxType {
// return eth.L2BlockRef{}, fmt.Errorf("first payload tx has unexpected tx type: %d", tx.Type())
//}
info
,
err
:=
L1BlockInfoFromBytes
(
rollupCfg
,
uint64
(
payload
.
Timestamp
),
tx
.
Data
())
//if err != nil {
// return eth.L2BlockRef{}, fmt.Errorf("failed to parse L1 info deposit tx from L2 block: %w", err)
//}
//l1Origin = eth.BlockID{Hash: info.BlockHash, Number: info.Number
}
txs
:=
payload
.
Transactions
()
if
len
(
tx
s
)
==
0
{
return
eth
.
L2BlockRef
{},
fmt
.
Errorf
(
"l2 block is missing L1 info
, block hash: %s"
,
payload
.
BlockHash
)
}
tx
:=
txs
[
0
]
if
tx
.
TxType
!=
nebulav1
.
TxType_ProtocolTx
{
return
eth
.
L2BlockRef
{},
fmt
.
Errorf
(
"first payload tx has unexpected tx type: %d"
,
tx
.
TxType
)
}
content
:=
tx
.
GetProtocolTx
()
if
content
==
nil
{
return
eth
.
L2BlockRef
{},
fmt
.
Errorf
(
"first payload tx has unexpected tx type: %d"
,
tx
.
TxType
)
}
info
,
err
:=
L1BlockInfoFromNebula
(
rollupCfg
,
uint64
(
payload
.
Timestamp
),
content
)
if
err
!=
nil
{
return
eth
.
L2BlockRef
{},
fmt
.
Errorf
(
"failed to parse L1 info deposit tx from L2 block: %w"
,
err
)
}
l1Origin
=
eth
.
BlockID
{
Hash
:
info
.
BlockHash
,
Number
:
info
.
Number
}
sequenceNumber
=
info
.
SequenceNumber
}
...
...
@@ -59,9 +60,20 @@ func PayloadToSystemConfig(rollupCfg *rollup.Config, payload *eth.ExecutionPaylo
}
return
rollupCfg
.
Genesis
.
SystemConfig
,
nil
}
// todo: vicotor implement this.
data
:=
[]
byte
{}
info
,
err
:=
L1BlockInfoFromBytes
(
rollupCfg
,
uint64
(
payload
.
Timestamp
),
data
)
txs
:=
payload
.
Transactions
()
if
len
(
txs
)
==
0
{
return
eth
.
SystemConfig
{},
fmt
.
Errorf
(
"l2 block is missing L1 info, block hash: %s"
,
payload
.
BlockHash
)
}
tx
:=
txs
[
0
]
if
tx
.
TxType
!=
nebulav1
.
TxType_ProtocolTx
{
return
eth
.
SystemConfig
{},
fmt
.
Errorf
(
"first payload tx has unexpected tx type: %d"
,
tx
.
TxType
)
}
content
:=
tx
.
GetProtocolTx
()
if
content
==
nil
{
return
eth
.
SystemConfig
{},
fmt
.
Errorf
(
"first payload tx has unexpected tx type: %d"
,
tx
.
TxType
)
}
info
,
err
:=
L1BlockInfoFromNebula
(
rollupCfg
,
uint64
(
payload
.
Timestamp
),
content
)
//info, err := L1BlockInfoFromBytes(rollupCfg, uint64(payload.Timestamp), data)
if
err
!=
nil
{
return
eth
.
SystemConfig
{},
fmt
.
Errorf
(
"failed to parse L1 info deposit tx from L2 block: %w"
,
err
)
}
...
...
op-node/rollup/engine/build_start.go
View file @
4d1c917e
...
...
@@ -37,11 +37,11 @@ func (eq *EngDeriver) onBuildStart(ev BuildStartEvent) {
eq
.
emitter
.
Emit
(
rollup
.
CriticalErrorEvent
{
Err
:
err
})
// make the node exit, things are very wrong.
return
}
//
fc := eth.ForkchoiceState{
//
HeadBlockHash: fcEvent.UnsafeL2Head.Hash,
//
SafeBlockHash: fcEvent.SafeL2Head.Hash,
//
FinalizedBlockHash: fcEvent.FinalizedL2Head.Hash,
//
}
fc
:=
eth
.
ForkchoiceState
{
HeadBlockHash
:
fcEvent
.
UnsafeL2Head
.
Hash
,
SafeBlockHash
:
fcEvent
.
SafeL2Head
.
Hash
,
FinalizedBlockHash
:
fcEvent
.
FinalizedL2Head
.
Hash
,
}
buildStartTime
:=
time
.
Now
()
result
,
err
:=
startPayload
(
context
.
TODO
(),
eq
.
ec
.
engine
,
fc
,
ev
.
Attributes
.
Attributes
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment