Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Open
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
4 changes: 2 additions & 2 deletions core/genesis_extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func TestGenesisEthUpgrades(t *testing.T) {
},
&extras.ChainConfig{
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase1BlockTimestamp: utils.PointerTo(uint64(0)),
ApricotPhase2BlockTimestamp: utils.PointerTo(uint64(0)),
},
},
)
Expand Down
12 changes: 6 additions & 6 deletions core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestSetupGenesis(t *testing.T) {

func testSetupGenesis(t *testing.T, scheme string) {
apricotPhase1Config := params.Copy(params.TestApricotPhase1Config)
params.GetExtra(&apricotPhase1Config).ApricotPhase1BlockTimestamp = utils.NewUint64(100)
params.GetExtra(&apricotPhase1Config).ApricotPhase1BlockTimestamp = utils.PointerTo(uint64(100))
var (
customghash = common.HexToHash("0x1099a11e9e454bd3ef31d688cf21936671966407bc330f051d754b5ce401e7ed")
customg = Genesis{
Expand All @@ -92,7 +92,7 @@ func testSetupGenesis(t *testing.T, scheme string) {
)

rollbackApricotPhase1Config := params.Copy(&apricotPhase1Config)
params.GetExtra(&rollbackApricotPhase1Config).ApricotPhase1BlockTimestamp = utils.NewUint64(90)
params.GetExtra(&rollbackApricotPhase1Config).ApricotPhase1BlockTimestamp = utils.PointerTo(uint64(90))
oldcustomg.Config = &rollbackApricotPhase1Config
tests := []struct {
name string
Expand Down Expand Up @@ -176,8 +176,8 @@ func testSetupGenesis(t *testing.T, scheme string) {
wantConfig: customg.Config,
wantErr: &ethparams.ConfigCompatError{
What: "ApricotPhase1 fork block timestamp",
StoredTime: u64(90),
NewTime: u64(100),
StoredTime: utils.PointerTo(uint64(90)),
NewTime: utils.PointerTo(uint64(100)),
RewindToTime: 89,
},
},
Expand Down Expand Up @@ -238,7 +238,7 @@ func TestNetworkUpgradeBetweenHeadAndAcceptedBlock(t *testing.T) {
require.Greater(block.Time, bc.lastAccepted.Time())

activatedGenesis := customg
apricotPhase2Timestamp := utils.NewUint64(51)
apricotPhase2Timestamp := utils.PointerTo(uint64(51))
updatedApricotPhase2Config := params.Copy(params.TestApricotPhase1Config)
params.GetExtra(&updatedApricotPhase2Config).ApricotPhase2BlockTimestamp = apricotPhase2Timestamp

Expand Down Expand Up @@ -276,7 +276,7 @@ func TestGenesisWriteUpgradesRegression(t *testing.T) {

params.GetExtra(genesis.Config).UpgradeConfig.PrecompileUpgrades = []extras.PrecompileUpgrade{
{
Config: warp.NewConfig(utils.NewUint64(51), 0, false),
Config: warp.NewConfig(utils.PointerTo(uint64(51)), 0, false),
},
}
_, _, err = SetupGenesisBlock(db, trieDB, genesis, genesisBlock.Hash(), false)
Expand Down
12 changes: 5 additions & 7 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,15 @@ import (
"golang.org/x/crypto/sha3"
)

func u64(val uint64) *uint64 { return &val }

// TestStateProcessorErrors tests the output from the 'core' errors
// as defined in core/error.go. These errors are generated when the
// blockchain imports bad blocks, meaning blocks which have valid headers but
// contain invalid transactions
func TestStateProcessorErrors(t *testing.T) {
cpcfg := *params.TestChainConfig
config := &cpcfg
config.ShanghaiTime = u64(0)
config.CancunTime = u64(0)
config.ShanghaiTime = utils.PointerTo(uint64(0))
config.CancunTime = utils.PointerTo(uint64(0))

var (
signer = types.LatestSigner(config)
Expand Down Expand Up @@ -283,8 +281,8 @@ func TestStateProcessorErrors(t *testing.T) {
},
&extras.ChainConfig{
NetworkUpgrades: extras.NetworkUpgrades{
ApricotPhase1BlockTimestamp: utils.NewUint64(0),
ApricotPhase2BlockTimestamp: utils.NewUint64(0),
ApricotPhase1BlockTimestamp: utils.PointerTo(uint64(0)),
ApricotPhase2BlockTimestamp: utils.PointerTo(uint64(0)),
},
},
),
Expand Down Expand Up @@ -391,7 +389,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
}
if configExtra.IsGranite(header.Time) {
headerExtra := customtypes.GetHeaderExtra(header)
headerExtra.TimeMilliseconds = utils.NewUint64(timeMS)
headerExtra.TimeMilliseconds = utils.PointerTo(timeMS)
}
if configExtra.IsApricotPhase4(header.Time) {
headerExtra := customtypes.GetHeaderExtra(header)
Expand Down
4 changes: 2 additions & 2 deletions internal/ethapi/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,8 @@ func TestEstimateGas(t *testing.T) {
func TestCall(t *testing.T) {
// Enable BLOBHASH opcode in Cancun
cfg := *params.TestChainConfig
cfg.ShanghaiTime = utils.NewUint64(0)
cfg.CancunTime = utils.NewUint64(0)
cfg.ShanghaiTime = utils.PointerTo(uint64(0))
cfg.CancunTime = utils.PointerTo(uint64(0))
t.Parallel()
// Initialize test accounts
var (
Expand Down
18 changes: 9 additions & 9 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func initialiseChainConfigs() {
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ShanghaiTime: utils.NewUint64(0),
CancunTime: utils.NewUint64(0),
ShanghaiTime: utils.PointerTo(uint64(0)),
CancunTime: utils.PointerTo(uint64(0)),
},
extras.TestChainConfig,
)
Expand Down Expand Up @@ -332,7 +332,7 @@ func initialiseChainConfigs() {
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ShanghaiTime: utils.NewUint64(0),
ShanghaiTime: utils.PointerTo(uint64(0)),
},
extras.TestDurangoChainConfig,
)
Expand All @@ -353,8 +353,8 @@ func initialiseChainConfigs() {
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ShanghaiTime: utils.NewUint64(0),
CancunTime: utils.NewUint64(0),
ShanghaiTime: utils.PointerTo(uint64(0)),
CancunTime: utils.PointerTo(uint64(0)),
},
extras.TestEtnaChainConfig,
)
Expand All @@ -375,8 +375,8 @@ func initialiseChainConfigs() {
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ShanghaiTime: utils.NewUint64(0),
CancunTime: utils.NewUint64(0),
ShanghaiTime: utils.PointerTo(uint64(0)),
CancunTime: utils.PointerTo(uint64(0)),
},
extras.TestFortunaChainConfig,
)
Expand All @@ -397,8 +397,8 @@ func initialiseChainConfigs() {
MuirGlacierBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ShanghaiTime: utils.NewUint64(0),
CancunTime: utils.NewUint64(0),
ShanghaiTime: utils.PointerTo(uint64(0)),
CancunTime: utils.PointerTo(uint64(0)),
},
extras.TestGraniteChainConfig,
)
Expand Down
4 changes: 2 additions & 2 deletions params/config_extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ func SetEthUpgrades(c *ChainConfig) error {
// We only mark Shanghai and Cancun as enabled if we have marked them as
// scheduled.
if durango := extra.DurangoBlockTimestamp; durango != nil && *durango < unscheduledActivation {
c.ShanghaiTime = utils.NewUint64(*durango)
c.ShanghaiTime = utils.PointerTo(*durango)
}

if etna := extra.EtnaTimestamp; etna != nil && *etna < unscheduledActivation {
c.CancunTime = utils.NewUint64(*etna)
c.CancunTime = utils.PointerTo(*etna)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion params/config_extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestMain(m *testing.M) {

func TestSetEthUpgrades(t *testing.T) {
genesisBlock := big.NewInt(0)
genesisTimestamp := utils.NewUint64(initiallyActive)
genesisTimestamp := utils.PointerTo(initiallyActive)
tests := []struct {
fork upgradetest.Fork
expected *ChainConfig
Expand Down
6 changes: 3 additions & 3 deletions params/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestCheckCompatible(t *testing.T) {
headTimestamp: 0,
wantErr: &ethparams.ConfigCompatError{
What: "ApricotPhase5 fork block timestamp",
StoredTime: utils.NewUint64(0),
StoredTime: utils.PointerTo(uint64(0)),
NewTime: nil,
RewindToTime: 0,
},
Expand All @@ -131,7 +131,7 @@ func TestCheckCompatible(t *testing.T) {
headTimestamp: 100,
wantErr: &ethparams.ConfigCompatError{
What: "ApricotPhase5 fork block timestamp",
StoredTime: utils.NewUint64(0),
StoredTime: utils.PointerTo(uint64(0)),
NewTime: nil,
RewindToTime: 0,
},
Expand All @@ -151,7 +151,7 @@ func TestConfigRules(t *testing.T) {
&ChainConfig{},
&extras.ChainConfig{
NetworkUpgrades: extras.NetworkUpgrades{
CortinaBlockTimestamp: utils.NewUint64(500),
CortinaBlockTimestamp: utils.PointerTo(uint64(500)),
},
},
)
Expand Down
30 changes: 15 additions & 15 deletions params/extras/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,59 +20,59 @@ var (
TestLaunchConfig = &ChainConfig{}

TestApricotPhase1Config = copyAndSet(TestLaunchConfig, func(c *ChainConfig) {
c.NetworkUpgrades.ApricotPhase1BlockTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.ApricotPhase1BlockTimestamp = utils.PointerTo(uint64(0))
})

TestApricotPhase2Config = copyAndSet(TestApricotPhase1Config, func(c *ChainConfig) {
c.NetworkUpgrades.ApricotPhase2BlockTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.ApricotPhase2BlockTimestamp = utils.PointerTo(uint64(0))
})

TestApricotPhase3Config = copyAndSet(TestApricotPhase2Config, func(c *ChainConfig) {
c.NetworkUpgrades.ApricotPhase3BlockTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.ApricotPhase3BlockTimestamp = utils.PointerTo(uint64(0))
})

TestApricotPhase4Config = copyAndSet(TestApricotPhase3Config, func(c *ChainConfig) {
c.NetworkUpgrades.ApricotPhase4BlockTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.ApricotPhase4BlockTimestamp = utils.PointerTo(uint64(0))
})

TestApricotPhase5Config = copyAndSet(TestApricotPhase4Config, func(c *ChainConfig) {
c.NetworkUpgrades.ApricotPhase5BlockTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.ApricotPhase5BlockTimestamp = utils.PointerTo(uint64(0))
})

TestApricotPhasePre6Config = copyAndSet(TestApricotPhase5Config, func(c *ChainConfig) {
c.NetworkUpgrades.ApricotPhasePre6BlockTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.ApricotPhasePre6BlockTimestamp = utils.PointerTo(uint64(0))
})

TestApricotPhase6Config = copyAndSet(TestApricotPhasePre6Config, func(c *ChainConfig) {
c.NetworkUpgrades.ApricotPhase6BlockTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.ApricotPhase6BlockTimestamp = utils.PointerTo(uint64(0))
})

TestApricotPhasePost6Config = copyAndSet(TestApricotPhase6Config, func(c *ChainConfig) {
c.NetworkUpgrades.ApricotPhasePost6BlockTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.ApricotPhasePost6BlockTimestamp = utils.PointerTo(uint64(0))
})

TestBanffChainConfig = copyAndSet(TestApricotPhasePost6Config, func(c *ChainConfig) {
c.NetworkUpgrades.BanffBlockTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.BanffBlockTimestamp = utils.PointerTo(uint64(0))
})

TestCortinaChainConfig = copyAndSet(TestBanffChainConfig, func(c *ChainConfig) {
c.NetworkUpgrades.CortinaBlockTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.CortinaBlockTimestamp = utils.PointerTo(uint64(0))
})

TestDurangoChainConfig = copyAndSet(TestCortinaChainConfig, func(c *ChainConfig) {
c.NetworkUpgrades.DurangoBlockTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.DurangoBlockTimestamp = utils.PointerTo(uint64(0))
})

TestEtnaChainConfig = copyAndSet(TestDurangoChainConfig, func(c *ChainConfig) {
c.NetworkUpgrades.EtnaTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.EtnaTimestamp = utils.PointerTo(uint64(0))
})

TestFortunaChainConfig = copyAndSet(TestEtnaChainConfig, func(c *ChainConfig) {
c.NetworkUpgrades.FortunaTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.FortunaTimestamp = utils.PointerTo(uint64(0))
})

TestGraniteChainConfig = copyAndSet(TestFortunaChainConfig, func(c *ChainConfig) {
c.NetworkUpgrades.GraniteTimestamp = utils.NewUint64(0)
c.NetworkUpgrades.GraniteTimestamp = utils.PointerTo(uint64(0))
})

TestChainConfig = copyConfig(TestGraniteChainConfig)
Expand Down Expand Up @@ -121,7 +121,7 @@ func (c *ChainConfig) CheckConfigCompatible(newcfg_ *ethparams.ChainConfig, head
// Return an error to prevent the chain from starting, just in case.
return ethparams.NewTimestampCompatError(
fmt.Sprintf("ChainConfig.Hooks() is not of the expected type *extras.ChainConfig, got %T", newcfg_.Hooks()),
utils.NewUint64(0),
utils.PointerTo(uint64(0)),
nil,
)
}
Expand Down
34 changes: 17 additions & 17 deletions params/extras/config_extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ func TestIsTimestampForked(t *testing.T) {
isForked: false,
},
"zero fork at genesis": {
fork: utils.NewUint64(0),
fork: utils.PointerTo(uint64(0)),
block: 0,
isForked: true,
},
"pre fork timestamp": {
fork: utils.NewUint64(100),
fork: utils.PointerTo(uint64(100)),
block: 50,
isForked: false,
},
"at fork timestamp": {
fork: utils.NewUint64(100),
fork: utils.PointerTo(uint64(100)),
block: 100,
isForked: true,
},
"post fork timestamp": {
fork: utils.NewUint64(100),
fork: utils.PointerTo(uint64(100)),
block: 150,
isForked: true,
},
Expand All @@ -72,50 +72,50 @@ func TestIsForkTransition(t *testing.T) {
transitioned: false,
},
"activate at genesis": {
fork: utils.NewUint64(0),
fork: utils.PointerTo(uint64(0)),
parent: nil,
current: 0,
transitioned: true,
},
"nil fork arbitrary transition": {
fork: nil,
parent: utils.NewUint64(100),
parent: utils.PointerTo(uint64(100)),
current: 101,
transitioned: false,
},
"nil fork transition same timestamp": {
fork: nil,
parent: utils.NewUint64(100),
parent: utils.PointerTo(uint64(100)),
current: 100,
transitioned: false,
},
"exact match on current timestamp": {
fork: utils.NewUint64(100),
parent: utils.NewUint64(99),
fork: utils.PointerTo(uint64(100)),
parent: utils.PointerTo(uint64(99)),
current: 100,
transitioned: true,
},
"current same as parent does not transition twice": {
fork: utils.NewUint64(100),
parent: utils.NewUint64(101),
fork: utils.PointerTo(uint64(100)),
parent: utils.PointerTo(uint64(101)),
current: 101,
transitioned: false,
},
"current, parent, and fork same should not transition twice": {
fork: utils.NewUint64(100),
parent: utils.NewUint64(100),
fork: utils.PointerTo(uint64(100)),
parent: utils.PointerTo(uint64(100)),
current: 100,
transitioned: false,
},
"current transitions after fork": {
fork: utils.NewUint64(100),
parent: utils.NewUint64(99),
fork: utils.PointerTo(uint64(100)),
parent: utils.PointerTo(uint64(99)),
current: 101,
transitioned: true,
},
"current and parent come after fork": {
fork: utils.NewUint64(100),
parent: utils.NewUint64(101),
fork: utils.PointerTo(uint64(100)),
parent: utils.PointerTo(uint64(101)),
current: 102,
transitioned: false,
},
Expand Down
2 changes: 1 addition & 1 deletion params/extras/precompile_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (c *ChainConfig) verifyPrecompileUpgrades() error {
lastTimestamp = nil
} else {
disabled = lastUpgradeByKey.disabled
lastTimestamp = utils.NewUint64(lastUpgradeByKey.blockTimestamp)
lastTimestamp = utils.PointerTo(lastUpgradeByKey.blockTimestamp)
}
upgradeTimestamp := upgrade.Timestamp()

Expand Down
Loading
Loading