mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
fix EmptyRootHash & ZkTrie's UpdateStorage; fix genesis (#759)
* ??? * fix `UpdateStorage` * draft fix * minor
This commit is contained in:
parent
62c81eee01
commit
34bf14978e
3 changed files with 34 additions and 32 deletions
|
|
@ -450,36 +450,37 @@ func (g *Genesis) ToBlock() *types.Block {
|
|||
if g.Difficulty == nil && g.Mixhash == (common.Hash{}) {
|
||||
head.Difficulty = params.GenesisDifficulty
|
||||
}
|
||||
if g.Config != nil && g.Config.IsLondon(common.Big0) {
|
||||
if g.BaseFee != nil {
|
||||
head.BaseFee = g.BaseFee
|
||||
} else {
|
||||
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
|
||||
}
|
||||
}
|
||||
// TODO: fix basefee
|
||||
// if g.Config != nil && g.Config.IsLondon(common.Big0) {
|
||||
// if g.BaseFee != nil {
|
||||
// head.BaseFee = g.BaseFee
|
||||
// } else {
|
||||
// head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
|
||||
// }
|
||||
// }
|
||||
var withdrawals []*types.Withdrawal
|
||||
if conf := g.Config; conf != nil {
|
||||
num := big.NewInt(int64(g.Number))
|
||||
if conf.IsShanghai(num, g.Timestamp) {
|
||||
head.WithdrawalsHash = &types.EmptyWithdrawalsHash
|
||||
withdrawals = make([]*types.Withdrawal, 0)
|
||||
}
|
||||
if conf.IsCancun(num, g.Timestamp) {
|
||||
// EIP-4788: The parentBeaconBlockRoot of the genesis block is always
|
||||
// the zero hash. This is because the genesis block does not have a parent
|
||||
// by definition.
|
||||
head.ParentBeaconRoot = new(common.Hash)
|
||||
// EIP-4844 fields
|
||||
head.ExcessBlobGas = g.ExcessBlobGas
|
||||
head.BlobGasUsed = g.BlobGasUsed
|
||||
if head.ExcessBlobGas == nil {
|
||||
head.ExcessBlobGas = new(uint64)
|
||||
}
|
||||
if head.BlobGasUsed == nil {
|
||||
head.BlobGasUsed = new(uint64)
|
||||
}
|
||||
}
|
||||
}
|
||||
// if conf := g.Config; conf != nil {
|
||||
// num := big.NewInt(int64(g.Number))
|
||||
// if conf.IsShanghai(num, g.Timestamp) {
|
||||
// head.WithdrawalsHash = &types.EmptyWithdrawalsHash
|
||||
// withdrawals = make([]*types.Withdrawal, 0)
|
||||
// }
|
||||
// if conf.IsCancun(num, g.Timestamp) {
|
||||
// // EIP-4788: The parentBeaconBlockRoot of the genesis block is always
|
||||
// // the zero hash. This is because the genesis block does not have a parent
|
||||
// // by definition.
|
||||
// head.ParentBeaconRoot = new(common.Hash)
|
||||
// // EIP-4844 fields
|
||||
// head.ExcessBlobGas = g.ExcessBlobGas
|
||||
// head.BlobGasUsed = g.BlobGasUsed
|
||||
// if head.ExcessBlobGas == nil {
|
||||
// head.ExcessBlobGas = new(uint64)
|
||||
// }
|
||||
// if head.BlobGasUsed == nil {
|
||||
// head.BlobGasUsed = new(uint64)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)).WithWithdrawals(withdrawals)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,10 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
EmptyZkTrieHash = common.Hash{}
|
||||
|
||||
// EmptyRootHash is the known root hash of an empty trie.
|
||||
EmptyRootHash = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
|
||||
EmptyRootHash = EmptyZkTrieHash
|
||||
|
||||
// EmptyUncleHash is the known hash of the empty uncle set.
|
||||
EmptyUncleHash = rlpHash([]*Header(nil)) // 1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347
|
||||
|
|
|
|||
|
|
@ -127,8 +127,7 @@ func (t *ZkTrie) UpdateContractCode(_ common.Address, _ common.Hash, _ []byte) e
|
|||
}
|
||||
|
||||
func (t *ZkTrie) UpdateStorage(_ common.Address, key, value []byte) error {
|
||||
v, _ := rlp.EncodeToBytes(value)
|
||||
return t.TryUpdate(key, v)
|
||||
return t.TryUpdate(key, value)
|
||||
}
|
||||
|
||||
// Delete removes any existing value for key from the trie.
|
||||
|
|
|
|||
Loading…
Reference in a new issue