Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0825b78
chore(customrawdb): delete customrawdb package and switch to avalanch…
powerslider Oct 6, 2025
8e3eed4
style: fix linter errors
powerslider Oct 6, 2025
6cef42d
Merge branch 'master' into powerslider/1779-delete-customrawdb-package
powerslider Oct 6, 2025
1828a89
fix: update avalanchego version
powerslider Oct 6, 2025
0d5eb51
fix: patch calls to ReadChainConfig and WriteChainConfig
powerslider Oct 6, 2025
527c0de
fix(network,core): adapt to avalanchego APIs, fix metrics clash, stab…
powerslider Oct 6, 2025
b6d83ca
fix: gci lint issue and image build issue
powerslider Oct 6, 2025
198db42
Merge branch 'master' into powerslider/1779-delete-customrawdb-package
powerslider Oct 6, 2025
6f0e847
fix(core): use attached extras with avalanchego customrawdb in genesis
powerslider Oct 6, 2025
a313b3e
fix: clean build context and support no-cache builds to avoid stale f…
powerslider Oct 6, 2025
517b563
fix(core/genesis): persist upgrade bytes before compat checks
powerslider Oct 6, 2025
1d2a414
Merge branch 'master' into powerslider/1779-delete-customrawdb-package
powerslider Oct 6, 2025
4304438
fix(core/genesis): more fixes
powerslider Oct 6, 2025
5a5b126
fix(core, docker, scripts): robust genesis compat handling, isolate l…
powerslider Oct 6, 2025
e9ecb8c
build(docker): simplify local avalanchego handling in Dockerfile
powerslider Oct 7, 2025
de29368
Merge branch 'master' into powerslider/1779-delete-customrawdb-package
powerslider Oct 7, 2025
68faeea
sync: coreth PR #1214: ci: update taskfile for rlpgen (#1760)
JonathanOppenheimer Oct 7, 2025
1792a3a
sync: coreth PR #1217: have `checkPredicates` account for maximum ava…
JonathanOppenheimer Oct 7, 2025
e68d48d
sync: coreth PR #1188: fix test aggregation goroutine leak (#1783)
JonathanOppenheimer Oct 7, 2025
484a2fb
sync: coreth PR #1268: simplify test (#1786)
JonathanOppenheimer Oct 7, 2025
7c1de96
sync: coreth PR #1149: add precompile reversion logic for Granite act…
JonathanOppenheimer Oct 7, 2025
66110f0
Merge branch 'master' into powerslider/1779-delete-customrawdb-package
powerslider Oct 8, 2025
7a69418
chore: update to latest avalanchego version
powerslider Oct 8, 2025
f77a170
chore: update golang image to 1.24.8
powerslider Oct 8, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
- name: Setup Contracts
run: ./scripts/run_task.sh setup-contracts
- name: Run Warp E2E Tests
uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@84e9aebcfbc04602865f4c0a3e8b46a27409a3f5
uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@fff1df9564d3fa86899780d73e887d9ee5b9b54e
with:
run: ./scripts/run_task.sh test-e2e-warp-ci
artifact_prefix: warp
Expand All @@ -122,7 +122,7 @@ jobs:
with:
go-version-file: "go.mod"
- name: Run E2E Load Tests
uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@84e9aebcfbc04602865f4c0a3e8b46a27409a3f5
uses: ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd@fff1df9564d3fa86899780d73e887d9ee5b9b54e
with:
run: ./scripts/run_task.sh test-e2e-load-ci
artifact_prefix: load
Expand Down
26 changes: 19 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,35 @@
ARG AVALANCHEGO_NODE_IMAGE="invalid-image"

# ============= Compilation Stage ================
FROM --platform=$BUILDPLATFORM golang:1.24.7-bookworm AS builder
FROM --platform=$BUILDPLATFORM golang:1.24.8-bookworm AS builder

WORKDIR /build

# Copy avalanche dependencies first (intermediate docker image caching)
# Copy avalanchego directory if present (for manual CI case, which uses local dependency)
COPY go.mod go.sum avalanchego* ./
# Download avalanche dependencies using go mod
RUN go mod download && go mod tidy
# Copy module files first (improves Docker layer caching)
COPY go.mod go.sum ./
# Download module dependencies
RUN go mod download

# Copy the code into the container
COPY . .

# Ensure we never keep a stale local replace when no local module is present
RUN go mod edit -dropreplace github.com/ava-labs/avalanchego || true

# If a local avalanchego source dir is present, move it outside the module tree.
# Only add a replace if the moved directory is a standalone module with go.mod,
# otherwise drop any existing replace so upstream is used.
RUN if [ -d ./avalanchego ]; then \
mkdir -p /third_party && mv ./avalanchego /third_party/avalanchego; \
if [ -f /third_party/avalanchego/go.mod ]; then \
go mod edit -replace github.com/ava-labs/avalanchego=/third_party/avalanchego; \
go mod tidy; \
fi; \
fi

