Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file configures github.com/golangci/golangci-lint.
version: '2'
run:
go: '1.26.1'
go: '1.26.2'
tests: true
linters:
default: none
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ─── BUILDER STAGE ───────────────────────────────────────────────────────────────
FROM golang:1.26.1-alpine AS builder
FROM golang:1.26.2-alpine AS builder

ARG BOR_DIR=/var/lib/bor/
ENV BOR_DIR=$BOR_DIR
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alltools
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build Geth in a stock Go builder container
FROM golang:1.26.1-alpine AS builder
FROM golang:1.26.2-alpine AS builder

RUN apk add --no-cache make gcc musl-dev linux-headers git

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ lint:

lint-deps:
rm -f ./build/bin/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v2.11.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v2.11.4

.PHONY: vulncheck

Expand Down
2 changes: 1 addition & 1 deletion cmd/keeper/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ethereum/go-ethereum/cmd/keeper

go 1.26.1
go 1.26.2

require (
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20260104020744-7268a54d0358
Expand Down
4 changes: 2 additions & 2 deletions cmd/keeper/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
Expand Down
9 changes: 6 additions & 3 deletions consensus/beacon/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (beacon *Beacon) Prepare(chain consensus.ChainHeaderReader, header *types.H
}

// Finalize implements consensus.Engine and processes withdrawals on top.
func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state vm.StateDB, body *types.Body, receipts []*types.Receipt) []*types.Receipt {
func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state vm.StateDB, body *types.Body, receipts []*types.Receipt) ([]*types.Receipt, error) {
if !beacon.IsPoSHeader(header) {
return beacon.ethone.Finalize(chain, header, state, body, receipts)
}
Expand All @@ -362,7 +362,7 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.
state.AddBalance(w.Address, amount, tracing.BalanceIncreaseWithdrawal)
}
// No block reward which is issued by consensus layer instead.
return receipts
return receipts, nil
}

// FinalizeAndAssemble implements consensus.Engine, setting the final state and
Expand All @@ -384,7 +384,10 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
}
}
// Finalize and assemble the block.
receipts = beacon.Finalize(chain, header, state, body, receipts)
receipts, err := beacon.Finalize(chain, header, state, body, receipts)
if err != nil {
return nil, nil, 0, err
}

// Assign the final state root to header.
start := time.Now()
Expand Down
69 changes: 39 additions & 30 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,37 +1173,35 @@

// Finalize implements consensus.Engine, ensuring no uncles are set, nor block
// rewards given.
func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header, wrappedState vm.StateDB, body *types.Body, receipts []*types.Receipt) []*types.Receipt {
headerNumber := header.Number.Uint64()
func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header, wrappedState vm.StateDB, body *types.Body, receipts []*types.Receipt) ([]*types.Receipt, error) {

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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=0xPolygon_bor&issues=AZ26ww4TAgo0a9BP_B_y&open=AZ26ww4TAgo0a9BP_B_y&pullRequest=2195
// Reject the block if it has withdrawals or requests
if body.Withdrawals != nil || header.WithdrawalsHash != nil {
return nil
return nil, consensus.ErrUnexpectedWithdrawals
}
if header.RequestsHash != nil {
return nil
return nil, consensus.ErrUnexpectedRequests
}

var (
headerNumber = header.Number.Uint64()
stateSyncData []*types.StateSyncData
err error
)

if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
start := time.Now()
cx := statefull.ChainContext{Chain: chain, Bor: c}
// check and commit span
if !c.config.IsRio(header.Number) {
if err := c.checkAndCommitSpan(wrappedState, header, cx); err != nil {
log.Error("Error while committing span", "error", err)
return nil
return nil, fmt.Errorf("error while committing span: %w", err)
}
}

if c.HeimdallClient != nil {
// commit states
stateSyncData, err = c.CommitStates(wrappedState, header, cx)
if err != nil {
log.Error("Error while committing states", "error", err)
return nil
return nil, fmt.Errorf("%w: error while committing states: %w", core.ErrStateSyncProcessing, err)
}
}
// Get the underlying state for updating consensus time
Expand All @@ -1215,31 +1213,42 @@
// the wrapped state here as it may have a hooked state db instance which can help
// in tracing if it's enabled.
if err = c.changeContractCodeIfNeeded(headerNumber, wrappedState); err != nil {
log.Error("Error changing contract code", "error", err)
return nil
return nil, fmt.Errorf("error changing contract code: %w", err)
}

if len(stateSyncData) > 0 && c.config != nil && c.config.IsMadhugiri(header.Number) {
if len(body.Transactions) > 0 {
// Craft a state-sync tx to validate it against the tx in block body
stateSyncTx := types.NewTx(&types.StateSyncTx{
StateSyncData: stateSyncData,
})
lastTx := body.Transactions[len(body.Transactions)-1]
if stateSyncTx.Hash() != lastTx.Hash() {
log.Error("Invalid state-sync tx in block body", "got", lastTx.Hash(), "want", stateSyncTx.Hash())
return receipts
}
if lastTx.Type() == types.StateSyncTxType {
receipts = insertStateSyncTransactionAndCalculateReceipt(lastTx, header, body, wrappedState, receipts)
}
}
} else {
// set state sync
hc := chain.(*core.HeaderChain)
// Set state-sync in any case
if hc, ok := chain.(*core.HeaderChain); ok {
hc.SetStateSync(stateSyncData)
}
Comment thread
manav2401 marked this conversation as resolved.
return receipts

if len(stateSyncData) == 0 {
return receipts, nil
}

txs := body.Transactions
isMadhugiri := c.config != nil && c.config.IsMadhugiri(header.Number)

// Pre-Madhugiri, state-sync transactions were not included in block body so we can safely return
if !isMadhugiri {
return receipts, nil
}

// Reject the block as heimdall suggests presence of state-sync event(s) but state-sync
// transaction is missing from block body.
if len(txs) == 0 || txs[len(txs)-1].Type() != types.StateSyncTxType {
return nil, fmt.Errorf("%w: block body missing state-sync transaction, heimdall reported %d event(s)", core.ErrStateSyncMismatch, len(stateSyncData))
}

// Craft a state-sync tx to validate it against the tx in block body
stateSyncTx := types.NewTx(&types.StateSyncTx{
StateSyncData: stateSyncData,
})
lastTx := txs[len(txs)-1]
if stateSyncTx.Hash() != lastTx.Hash() {
return nil, fmt.Errorf("%w: hash mismatch, got %s want %s", core.ErrStateSyncMismatch, lastTx.Hash(), stateSyncTx.Hash())
}
receipts = insertStateSyncTransactionAndCalculateReceipt(lastTx, header, body, wrappedState, receipts)
return receipts, nil
}

func insertStateSyncTransactionAndCalculateReceipt(stateSyncTx *types.Transaction, header *types.Header, body *types.Body, state vm.StateDB, receipts []*types.Receipt) []*types.Receipt {
Expand Down
Loading
Loading