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
10 changes: 2 additions & 8 deletions core/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,11 @@ func CalcGasLimit(parentGasLimit, desiredLimit uint64) uint64 {
}
// If we're outside our allowed gas range, we try to hone towards them
if limit < desiredLimit {
limit = parentGasLimit + delta
if limit > desiredLimit {
limit = desiredLimit
}
limit = min(parentGasLimit+delta, desiredLimit)
return limit
}
if limit > desiredLimit {
limit = parentGasLimit - delta
if limit < desiredLimit {
limit = desiredLimit
}
limit = max(parentGasLimit-delta, desiredLimit)
}
return limit
}
10 changes: 2 additions & 8 deletions core/bloombits/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,8 @@ func (m *Matcher) Start(ctx context.Context, begin, end uint64, results chan uin
// Calculate the first and last blocks of the section
sectionStart := res.section * m.sectionSize

first := sectionStart
if begin > first {
first = begin
}
last := sectionStart + m.sectionSize - 1
if end < last {
last = end
}
first := max(begin, sectionStart)
last := min(end, sectionStart+m.sectionSize-1)
// Iterate over all the blocks in the section and return the matching ones
for i := first; i <= last; i++ {
// Skip the entire byte if no matches are found inside (and we're processing an entire byte!)
Expand Down
9 changes: 3 additions & 6 deletions core/chain_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,9 @@ func (c *ChainIndexer) AddChildIndexer(indexer *ChainIndexer) {
c.children = append(c.children, indexer)

// Cascade any pending updates to new children too
sections := c.storedSections
if c.knownSections < sections {
// if a section is "stored" but not "known" then it is a checkpoint without
// available chain data so we should not cascade it yet
sections = c.knownSections
}
// if a section is "stored" but not "known" then it is a checkpoint without
// available chain data so we should not cascade it yet
sections := min(c.knownSections, c.storedSections)
if sections > 0 {
indexer.newHead(sections*c.sectionSize-1, false)
}
Expand Down
5 changes: 1 addition & 4 deletions core/state/access_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,7 @@ func (ae *AccessEvents) CodeChunksRangeGas(contractAddr common.Address, startPC,
return 0
}

endPC := startPC + size
if endPC > codeLen {
endPC = codeLen
}
endPC := min(startPC+size, codeLen)
if endPC > 0 {
endPC -= 1 // endPC is the last bytecode that will be touched.
}
Expand Down
5 changes: 1 addition & 4 deletions core/txindexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ func (indexer *txIndexer) run(tail *uint64, head uint64, stop chan struct{}, don
// It can happen when chain is rewound to a historical point which
// is even lower than the indexes tail, recap the indexing target
// to new head to avoid reading non-existent block bodies.
end := *tail
if end > head+1 {
end = head + 1
}
end := min(*tail, head+1)
rawdb.IndexTransactions(indexer.db, 0, end, stop, true)
}
return
Expand Down
10 changes: 2 additions & 8 deletions core/txpool/blobpool/evictheap.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,8 @@ func (h *evictHeap) Less(i, j int) bool {
lastI := txsI[len(txsI)-1]
lastJ := txsJ[len(txsJ)-1]

prioI := evictionPriority(h.basefeeJumps, lastI.evictionExecFeeJumps, h.blobfeeJumps, lastI.evictionBlobFeeJumps)
if prioI > 0 {
prioI = 0
}
prioJ := evictionPriority(h.basefeeJumps, lastJ.evictionExecFeeJumps, h.blobfeeJumps, lastJ.evictionBlobFeeJumps)
if prioJ > 0 {
prioJ = 0
}
prioI := min(evictionPriority(h.basefeeJumps, lastI.evictionExecFeeJumps, h.blobfeeJumps, lastI.evictionBlobFeeJumps), 0)
prioJ := min(evictionPriority(h.basefeeJumps, lastJ.evictionExecFeeJumps, h.blobfeeJumps, lastJ.evictionBlobFeeJumps), 0)
if prioI == prioJ {
return lastI.evictionExecTip.Lt(lastJ.evictionExecTip)
}
Expand Down
10 changes: 2 additions & 8 deletions core/vm/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ func getData(data []byte, start uint64, size uint64) []byte {
if start > length {
start = length
}
end := start + size
if end > length {
end = length
}
end := min(start+size, length)
return common.RightPadBytes(data[start:end], int(size))
}

Expand All @@ -69,10 +66,7 @@ func getDataAndAdjustedBounds(data []byte, start uint64, size uint64) (codeCopyP
if start > length {
start = length
}
end := start + size
if end > length {
end = length
}
end := min(start+size, length)
return common.RightPadBytes(data[start:end], int(size)), start, end - start
}

Expand Down
5 changes: 1 addition & 4 deletions core/vm/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ func benchmarkPrecompiled(addr string, test precompiledTest, bench *testing.B) {
res, _, err = RunPrecompiledContract(p, data, reqGas, nil)
}
bench.StopTimer()
elapsed := uint64(time.Since(start))
if elapsed < 1 {
elapsed = 1
}
elapsed := max(uint64(time.Since(start)), 1)
gasUsed := reqGas * uint64(bench.N)
bench.ReportMetric(float64(reqGas), "gas/op")
// Keep it as uint64, multiply 100 to get two digit float later
Expand Down