Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge V1.1.0 beta candidate to 'develop' #1068

Merged
merged 19 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions builder/files/genesis-testnet-v4.json

Large diffs are not rendered by default.

23 changes: 8 additions & 15 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,14 @@

// Verify that the gas limit is <= 2^63-1
gasCap := uint64(0x7fffffffffffffff)

if header.GasLimit > gasCap {
return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, gasCap)
}

if header.WithdrawalsHash != nil {
return consensus.ErrUnexpectedWithdrawals
}

Check warning on line 390 in consensus/bor/bor.go

View check run for this annotation

Codecov / codecov/patch

consensus/bor/bor.go#L388-L390

Added lines #L388 - L390 were not covered by tests

// All basic checks passed, verify cascading fields
return c.verifyCascadingFields(chain, header, parents)
}
Expand Down Expand Up @@ -816,13 +819,7 @@

headerNumber := header.Number.Uint64()

if len(withdrawals) > 0 {
log.Error("Bor does not support withdrawals", "number", headerNumber)
return
}

if header.WithdrawalsHash != nil {
log.Error("Bor does not support withdrawalHash", "number", headerNumber)
if withdrawals != nil || header.WithdrawalsHash != nil {
return
}

Expand Down Expand Up @@ -898,18 +895,14 @@
finalizeCtx, finalizeSpan := tracing.StartSpan(ctx, "bor.FinalizeAndAssemble")
defer tracing.EndSpan(finalizeSpan)

if len(withdrawals) > 0 {
return nil, errors.New("Bor does not support withdrawals")
}
headerNumber := header.Number.Uint64()

Check warning on line 898 in consensus/bor/bor.go

View check run for this annotation

Codecov / codecov/patch

consensus/bor/bor.go#L898

Added line #L898 was not covered by tests

if header.WithdrawalsHash != nil {
return nil, errors.New("Bor does not support withdrawalHash")
if withdrawals != nil || header.WithdrawalsHash != nil {
return nil, consensus.ErrUnexpectedWithdrawals

Check warning on line 901 in consensus/bor/bor.go

View check run for this annotation

Codecov / codecov/patch

consensus/bor/bor.go#L900-L901

Added lines #L900 - L901 were not covered by tests
}

stateSyncData := []*types.StateSyncData{}

headerNumber := header.Number.Uint64()

var err error

if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
Expand Down
7 changes: 6 additions & 1 deletion consensus/bor/statefull/processor.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package statefull

import (
"bytes"
"context"
"math"
"math/big"
Expand Down Expand Up @@ -90,7 +91,11 @@ func ApplyMessage(

success := big.NewInt(5).SetBytes(ret)

if success.Cmp(big.NewInt(0)) == 0 {
validatorContract := common.HexToAddress(chainConfig.Bor.ValidatorContract)

// if success == 0 and msg.To() != validatorContractAddress, log Error
// if msg.To() == validatorContractAddress, its committing a span and we don't get any return value
if success.Cmp(big.NewInt(0)) == 0 && !bytes.Equal(msg.To().Bytes(), validatorContract.Bytes()) {
log.Error("message execution failed on contract", "msgData", msg.Data)
}

Expand Down
3 changes: 3 additions & 0 deletions consensus/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ var (
// ErrInvalidTerminalBlock is returned if a block is invalid wrt. the terminal
// total difficulty.
ErrInvalidTerminalBlock = errors.New("invalid terminal block")

// ErrUnexpectedWithdrawals is returned if a pre-Shanghai block has withdrawals.
ErrUnexpectedWithdrawals = errors.New("unexpected withdrawals")
)
4 changes: 2 additions & 2 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ func (g *Genesis) ToBlock() *types.Block {
var withdrawals []*types.Withdrawal

if g.Config != nil && g.Config.IsShanghai(new(big.Int).SetUint64(g.Number)) {
head.WithdrawalsHash = &types.EmptyWithdrawalsHash
withdrawals = make([]*types.Withdrawal, 0)
head.WithdrawalsHash = nil
withdrawals = nil
}

return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)).WithWithdrawals(withdrawals)
Expand Down
6 changes: 5 additions & 1 deletion core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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")
}
// Bor does not support withdrawals
if withdrawals != nil {
withdrawals = nil
}
// 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)

Expand Down
15 changes: 9 additions & 6 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,15 @@ func newShanghaiInstructionSet() JumpTable {

func newMergeInstructionSet() JumpTable {
instructionSet := newLondonInstructionSet()
instructionSet[PREVRANDAO] = &operation{
execute: opRandom,
constantGas: GasQuickStep,
minStack: minStack(0, 1),
maxStack: maxStack(0, 1),
}

// disabling in pos due to incompatibility with prevrandao

// instructionSet[PREVRANDAO] = &operation{
// execute: opRandom,
// constantGas: GasQuickStep,
// minStack: minStack(0, 1),
// maxStack: maxStack(0, 1),
// }

return validate(instructionSet)
}
Expand Down
6 changes: 6 additions & 0 deletions eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@
// both the pending block as well as the pending state from
// the miner and operate on those
_, stateDb := api.eth.miner.Pending()
if stateDb == nil {
return state.Dump{}, errors.New("pending state is not available")
}

Check warning on line 282 in eth/api.go

View check run for this annotation

Codecov / codecov/patch

eth/api.go#L280-L282

Added lines #L280 - L282 were not covered by tests
return stateDb.RawDump(opts), nil
}

Expand Down Expand Up @@ -385,6 +388,9 @@
// both the pending block as well as the pending state from
// the miner and operate on those
_, stateDb = api.eth.miner.Pending()
if stateDb == nil {
return state.IteratorDump{}, errors.New("pending state is not available")
}

Check warning on line 393 in eth/api.go

View check run for this annotation

Codecov / codecov/patch

eth/api.go#L391-L393

Added lines #L391 - L393 were not covered by tests
} else {
var header *types.Header
if number == rpc.LatestBlockNumber {
Expand Down
9 changes: 9 additions & 0 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
// Pending block is only known by the miner
if number == rpc.PendingBlockNumber {
block := b.eth.miner.PendingBlock()
if block == nil {
return nil, errors.New("pending block is not available")
}

Check warning on line 73 in eth/api_backend.go

View check run for this annotation

Codecov / codecov/patch

eth/api_backend.go#L71-L73

Added lines #L71 - L73 were not covered by tests
return block.Header(), nil
}
// Otherwise resolve and return the block
Expand Down Expand Up @@ -136,6 +139,9 @@
// Pending block is only known by the miner
if number == rpc.PendingBlockNumber {
block := b.eth.miner.PendingBlock()
if block == nil {
return nil, errors.New("pending block is not available")
}

Check warning on line 144 in eth/api_backend.go

View check run for this annotation

Codecov / codecov/patch

eth/api_backend.go#L142-L144

Added lines #L142 - L144 were not covered by tests
return block, nil
}
// Otherwise resolve and return the block
Expand Down Expand Up @@ -217,6 +223,9 @@
// Pending state is only known by the miner
if number == rpc.PendingBlockNumber {
block, state := b.eth.miner.Pending()
if block == nil || state == nil {
return nil, nil, errors.New("pending state is not available")
}

Check warning on line 228 in eth/api_backend.go

View check run for this annotation

Codecov / codecov/patch

eth/api_backend.go#L226-L228

Added lines #L226 - L228 were not covered by tests
return state, block.Header(), nil
}
// Otherwise resolve the block number and return its state
Expand Down
3 changes: 3 additions & 0 deletions eth/filters/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@
// pendingLogs returns the logs matching the filter criteria within the pending block.
func (f *Filter) pendingLogs() ([]*types.Log, error) {
block, receipts := f.sys.backend.PendingBlockAndReceipts()
if block == nil || receipts == nil {
return nil, errors.New("pending block is not available")
}

Check warning on line 333 in eth/filters/filter.go

View check run for this annotation

Codecov / codecov/patch

eth/filters/filter.go#L331-L333

Added lines #L331 - L333 were not covered by tests
if bloomFilter(block.Bloom(), f.addresses, f.topics) {
var unfiltered []*types.Log
for _, r := range receipts {
Expand Down
6 changes: 1 addition & 5 deletions eth/protocols/eth/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,7 @@ func TestGetBlockBodies68(t *testing.T) {
func testGetBlockBodies(t *testing.T, protocol uint) {
gen := func(n int, g *core.BlockGen) {
if n%2 == 0 {
w := &types.Withdrawal{
Address: common.Address{0xaa},
Amount: 42,
}
g.AddWithdrawal(w)
g.AddWithdrawal(&types.Withdrawal{})
}
}

Expand Down
6 changes: 3 additions & 3 deletions internal/cli/server/chains/mumbai.go

Large diffs are not rendered by default.

Loading
Loading