mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
Merge pull request #1054 from maticnetwork/withdrawals
bor: make withdrawal objects nil
This commit is contained in:
commit
95cee33038
4 changed files with 24 additions and 22 deletions
|
|
@ -172,6 +172,12 @@ func encodeSigHeader(w io.Writer, header *types.Header, c *params.BorConfig) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if header.WithdrawalsHash != nil {
|
||||||
|
header.WithdrawalsHash = nil
|
||||||
|
|
||||||
|
log.Warn("Bor does not support withdrawals", "number", header.Number)
|
||||||
|
}
|
||||||
|
|
||||||
if err := rlp.Encode(w, enc); err != nil {
|
if err := rlp.Encode(w, enc); err != nil {
|
||||||
panic("can't encode: " + err.Error())
|
panic("can't encode: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
@ -816,14 +822,11 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header,
|
||||||
|
|
||||||
headerNumber := header.Number.Uint64()
|
headerNumber := header.Number.Uint64()
|
||||||
|
|
||||||
if len(withdrawals) > 0 {
|
if withdrawals != nil || header.WithdrawalsHash != nil {
|
||||||
log.Error("Bor does not support withdrawals", "number", headerNumber)
|
// withdrawals = nil is not required because withdrawals are not used
|
||||||
return
|
header.WithdrawalsHash = nil
|
||||||
}
|
|
||||||
|
|
||||||
if header.WithdrawalsHash != nil {
|
log.Warn("Bor does not support withdrawals", "number", headerNumber)
|
||||||
log.Error("Bor does not support withdrawalHash", "number", headerNumber)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
|
if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
|
||||||
|
|
@ -898,18 +901,17 @@ func (c *Bor) FinalizeAndAssemble(ctx context.Context, chain consensus.ChainHead
|
||||||
finalizeCtx, finalizeSpan := tracing.StartSpan(ctx, "bor.FinalizeAndAssemble")
|
finalizeCtx, finalizeSpan := tracing.StartSpan(ctx, "bor.FinalizeAndAssemble")
|
||||||
defer tracing.EndSpan(finalizeSpan)
|
defer tracing.EndSpan(finalizeSpan)
|
||||||
|
|
||||||
if len(withdrawals) > 0 {
|
headerNumber := header.Number.Uint64()
|
||||||
return nil, errors.New("Bor does not support withdrawals")
|
|
||||||
}
|
|
||||||
|
|
||||||
if header.WithdrawalsHash != nil {
|
if withdrawals != nil || header.WithdrawalsHash != nil {
|
||||||
return nil, errors.New("Bor does not support withdrawalHash")
|
// withdrawals != nil not required because withdrawals are not used
|
||||||
|
header.WithdrawalsHash = nil
|
||||||
|
|
||||||
|
log.Warn("Bor does not support withdrawals", "number", headerNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
stateSyncData := []*types.StateSyncData{}
|
stateSyncData := []*types.StateSyncData{}
|
||||||
|
|
||||||
headerNumber := header.Number.Uint64()
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
|
if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
|
||||||
|
|
|
||||||
|
|
@ -529,8 +529,8 @@ func (g *Genesis) ToBlock() *types.Block {
|
||||||
var withdrawals []*types.Withdrawal
|
var withdrawals []*types.Withdrawal
|
||||||
|
|
||||||
if g.Config != nil && g.Config.IsShanghai(new(big.Int).SetUint64(g.Number)) {
|
if g.Config != nil && g.Config.IsShanghai(new(big.Int).SetUint64(g.Number)) {
|
||||||
head.WithdrawalsHash = &types.EmptyWithdrawalsHash
|
head.WithdrawalsHash = nil
|
||||||
withdrawals = make([]*types.Withdrawal, 0)
|
withdrawals = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)).WithWithdrawals(withdrawals)
|
return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)).WithWithdrawals(withdrawals)
|
||||||
|
|
|
||||||
|
|
@ -101,9 +101,13 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||||
}
|
}
|
||||||
// Fail if Shanghai not enabled and len(withdrawals) is non-zero.
|
// Fail if Shanghai not enabled and len(withdrawals) is non-zero.
|
||||||
withdrawals := block.Withdrawals()
|
withdrawals := block.Withdrawals()
|
||||||
if len(withdrawals) > 0 && !p.config.IsShanghai(block.Number()) {
|
if !p.config.IsShanghai(block.Number()) && withdrawals != nil {
|
||||||
return nil, nil, 0, fmt.Errorf("withdrawals before shanghai")
|
return nil, nil, 0, fmt.Errorf("withdrawals before shanghai")
|
||||||
}
|
}
|
||||||
|
// Bor does not support withdrawals
|
||||||
|
if withdrawals != nil {
|
||||||
|
withdrawals = nil
|
||||||
|
}
|
||||||
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
|
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
|
||||||
p.engine.Finalize(p.bc, header, statedb, block.Transactions(), block.Uncles(), withdrawals)
|
p.engine.Finalize(p.bc, header, statedb, block.Transactions(), block.Uncles(), withdrawals)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -367,11 +367,7 @@ func TestGetBlockBodies68(t *testing.T) {
|
||||||
func testGetBlockBodies(t *testing.T, protocol uint) {
|
func testGetBlockBodies(t *testing.T, protocol uint) {
|
||||||
gen := func(n int, g *core.BlockGen) {
|
gen := func(n int, g *core.BlockGen) {
|
||||||
if n%2 == 0 {
|
if n%2 == 0 {
|
||||||
w := &types.Withdrawal{
|
g.AddWithdrawal(&types.Withdrawal{})
|
||||||
Address: common.Address{0xaa},
|
|
||||||
Amount: 42,
|
|
||||||
}
|
|
||||||
g.AddWithdrawal(w)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue