Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
张蕾
Geth-Modification
Commits
6d2d1261
Unverified
Commit
6d2d1261
authored
Feb 21, 2023
by
Martin Holst Swende
Committed by
GitHub
Feb 21, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix accessor mismatch for genesis state (#26747)
parent
90d25514
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
genesis.go
core/genesis.go
+7
-7
accessors_metadata.go
core/rawdb/accessors_metadata.go
+5
-5
No files found.
core/genesis.go
View file @
6d2d1261
...
...
@@ -138,7 +138,7 @@ func (ga *GenesisAlloc) deriveHash() (common.Hash, error) {
// flush is very similar with deriveHash, but the main difference is
// all the generated states will be persisted into the given database.
// Also, the genesis state specification will be flushed as well.
func
(
ga
*
GenesisAlloc
)
flush
(
db
ethdb
.
Database
,
triedb
*
trie
.
Database
)
error
{
func
(
ga
*
GenesisAlloc
)
flush
(
db
ethdb
.
Database
,
triedb
*
trie
.
Database
,
blockhash
common
.
Hash
)
error
{
statedb
,
err
:=
state
.
New
(
common
.
Hash
{},
state
.
NewDatabaseWithNodeDB
(
db
,
triedb
),
nil
)
if
err
!=
nil
{
return
err
...
...
@@ -166,15 +166,15 @@ func (ga *GenesisAlloc) flush(db ethdb.Database, triedb *trie.Database) error {
if
err
!=
nil
{
return
err
}
rawdb
.
WriteGenesisStateSpec
(
db
,
root
,
blob
)
rawdb
.
WriteGenesisStateSpec
(
db
,
blockhash
,
blob
)
return
nil
}
// CommitGenesisState loads the stored genesis state with the given block
// hash and commits it into the provided trie database.
func
CommitGenesisState
(
db
ethdb
.
Database
,
triedb
*
trie
.
Database
,
hash
common
.
Hash
)
error
{
func
CommitGenesisState
(
db
ethdb
.
Database
,
triedb
*
trie
.
Database
,
block
hash
common
.
Hash
)
error
{
var
alloc
GenesisAlloc
blob
:=
rawdb
.
ReadGenesisStateSpec
(
db
,
hash
)
blob
:=
rawdb
.
ReadGenesisStateSpec
(
db
,
block
hash
)
if
len
(
blob
)
!=
0
{
if
err
:=
alloc
.
UnmarshalJSON
(
blob
);
err
!=
nil
{
return
err
...
...
@@ -186,7 +186,7 @@ func CommitGenesisState(db ethdb.Database, triedb *trie.Database, hash common.Ha
// - supported networks(mainnet, testnets), recover with defined allocations
// - private network, can't recover
var
genesis
*
Genesis
switch
hash
{
switch
block
hash
{
case
params
.
MainnetGenesisHash
:
genesis
=
DefaultGenesisBlock
()
case
params
.
RinkebyGenesisHash
:
...
...
@@ -202,7 +202,7 @@ func CommitGenesisState(db ethdb.Database, triedb *trie.Database, hash common.Ha
return
errors
.
New
(
"not found"
)
}
}
return
alloc
.
flush
(
db
,
triedb
)
return
alloc
.
flush
(
db
,
triedb
,
blockhash
)
}
// GenesisAccount is an account in the state of the genesis block.
...
...
@@ -493,7 +493,7 @@ func (g *Genesis) Commit(db ethdb.Database, triedb *trie.Database) (*types.Block
// All the checks has passed, flush the states derived from the genesis
// specification as well as the specification itself into the provided
// database.
if
err
:=
g
.
Alloc
.
flush
(
db
,
triedb
);
err
!=
nil
{
if
err
:=
g
.
Alloc
.
flush
(
db
,
triedb
,
block
.
Hash
()
);
err
!=
nil
{
return
nil
,
err
}
rawdb
.
WriteTd
(
db
,
block
.
Hash
(),
block
.
NumberU64
(),
block
.
Difficulty
())
...
...
core/rawdb/accessors_metadata.go
View file @
6d2d1261
...
...
@@ -82,15 +82,15 @@ func WriteChainConfig(db ethdb.KeyValueWriter, hash common.Hash, cfg *params.Cha
}
// ReadGenesisStateSpec retrieves the genesis state specification based on the
// given genesis hash.
func
ReadGenesisStateSpec
(
db
ethdb
.
KeyValueReader
,
hash
common
.
Hash
)
[]
byte
{
data
,
_
:=
db
.
Get
(
genesisStateSpecKey
(
hash
))
// given genesis
(block-)
hash.
func
ReadGenesisStateSpec
(
db
ethdb
.
KeyValueReader
,
block
hash
common
.
Hash
)
[]
byte
{
data
,
_
:=
db
.
Get
(
genesisStateSpecKey
(
block
hash
))
return
data
}
// WriteGenesisStateSpec writes the genesis state specification into the disk.
func
WriteGenesisStateSpec
(
db
ethdb
.
KeyValueWriter
,
hash
common
.
Hash
,
data
[]
byte
)
{
if
err
:=
db
.
Put
(
genesisStateSpecKey
(
hash
),
data
);
err
!=
nil
{
func
WriteGenesisStateSpec
(
db
ethdb
.
KeyValueWriter
,
block
hash
common
.
Hash
,
data
[]
byte
)
{
if
err
:=
db
.
Put
(
genesisStateSpecKey
(
block
hash
),
data
);
err
!=
nil
{
log
.
Crit
(
"Failed to store genesis state"
,
"err"
,
err
)
}
}
...
...
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