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 1 commit
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
9 changes: 4 additions & 5 deletions eth/tracers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/plugin/evm/customrawdb"
"github.com/ava-labs/coreth/rpc"
"github.com/ava-labs/coreth/utils"
"github.com/ava-labs/libevm/common"
"github.com/ava-labs/libevm/common/hexutil"
"github.com/ava-labs/libevm/core/rawdb"
Expand Down Expand Up @@ -299,8 +300,6 @@ func testTraceCall(t *testing.T, scheme string) {
}
})

uintPtr := func(i int) *hexutil.Uint { x := hexutil.Uint(i); return &x }

defer backend.teardown()
api := NewAPI(backend)
var testSuite = []struct {
Expand Down Expand Up @@ -353,7 +352,7 @@ func testTraceCall(t *testing.T, scheme string) {
To: &accounts[0].addr,
Value: (*hexutil.Big)(new(big.Int).Add(big.NewInt(params.Ether), big.NewInt(100))),
},
config: &TraceCallConfig{TxIndex: uintPtr(0)},
config: &TraceCallConfig{TxIndex: utils.PointerTo(hexutil.Uint(0))},
expectErr: fmt.Errorf("tracing failed: insufficient funds for gas * price + value: address %s have 1000000000000000000 want 1000000000000000100", accounts[2].addr),
},
// Before the target transaction, should be failed
Expand All @@ -364,7 +363,7 @@ func testTraceCall(t *testing.T, scheme string) {
To: &accounts[0].addr,
Value: (*hexutil.Big)(new(big.Int).Add(big.NewInt(params.Ether), big.NewInt(100))),
},
config: &TraceCallConfig{TxIndex: uintPtr(1)},
config: &TraceCallConfig{TxIndex: utils.PointerTo(hexutil.Uint(1))},
expectErr: fmt.Errorf("tracing failed: insufficient funds for gas * price + value: address %s have 1000000000000000000 want 1000000000000000100", accounts[2].addr),
},
// After the target transaction, should be succeed
Expand All @@ -375,7 +374,7 @@ func testTraceCall(t *testing.T, scheme string) {
To: &accounts[0].addr,
Value: (*hexutil.Big)(new(big.Int).Add(big.NewInt(params.Ether), big.NewInt(100))),
},
config: &TraceCallConfig{TxIndex: uintPtr(2)},
config: &TraceCallConfig{TxIndex: utils.PointerTo(hexutil.Uint(2))},
expectErr: nil,
expect: `{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}`,
},
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 @@ -89,8 +89,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 @@ -326,7 +326,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 @@ -347,8 +347,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 @@ -369,8 +369,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 @@ -391,8 +391,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
Loading
Loading