Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: params.ChainConfigExtra & RulesExtra -> params/extras #702

Merged
merged 19 commits into from
Dec 18, 2024
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
3 changes: 2 additions & 1 deletion core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/ava-labs/coreth/core/state/pruner"
"github.com/ava-labs/coreth/core/types"
"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/params/extras"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/core/vm"
"github.com/ava-labs/libevm/crypto"
Expand Down Expand Up @@ -425,7 +426,7 @@ func TestUngracefulAsyncShutdown(t *testing.T) {
gspec := &Genesis{
Config: params.WithExtra(
&params.ChainConfig{HomesteadBlock: new(big.Int)},
&params.ChainConfigExtra{},
&extras.ChainConfig{},
),
Alloc: types.GenesisAlloc{addr1: {Balance: genesisBalance}},
}
Expand Down
5 changes: 3 additions & 2 deletions core/genesis_extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/ava-labs/coreth/core/rawdb"
"github.com/ava-labs/coreth/core/types"
"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/params/extras"
"github.com/ava-labs/coreth/utils"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/triedb"
Expand All @@ -57,8 +58,8 @@ func TestGenesisEthUpgrades(t *testing.T) {
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
},
&params.ChainConfigExtra{
NetworkUpgrades: params.NetworkUpgrades{
&extras.ChainConfig{
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
},
Expand Down
3 changes: 2 additions & 1 deletion core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/ava-labs/coreth/core/rawdb"
"github.com/ava-labs/coreth/core/types"
"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/params/extras"
"github.com/ava-labs/coreth/precompile/contracts/warp"
"github.com/ava-labs/coreth/triedb/pathdb"
"github.com/ava-labs/coreth/utils"
Expand Down Expand Up @@ -257,7 +258,7 @@ func TestGenesisWriteUpgradesRegression(t *testing.T) {
_, _, err := SetupGenesisBlock(db, trieDB, genesis, genesisBlock.Hash(), false)
require.NoError(err)

params.GetExtra(genesis.Config).UpgradeConfig.PrecompileUpgrades = []params.PrecompileUpgrade{
params.GetExtra(genesis.Config).UpgradeConfig.PrecompileUpgrades = []extras.PrecompileUpgrade{
{
Config: warp.NewConfig(utils.NewUint64(51), 0, false),
},
Expand Down
5 changes: 3 additions & 2 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/ava-labs/coreth/core/rawdb"
"github.com/ava-labs/coreth/core/types"
"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/params/extras"
"github.com/ava-labs/coreth/utils"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/core/vm"
Expand Down Expand Up @@ -270,8 +271,8 @@ func TestStateProcessorErrors(t *testing.T) {
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
},
&params.ChainConfigExtra{
NetworkUpgrades: params.NetworkUpgrades{
&extras.ChainConfig{
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
},
Expand Down
5 changes: 3 additions & 2 deletions core/vm/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/ava-labs/coreth/core/state"
"github.com/ava-labs/coreth/core/types"
"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/params/extras"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/core/vm"
"github.com/ava-labs/libevm/crypto"
Expand Down Expand Up @@ -84,8 +85,8 @@ func setDefaults(cfg *Config) {
LondonBlock: new(big.Int),
BerlinBlock: new(big.Int),
},
&params.ChainConfigExtra{
NetworkUpgrades: params.NetworkUpgrades{
&extras.ChainConfig{
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: new(uint64),
ApricotPhase2BlockTimestamp: new(uint64),
ApricotPhase3BlockTimestamp: new(uint64),
Expand Down
85 changes: 43 additions & 42 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"github.com/ava-labs/avalanchego/upgrade"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/coreth/params/extras"
"github.com/ava-labs/coreth/utils"
ethparams "github.com/ava-labs/libevm/params"
)
Expand Down Expand Up @@ -68,9 +69,9 @@ var (
ShanghaiTime: utils.TimeToNewUint64(upgrade.GetConfig(constants.UnitTestID).DurangoTime),
CancunTime: utils.TimeToNewUint64(upgrade.GetConfig(constants.UnitTestID).EtnaTime),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: utils.NewUint64(0),
Expand Down Expand Up @@ -101,9 +102,9 @@ var (
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: nil,
ApricotPhase2BlockTimestamp: nil,
ApricotPhase3BlockTimestamp: nil,
Expand Down Expand Up @@ -134,9 +135,9 @@ var (
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: big.NewInt(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: nil,
ApricotPhase3BlockTimestamp: nil,
Expand Down Expand Up @@ -168,9 +169,9 @@ var (
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: nil,
Expand Down Expand Up @@ -203,9 +204,9 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: utils.NewUint64(0),
Expand Down Expand Up @@ -238,9 +239,9 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: utils.NewUint64(0),
Expand Down Expand Up @@ -273,9 +274,9 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: utils.NewUint64(0),
Expand Down Expand Up @@ -308,9 +309,9 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: utils.NewUint64(0),
Expand Down Expand Up @@ -343,9 +344,9 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: utils.NewUint64(0),
Expand Down Expand Up @@ -378,9 +379,9 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: utils.NewUint64(0),
Expand Down Expand Up @@ -413,9 +414,9 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: utils.NewUint64(0),
Expand Down Expand Up @@ -448,9 +449,9 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: utils.NewUint64(0),
Expand Down Expand Up @@ -484,9 +485,9 @@ var (
LondonBlock: big.NewInt(0),
ShanghaiTime: utils.NewUint64(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: utils.NewUint64(0),
Expand Down Expand Up @@ -521,9 +522,9 @@ var (
ShanghaiTime: utils.NewUint64(0),
CancunTime: utils.NewUint64(0),
},
&ChainConfigExtra{
AvalancheContext: AvalancheContext{utils.TestSnowContext()},
NetworkUpgrades: NetworkUpgrades{
&extras.ChainConfig{
AvalancheContext: extras.AvalancheContext{SnowCtx: utils.TestSnowContext()},
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase3BlockTimestamp: utils.NewUint64(0),
Expand Down
Loading
Loading