Skip to content
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# Changelog
## v1.6.3
### FEATURE
NA

### BUGFIX
[\#3429](https://github.com/bnb-chain/bsc/pull/3429) build(deps): bump github.com/consensys/gnark-crypto
[\#3433](https://github.com/bnb-chain/bsc/pull/3433) internal/ethapi: fix eth_simulateV1
[\#3431](https://github.com/bnb-chain/bsc/pull/3431) eth/tracers: fix crasher in TraceCall with BlockOverrides

### IMPROVEMENT
[\#3436](https://github.com/bnb-chain/bsc/pull/3436) revert: revert the nano check in parlia
[\#3435](https://github.com/bnb-chain/bsc/pull/3435) eth: fix stuck when handleBlockBroadcast

## v1.6.2
### FEATURE
Expand Down
19 changes: 0 additions & 19 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -1416,9 +1416,6 @@ func (p *Parlia) Finalize(chain consensus.ChainHeaderReader, header *types.Heade

systemcontracts.TryUpdateBuildInSystemContract(p.chainConfig, header.Number, parent.Time, header.Time, state, false)

if err := p.checkNanoBlackList(state, header); err != nil {
return err
}
if p.chainConfig.IsOnFeynman(header.Number, parent.Time, header.Time) {
err := p.initializeFeynmanContract(state, header, cx, txs, receipts, systemTxs, usedGas, false, tracer)
if err != nil {
Expand Down Expand Up @@ -1518,10 +1515,6 @@ func (p *Parlia) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *

systemcontracts.TryUpdateBuildInSystemContract(p.chainConfig, header.Number, parent.Time, header.Time, state, false)

if err := p.checkNanoBlackList(state, header); err != nil {
return nil, nil, err
}

if p.chainConfig.IsOnFeynman(header.Number, parent.Time, header.Time) {
err := p.initializeFeynmanContract(state, header, cx, &body.Transactions, &receipts, nil, &header.GasUsed, true, tracer)
if err != nil {
Expand Down Expand Up @@ -2434,18 +2427,6 @@ func (p *Parlia) NextProposalBlock(chain consensus.ChainHeaderReader, header *ty
return snap.nextProposalBlock(proposer)
}

func (p *Parlia) checkNanoBlackList(state vm.StateDB, header *types.Header) error {
if p.chainConfig.IsNano(header.Number) {
for _, blackListAddr := range types.NanoBlackList {
if state.IsAddressInMutations(blackListAddr) {
log.Error("blacklisted address found", "address", blackListAddr)
return fmt.Errorf("block contains blacklisted address: %s", blackListAddr.Hex())
}
}
}
return nil
}

func (p *Parlia) detectNewVersionWithFork(chain consensus.ChainHeaderReader, header *types.Header, state vm.StateDB) {
// Ignore blocks that are considered too old
const maxBlockReceiveDelay = 10 * time.Second
Expand Down
5 changes: 0 additions & 5 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1687,11 +1687,6 @@ func (s *StateDB) AccessEvents() *AccessEvents {
return s.accessEvents
}

func (s *StateDB) IsAddressInMutations(addr common.Address) bool {
_, ok := s.mutations[addr]
return ok
}

func (s *StateDB) DumpAccessList(block *types.Block) {
if s.blockAccessList == nil {
return
Expand Down
4 changes: 0 additions & 4 deletions core/state/statedb_hooked.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,3 @@ func (s *hookedStateDB) Finalise(deleteEmptyObjects bool) {
func (s *hookedStateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
return s.inner.IntermediateRoot(deleteEmptyObjects)
}

func (s *hookedStateDB) IsAddressInMutations(addr common.Address) bool {
return s.inner.IsAddressInMutations(addr)
}
2 changes: 0 additions & 2 deletions core/vm/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,4 @@ type StateDB interface {
// Finalise must be invoked at the end of a transaction
Finalise(bool)
IntermediateRoot(deleteEmptyObjects bool) common.Hash

IsAddressInMutations(addr common.Address) bool
}
6 changes: 5 additions & 1 deletion eth/handler_eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ func (h *ethHandler) handleBlockBroadcast(peer *eth.Peer, packet *eth.NewBlockPa
log.Debug("handleBlockBroadcast", "peer", peer.ID(), "block", block.Number(), "hash", block.Hash())
h.blockFetcher.Enqueue(peer.ID(), block)
stats := h.chain.GetBlockStats(block.Hash())
blockFirstReceived := false
if stats.RecvNewBlockTime.Load() == 0 {
blockFirstReceived = true
stats.RecvNewBlockTime.Store(time.Now().UnixMilli())
addr := peer.RemoteAddr()
if addr != nil {
Expand All @@ -166,7 +168,9 @@ func (h *ethHandler) handleBlockBroadcast(peer *eth.Peer, packet *eth.NewBlockPa
// Update the peer's total difficulty if better than the previous
if _, td := peer.Head(); trueTD.Cmp(td) > 0 {
peer.SetHead(trueHead, trueTD)
h.chainSync.handlePeerEvent()
if blockFirstReceived {
h.chainSync.handlePeerEvent()
}
}
return nil
}
8 changes: 4 additions & 4 deletions eth/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type chainSyncOp struct {
func newChainSyncer(handler *handler) *chainSyncer {
return &chainSyncer{
handler: handler,
peerEventCh: make(chan struct{}),
peerEventCh: make(chan struct{}, 10),
}
}

Expand Down Expand Up @@ -186,9 +186,9 @@ func (cs *chainSyncer) nextSyncOp() *chainSyncOp {
} else if op.td.Cmp(new(big.Int).Add(ourTD, common.Big2)) <= 0 { // common.Big2: difficulty of an in-turn block
// On BSC, blocks are produced much faster than on Ethereum.
// If the node is only slightly behind (e.g., 1 block), syncing is unnecessary.
// It's likely still processing broadcasted blocks or block hash announcements.
// In most cases, the node will catch up within 3 seconds.
time.Sleep(3 * time.Second)
// It's likely still processing broadcasted blocks(such as including a big tx) or block hash announcements.
// In most cases, the node will catch up within 2 seconds.
time.Sleep(2 * time.Second)

// Re-check local head to see if it has caught up
if _, latestTD := cs.modeAndLocalHead(); ourTD.Cmp(latestTD) < 0 {
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc

// Apply the customization rules if required.
if config != nil {
if config.BlockOverrides != nil && config.BlockOverrides.Number.ToInt().Uint64() == h.Number.Uint64()+1 {
if config.BlockOverrides != nil && config.BlockOverrides.Number != nil && config.BlockOverrides.Number.ToInt().Uint64() == h.Number.Uint64()+1 {
// Overriding the block number to n+1 is a common way for wallets to
// simulate transactions, however without the following fix, a contract
// can assert it is being simulated by checking if blockhash(n) == 0x0 and
Expand Down
14 changes: 14 additions & 0 deletions eth/tracers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,20 @@ func TestTraceCall(t *testing.T) {
{"pc":0,"op":"NUMBER","gas":24946984,"gasCost":2,"depth":1,"stack":[]},
{"pc":1,"op":"STOP","gas":24946982,"gasCost":0,"depth":1,"stack":["0x1337"]}]}`,
},
// Tests issue #33014 where accessing nil block number override panics.
{
blockNumber: rpc.BlockNumber(0),
call: ethapi.TransactionArgs{
From: &accounts[0].addr,
To: &accounts[1].addr,
Value: (*hexutil.Big)(big.NewInt(1000)),
},
config: &TraceCallConfig{
BlockOverrides: &override.BlockOverrides{},
},
expectErr: nil,
expect: `{"gas":21000,"failed":false,"returnValue":"0x","structLogs":[]}`,
},
}
for i, testspec := range testSuite {
result, err := api.TraceCall(context.Background(), testspec.call, rpc.BlockNumberOrHash{BlockNumber: &testspec.blockNumber}, testspec.config)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/cloudflare/cloudflare-go v0.114.0
github.com/cockroachdb/pebble v1.1.5
github.com/cometbft/cometbft v0.37.0
github.com/consensys/gnark-crypto v0.18.0
github.com/consensys/gnark-crypto v0.18.1
github.com/crate-crypto/go-eth-kzg v1.3.0
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a
github.com/crate-crypto/go-kzg-4844 v1.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo=
github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0=
github.com/consensys/gnark-crypto v0.18.0 h1:vIye/FqI50VeAr0B3dx+YjeIvmc3LWz4yEfbWBpTUf0=
github.com/consensys/gnark-crypto v0.18.0/go.mod h1:L3mXGFTe1ZN+RSJ+CLjUt9x7PNdx8ubaYfDROyp2Z8c=
github.com/consensys/gnark-crypto v0.18.1 h1:RyLV6UhPRoYYzaFnPQA4qK3DyuDgkTgskDdoGqFt3fI=
github.com/consensys/gnark-crypto v0.18.1/go.mod h1:L3mXGFTe1ZN+RSJ+CLjUt9x7PNdx8ubaYfDROyp2Z8c=
github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE=
github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM=
github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw=
Expand Down
14 changes: 13 additions & 1 deletion internal/ethapi/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/ethereum/go-ethereum/internal/ethapi/override"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/trie"
)

const (
Expand Down Expand Up @@ -371,7 +372,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
}
blockBody := &types.Body{Transactions: txes, Withdrawals: *block.BlockOverrides.Withdrawals}
chainHeadReader := &simChainHeadReader{ctx, sim.b}
b, _, err := sim.b.Engine().FinalizeAndAssemble(chainHeadReader, header, sim.state, blockBody, receipts, nil)
b, err := sim.FinalizeAndAssemble(chainHeadReader, header, sim.state, blockBody, receipts)
if err != nil {
return nil, nil, nil, err
}
Expand Down Expand Up @@ -527,6 +528,17 @@ func (sim *simulator) newSimulatedChainContext(ctx context.Context, headers []*t
return NewChainContext(ctx, &simBackend{base: sim.base, b: sim.b, headers: headers})
}

func (sim *simulator) FinalizeAndAssemble(chain *simChainHeadReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) {
header.Root = sim.state.IntermediateRoot(true)
if sim.chainConfig.IsShanghai(header.Number, header.Time) {
if body.Withdrawals == nil {
body.Withdrawals = make([]*types.Withdrawal, 0)
}
}
block := types.NewBlock(header, body, receipts, trie.NewStackTrie(nil))
return block, nil
}

type simBackend struct {
b ChainContextBackend
base *types.Header
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ package version
const (
Major = 1 // Major version component of the current release
Minor = 6 // Minor version component of the current release
Patch = 2 // Patch version component of the current release
Patch = 3 // Patch version component of the current release
Meta = "" // Version metadata to append to the version string
)
Loading