# Ensure pre-existing builds are not available for inclusion in the final image
RUN [ -d ./build ] && rm -rf ./build/* || true


ARG TARGETPLATFORM
ARG BUILDPLATFORM

Expand Down
20 changes: 10 additions & 10 deletions compatibility.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"rpcChainVMProtocolVersion": {
"v0.7.0": 38,
"v0.7.1": 39,
"v0.7.10": 43,
"v0.7.9": 43,
"v0.7.8": 43,
"v0.7.7": 42,
"v0.7.6": 42,
"v0.7.5": 41,
"v0.7.4": 40,
"v0.7.3": 39,
"v0.7.2": 39,
"v0.7.1": 39,
"v0.7.0": 38
"v0.7.3": 39,
"v0.7.4": 40,
"v0.7.5": 41,
"v0.7.6": 42,
"v0.7.7": 42,
"v0.7.8": 43,
"v0.7.9": 43
}
}
}
5 changes: 3 additions & 2 deletions core/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"math/big"
"testing"

"github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/common/math"
"github.com/ava-labs/libevm/core/rawdb"
Expand All @@ -42,7 +43,6 @@ import (
ethparams "github.com/ava-labs/libevm/params"
"github.com/ava-labs/subnet-evm/consensus/dummy"
"github.com/ava-labs/subnet-evm/params"
"github.com/ava-labs/subnet-evm/plugin/evm/customrawdb"
)

func BenchmarkInsertChain_empty_memdb(b *testing.B) {
Expand Down Expand Up @@ -253,7 +253,8 @@ func makeChainForBench(db ethdb.Database, genesis *Genesis, full bool, count uin
rawdb.WriteCanonicalHash(db, hash, n)

if n == 0 {
customrawdb.WriteChainConfig(db, hash, genesis.Config)
extra := params.GetExtra(genesis.Config)
customrawdb.WriteChainConfig(db, hash, genesis.Config, *extra)
}
rawdb.WriteHeadHeaderHash(db, hash)

Expand Down
2 changes: 1 addition & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"sync/atomic"
"time"

"github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/common/lru"
"github.com/ava-labs/libevm/consensus/misc/eip4844"
Expand All @@ -61,7 +62,6 @@ import (
"github.com/ava-labs/subnet-evm/internal/version"
"github.com/ava-labs/subnet-evm/params"
"github.com/ava-labs/subnet-evm/plugin/evm/customlogs"
"github.com/ava-labs/subnet-evm/plugin/evm/customrawdb"
"github.com/ava-labs/subnet-evm/plugin/evm/customtypes"
"github.com/ava-labs/subnet-evm/triedb/firewood"
"github.com/ava-labs/subnet-evm/triedb/hashdb"
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain_repair_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"math/big"
"testing"

"github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/core/rawdb"
"github.com/ava-labs/libevm/core/types"
Expand All @@ -44,7 +45,6 @@ import (
"github.com/ava-labs/libevm/triedb"
"github.com/ava-labs/subnet-evm/consensus/dummy"
"github.com/ava-labs/subnet-evm/params"
"github.com/ava-labs/subnet-evm/plugin/evm/customrawdb"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"

"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/core/rawdb"
"github.com/ava-labs/libevm/core/types"
Expand All @@ -22,7 +23,6 @@ import (
"github.com/ava-labs/subnet-evm/core/state/pruner"
"github.com/ava-labs/subnet-evm/params"
"github.com/ava-labs/subnet-evm/params/extras"
"github.com/ava-labs/subnet-evm/plugin/evm/customrawdb"
"github.com/ava-labs/subnet-evm/plugin/evm/upgrade/legacy"

ethparams "github.com/ava-labs/libevm/params"
Expand Down
114 changes: 90 additions & 24 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ import (
"errors"
"fmt"
"math/big"
"strings"
"time"

"github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/common/hexutil"
"github.com/ava-labs/libevm/common/math"
Expand All @@ -49,7 +51,6 @@ import (
"github.com/ava-labs/libevm/triedb"
"github.com/ava-labs/subnet-evm/core/extstate"
"github.com/ava-labs/subnet-evm/params"
"github.com/ava-labs/subnet-evm/plugin/evm/customrawdb"
"github.com/ava-labs/subnet-evm/plugin/evm/customtypes"
"github.com/ava-labs/subnet-evm/plugin/evm/upgrade/legacy"
"github.com/ava-labs/subnet-evm/triedb/pathdb"
Expand Down Expand Up @@ -177,25 +178,31 @@ func SetupGenesisBlock(
return genesis.Config, common.Hash{}, &GenesisMismatchError{stored, hash}
}
// Get the existing chain configuration.
newcfg := genesis.Config
if err := newcfg.CheckConfigForkOrder(); err != nil {
return newcfg, common.Hash{}, err
newCfg := genesis.Config
if err := newCfg.CheckConfigForkOrder(); err != nil {
return newCfg, common.Hash{}, err
}
storedcfg := customrawdb.ReadChainConfig(db, stored)

// Read stored config into a local extras copy to avoid mutating the
// caller's attached extras (which may be concurrently accessed in tests).
// We'll persist the new config (including upgrade bytes) using the attached
// extras below to ensure on-disk state is up to date.
readExtra := *params.GetExtra(newCfg)
storedCfg := customrawdb.ReadChainConfig(db, stored, &readExtra)
// If there is no previously stored chain config, write the chain config to disk.
if storedcfg == nil {
if storedCfg == nil {
// Note: this can happen since we did not previously write the genesis block and chain config in the same batch.
log.Warn("Found genesis block without chain config")
customrawdb.WriteChainConfig(db, stored, newcfg)
return newcfg, stored, nil
customrawdb.WriteChainConfig(db, stored, newCfg, *params.GetExtra(newCfg))
return newCfg, stored, nil
}

// Notes on the following line:
// - this is needed in coreth to handle the case where existing nodes do not
// have the Berlin or London forks initialized by block number on disk.
// See https://github.com/ava-labs/coreth/pull/667/files
// - this is not needed in subnet-evm but it does not impact it either
if err := params.SetEthUpgrades(storedcfg); err != nil {
if err := params.SetEthUpgrades(storedCfg); err != nil {
return genesis.Config, common.Hash{}, err
}
// Check config compatibility and write the config. Compatibility errors
Expand All @@ -208,25 +215,31 @@ func SetupGenesisBlock(
// when we start syncing from scratch, the last accepted block
// will be genesis block
if lastBlock == nil {
return newcfg, common.Hash{}, errors.New("missing last accepted block")
return newCfg, common.Hash{}, errors.New("missing last accepted block")
}
height := lastBlock.NumberU64()
timestamp := lastBlock.Time()
if skipChainConfigCheckCompatible {
log.Info("skipping verifying activated network upgrades on chain config")
} else {
compatErr := storedcfg.CheckCompatible(newcfg, height, timestamp)
if compatErr != nil && ((height != 0 && compatErr.RewindToBlock != 0) || (timestamp != 0 && compatErr.RewindToTime != 0)) {
storedData, _ := params.ToWithUpgradesJSON(storedcfg).MarshalJSON()
newData, _ := params.ToWithUpgradesJSON(newcfg).MarshalJSON()
log.Error("found mismatch between config on database vs. new config", "storedConfig", string(storedData), "newConfig", string(newData), "err", compatErr)
return newcfg, stored, compatErr

// If the chain hasn't advanced past genesis (height 0), persist the new
// chain config (including upgrade bytes) before compatibility checks so
// subsequent restarts see the updated upgrades and do not flag them as
// retroactive enables.
if height == 0 {
storedCfg = persistChainConfigAndReload(db, stored, newCfg)
}

if !skipChainConfigCheckCompatible {
if _, err := reconcileCompatibility(db, stored, storedCfg, newCfg, height, timestamp); err != nil {
logCompatibilityMismatch(storedCfg, newCfg, err)
return newCfg, stored, err
}
} else {
log.Info("skipping verifying activated network upgrades on chain config")
}
// Required to write the chain config to disk to ensure both the chain config and upgrade bytes are persisted to disk.
// Note: this intentionally removes an extra check from upstream.
customrawdb.WriteChainConfig(db, stored, newcfg)
return newcfg, stored, nil

// Persist the new chain config (including upgrade bytes) now that compatibility is verified.
customrawdb.WriteChainConfig(db, stored, newCfg, *params.GetExtra(newCfg))
return newCfg, stored, nil
}

// IsVerkle indicates whether the state is already stored in a verkle
Expand Down Expand Up @@ -401,7 +414,9 @@ func (g *Genesis) Commit(db ethdb.Database, triedb *triedb.Database) (*types.Blo
rawdb.WriteCanonicalHash(batch, block.Hash(), block.NumberU64())
rawdb.WriteHeadBlockHash(batch, block.Hash())
rawdb.WriteHeadHeaderHash(batch, block.Hash())
customrawdb.WriteChainConfig(batch, block.Hash(), config)

extra := params.GetExtra(config)
customrawdb.WriteChainConfig(batch, block.Hash(), config, *extra)
if err := batch.Write(); err != nil {
return nil, fmt.Errorf("failed to write genesis block: %w", err)
}
Expand Down Expand Up @@ -453,3 +468,54 @@ func ReadBlockByHash(db ethdb.Reader, hash common.Hash) *types.Block {
}
return rawdb.ReadBlock(db, hash, *blockNumber)
}

// reconcileCompatibility checks compatibility between the stored and new chain configs.
// If the only incompatibility is missing precompile upgrade metadata, it persists the
// new config (including upgrade bytes) and returns a refreshed stored config view.
// Otherwise, it returns the compatibility error.
func reconcileCompatibility(
db ethdb.Database,
genesisHash common.Hash,
storedCfg *params.ChainConfig,
newCfg *params.ChainConfig,
height uint64,
timestamp uint64,
) (*params.ChainConfig, error) {
compatErr := storedCfg.CheckCompatible(newCfg, height, timestamp)
needsRewind := compatErr != nil && ((height != 0 && compatErr.RewindToBlock != 0) || (timestamp != 0 && compatErr.RewindToTime != 0))
if !needsRewind {
return storedCfg, nil
}
if !isPrecompileUpgradeOnlyIncompatibility(compatErr) {
return nil, compatErr
}
// Only precompile upgrade metadata differs: write upgrades and proceed.
refreshed := persistChainConfigAndReload(db, genesisHash, newCfg)
return refreshed, nil
}

// persistChainConfigAndReload writes the provided chain config (including upgrade bytes)
// and returns a fresh view of the stored config using a separate extras copy.
func persistChainConfigAndReload(db ethdb.Database, genesisHash common.Hash, cfg *params.ChainConfig) *params.ChainConfig {
customrawdb.WriteChainConfig(db, genesisHash, cfg, *params.GetExtra(cfg))
refreshedExtra := *params.GetExtra(cfg)
return customrawdb.ReadChainConfig(db, genesisHash, &refreshedExtra)
}

// isPrecompileUpgradeOnlyIncompatibility returns true if the compatibility error
// pertains exclusively to precompile upgrade activation metadata being absent on disk.
// In such cases, persisting the new chain config (including upgrade bytes) resolves
// the mismatch without requiring a rewind.
func isPrecompileUpgradeOnlyIncompatibility(err *ethparams.ConfigCompatError) bool {
if err == nil {
return false
}
return strings.Contains(err.What, "PrecompileUpgrade[")
}

// logCompatibilityMismatch emits a structured error comparing stored and new configs.
func logCompatibilityMismatch(storedCfg, newCfg *params.ChainConfig, err error) {
storedData, _ := params.ToWithUpgradesJSON(storedCfg).MarshalJSON()
newData, _ := params.ToWithUpgradesJSON(newCfg).MarshalJSON()
log.Error("found mismatch between config on database vs. new config", "storedConfig", string(storedData), "newConfig", string(newData), "err", err)
}
2 changes: 1 addition & 1 deletion core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"reflect"
"testing"

"github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/core/rawdb"
"github.com/ava-labs/libevm/core/state"
Expand All @@ -48,7 +49,6 @@ import (
"github.com/ava-labs/subnet-evm/consensus/dummy"
"github.com/ava-labs/subnet-evm/params"
"github.com/ava-labs/subnet-evm/params/extras"
"github.com/ava-labs/subnet-evm/plugin/evm/customrawdb"
"github.com/ava-labs/subnet-evm/plugin/evm/upgrade/legacy"
"github.com/ava-labs/subnet-evm/precompile/allowlist"
"github.com/ava-labs/subnet-evm/precompile/contracts/deployerallowlist"
Expand Down
2 changes: 1 addition & 1 deletion core/state/pruner/pruner.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"strings"
"time"

"github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/core/rawdb"
"github.com/ava-labs/libevm/core/types"
Expand All @@ -47,7 +48,6 @@ import (
"github.com/ava-labs/libevm/trie"
"github.com/ava-labs/libevm/triedb"
"github.com/ava-labs/subnet-evm/core/state/snapshot"
"github.com/ava-labs/subnet-evm/plugin/evm/customrawdb"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion core/state/snapshot/disklayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import (
"bytes"
"testing"

"github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/core/rawdb"
"github.com/ava-labs/libevm/ethdb/memorydb"
"github.com/ava-labs/libevm/rlp"
"github.com/ava-labs/subnet-evm/plugin/evm/customrawdb"
)

// reverse reverses the contents of a byte slice. It's used to update random accs
Expand Down
2 changes: 1 addition & 1 deletion core/state/snapshot/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"fmt"
"time"

"github.com/ava-labs/avalanchego/vms/evm/sync/customrawdb"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/core/rawdb"
"github.com/ava-labs/libevm/core/types"
Expand All @@ -40,7 +41,6 @@ import (
"github.com/ava-labs/libevm/rlp"
"github.com/ava-labs/libevm/trie"
"github.com/ava-labs/libevm/triedb"
"github.com/ava-labs/subnet-evm/plugin/evm/customrawdb"
"github.com/ava-labs/subnet-evm/utils"
)

Expand Down
Loading
Loading