Skip to content
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9fb360a
enabling pip-66 back and wait moved from seal to prepare
lucca30 Jan 21, 2026
2d9b1d3
Merge remote-tracking branch 'origin/develop' into lmartins/prefetch-…
lucca30 Jan 21, 2026
bc76b7e
bring subsecond extra time
lucca30 Jan 21, 2026
0c3f571
prefetch from pool
lucca30 Jan 29, 2026
2a743d6
more prefetch metrics
lucca30 Jan 30, 2026
78d008e
address early announcement for rio blocks
lucca30 Jan 30, 2026
11cae51
separate worker cache metrics
lucca30 Jan 30, 2026
adf4550
optinal flag to disable prefetch
lucca30 Jan 30, 2026
fdad6b8
prefetch gas limit flag
lucca30 Jan 30, 2026
51b2b13
tests and lint
lucca30 Feb 2, 2026
77e352d
small fixes
lucca30 Feb 2, 2026
ccd460e
remove logs
lucca30 Feb 2, 2026
d1023f1
Merge remote-tracking branch 'origin/develop' into lmartins/prefetch-…
lucca30 Feb 2, 2026
f6374ae
address duplicates
lucca30 Feb 2, 2026
0077186
small fix on integration test
lucca30 Feb 2, 2026
254f2a9
prefetch coverage histogram and fmt
lucca30 Feb 2, 2026
f37b23c
verify headers coverage and bor test resiliency
lucca30 Feb 2, 2026
94393f4
address duplicates
lucca30 Feb 2, 2026
6acb9e1
duplicates and lint
lucca30 Feb 2, 2026
595e87f
addressing comments
lucca30 Feb 3, 2026
89c5a24
small fix
lucca30 Feb 3, 2026
f845105
Merge remote-tracking branch 'origin/develop' into lmartins/prefetch-…
lucca30 Feb 5, 2026
f9a5e84
address comments
lucca30 Feb 9, 2026
8621289
Merge remote-tracking branch 'origin/develop' into lmartins/prefetch-…
lucca30 Feb 9, 2026
cbcd5b0
fix push tx for rpc nodes
lucca30 Feb 9, 2026
9bf8cd9
Merge remote-tracking branch 'origin/develop' into lmartins/prefetch-…
lucca30 Feb 10, 2026
bc96b0c
rename meter and intermediateroot prefetch
lucca30 Feb 10, 2026
db4b552
Merge remote-tracking branch 'origin/develop' into lmartins/prefetch-…
lucca30 Feb 10, 2026
55527aa
address lint
lucca30 Feb 10, 2026
7eb0a10
address succession number check
lucca30 Feb 10, 2026
422610b
fixing concurrency issues and tests for prefetch state being thrown a…
lucca30 Feb 11, 2026
10cd923
make lint
lucca30 Feb 11, 2026
0f0db27
e2e worker tests
lucca30 Feb 11, 2026
e04854e
benchmark tests
lucca30 Feb 11, 2026
93f9626
worker tests fixed and interrupt watch while waiting
lucca30 Feb 11, 2026
06b773a
remove parallel from tests
lucca30 Feb 11, 2026
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: 6 additions & 6 deletions accounts/abi/bind/v2/dep_tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func TestContractLinking(t *testing.T) {
},
},
// test two contracts can be deployed which don't share deps
linkTestCaseInput{
{
map[rune][]rune{
'a': {'b', 'c', 'd', 'e'},
'f': {'g', 'h', 'i', 'j'}},
Expand All @@ -297,7 +297,7 @@ func TestContractLinking(t *testing.T) {
},
},
// test two contracts can be deployed which share deps
linkTestCaseInput{
{
map[rune][]rune{
'a': {'b', 'c', 'd', 'e'},
'f': {'g', 'c', 'd', 'h'}},
Expand All @@ -307,31 +307,31 @@ func TestContractLinking(t *testing.T) {
},
},
// test one contract with overrides for all lib deps
linkTestCaseInput{
{
map[rune][]rune{
'a': {'b', 'c', 'd', 'e'}},
map[rune]struct{}{'b': {}, 'c': {}, 'd': {}, 'e': {}},
map[rune]struct{}{
'a': {}},
},
// test one contract with overrides for some lib deps
linkTestCaseInput{
{
map[rune][]rune{
'a': {'b', 'c'}},
map[rune]struct{}{'b': {}, 'c': {}},
map[rune]struct{}{
'a': {}},
},
// test deployment of a contract with overrides
linkTestCaseInput{
{
map[rune][]rune{
'a': {}},
map[rune]struct{}{'a': {}},
map[rune]struct{}{},
},
// two contracts ('a' and 'f') share some dependencies. contract 'a' is marked as an override. expect that any of
// its dependencies that aren't shared with 'f' are not deployed.
linkTestCaseInput{map[rune][]rune{
{map[rune][]rune{
'a': {'b', 'c', 'd', 'e'},
'f': {'g', 'c', 'd', 'h'}},
map[rune]struct{}{'a': {}},
Expand Down
1 change: 0 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ var (
Usage: "0x prefixed public address for the pending block producer (not used for actual block production)",
Category: flags.MinerCategory,
}

// Account settings
PasswordFileFlag = &cli.PathFlag{
Name: "password",
Expand Down
4 changes: 2 additions & 2 deletions consensus/beacon/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,14 @@ func (beacon *Beacon) verifyHeaders(chain consensus.ChainHeaderReader, headers [

// Prepare implements consensus.Engine, initializing the difficulty field of a
// header to conform to the beacon protocol. The changes are done inline.
func (beacon *Beacon) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error {
func (beacon *Beacon) Prepare(chain consensus.ChainHeaderReader, header *types.Header, waitOnPrepare bool) error {
// Transition isn't triggered yet, use the legacy rules for preparation.
reached, err := IsTTDReached(chain, header.ParentHash, header.Number.Uint64()-1)
if err != nil {
return err
}
if !reached {
return beacon.ethone.Prepare(chain, header)
return beacon.ethone.Prepare(chain, header, waitOnPrepare)
}
header.Difficulty = beaconDifficulty
return nil
Expand Down
71 changes: 57 additions & 14 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,30 @@
number := header.Number.Uint64()
now := uint64(time.Now().Unix())

// Allow early blocks if Bhilai HF is enabled
if c.config.IsBhilai(header.Number) {
if c.config.IsRio(header.Number) {
// Rio HF introduced flexible blocktime (can be set larger than consensus without approval).
// Using strict CalcProducerDelay would reject valid blocks, so we just ensure announcement
// time comes after parent time to allow for flexible blocktime.
var parent *types.Header

if len(parents) > 0 {
parent = parents[len(parents)-1]
} else {
parent = chain.GetHeader(header.ParentHash, number-1)
}
if parent == nil || now < parent.Time {
log.Error("Block announced too early post rio", "number", number, "headerTime", header.Time, "now", now)
return consensus.ErrFutureBlock
}
} else if c.config.IsBhilai(header.Number) {
// Allow early blocks if Bhilai HF is enabled
// Don't waste time checking blocks from the future but allow a buffer of block time for
// early block announcements. Note that this is a loose check and would allow early blocks
// from non-primary producer. Such blocks will be rejected later when we know the succession
// number of the signer in the current sprint.
if header.Time-c.config.CalculatePeriod(number) > now {
// Uses CalcProducerDelay instead of block period to account for producer delay on sprint start blocks.
// We assume succession 0 (primary producer) to not be much restrictive for early block announcements.
if header.Time-CalcProducerDelay(number, 0, c.config) > now {
log.Error("Block announced too early post bhilai", "number", number, "headerTime", header.Time, "now", now)
return consensus.ErrFutureBlock
}
Expand Down Expand Up @@ -476,7 +493,18 @@
return err
}

c.recentVerifiedHeaders.Set(header.Hash(), header, ttlcache.DefaultTTL)
// Calculate TTL for the header cache entry
// If the header time is in the future (early announced block), add extra time to TTL
cacheTTL := veblopBlockTimeout
nowTime := time.Now()
headerTime := time.Unix(int64(header.Time), 0)
if headerTime.After(nowTime) {
// Add the time from now until header time as extra to the base timeout
extraTime := headerTime.Sub(nowTime)
cacheTTL = veblopBlockTimeout + extraTime
}

c.recentVerifiedHeaders.Set(header.Hash(), header, cacheTTL)
return nil
}

Expand Down Expand Up @@ -928,7 +956,7 @@

// Prepare implements consensus.Engine, preparing all the consensus fields of the
// header for running the transactions on top.
func (c *Bor) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error {
func (c *Bor) Prepare(chain consensus.ChainHeaderReader, header *types.Header, waitOnPrepare bool) error {
// If the block isn't a checkpoint, cast a random vote (good enough for now)
header.Coinbase = common.Address{}
header.Nonce = types.BlockNonce{}
Expand Down Expand Up @@ -1026,6 +1054,8 @@
return fmt.Errorf("the floor of custom mining block time (%v) is less than the consensus block time: %v < %v", c.blockTime, c.blockTime.Seconds(), c.config.CalculatePeriod(number))
}

var delay time.Duration

if c.blockTime > 0 && c.config.IsRio(header.Number) {
// Only enable custom block time for Rio and later

Expand All @@ -1043,14 +1073,16 @@
actualNewBlockTime := parentActualBlockTime.Add(c.blockTime)
header.Time = uint64(actualNewBlockTime.Unix())
header.ActualTime = actualNewBlockTime
delay = time.Until(parentActualBlockTime)
} else {
header.Time = parent.Time + CalcProducerDelay(number, succession, c.config)
delay = time.Until(time.Unix(int64(parent.Time), 0))
}

now := time.Now()
if header.Time < uint64(now.Unix()) {
additionalBlockTime := time.Duration(c.config.CalculatePeriod(number)) * time.Second
if c.blockTime > 0 {
if c.blockTime > 0 && c.config.IsRio(header.Number) {
additionalBlockTime = c.blockTime
}
header.Time = uint64(now.Add(additionalBlockTime).Unix())
Expand All @@ -1059,6 +1091,23 @@
}
}

// Wait before start the block production if needed (previsously this wait was on Seal)
if c.config.IsBhilai(header.Number) && waitOnPrepare {
var successionNumber int
// if signer is not empty (RPC nodes have empty signer)
if currentSigner.signer != (common.Address{}) {
var err error
successionNumber, err = snap.GetSignerSuccessionNumber(currentSigner.signer)
if err != nil {
return err
}
if successionNumber == 0 {
<-time.After(delay)
}
}

}

Check failure on line 1109 in consensus/bor/bor.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-22.04)

unnecessary trailing newline (whitespace)

return nil
}

Expand Down Expand Up @@ -1323,14 +1372,8 @@
var delay time.Duration

// Sweet, the protocol permits us to sign the block, wait for our time
if c.config.IsBhilai(header.Number) {
delay = time.Until(header.GetActualTime()) // Wait until we reach header time for non-primary validators
// Disable early block announcement
// if successionNumber == 0 {
// // For primary producers, set the delay to `header.Time - block time` instead of `header.Time`
// // for early block announcement instead of waiting for full block time.
// delay = time.Until(time.Unix(int64(header.Time-c.config.CalculatePeriod(number)), 0))
// }
if c.config.IsBhilai(header.Number) && successionNumber == 0 {
delay = 0 // delay was moved to Prepare for bhilai and later
} else {
delay = time.Until(header.GetActualTime()) // Wait until we reach header time
}
Expand Down
Loading
Loading