mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
fix test, add napoli block
This commit is contained in:
parent
738107b6c8
commit
05a19f2a36
4 changed files with 26 additions and 7 deletions
|
|
@ -105,13 +105,14 @@ var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{
|
||||||
common.BytesToAddress([]byte{18}): &bls12381MapG2{},
|
common.BytesToAddress([]byte{18}): &bls12381MapG2{},
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrecompiledContractsP256Verify contains the precompiled Ethereum
|
// PrecompiledContractsNapoli contains the precompiled Ethereum
|
||||||
// contract specified in EIP-7212. This is exported for testing purposes.
|
// contract specified in EIP-7212. This is exported for testing purposes.
|
||||||
var PrecompiledContractsP256Verify = map[common.Address]PrecompiledContract{
|
var PrecompiledContractsNapoli = map[common.Address]PrecompiledContract{
|
||||||
common.BytesToAddress([]byte{19}): &p256Verify{},
|
common.BytesToAddress([]byte{19}): &p256Verify{},
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
PrecompiledAddressesNapoli []common.Address
|
||||||
PrecompiledAddressesBerlin []common.Address
|
PrecompiledAddressesBerlin []common.Address
|
||||||
PrecompiledAddressesIstanbul []common.Address
|
PrecompiledAddressesIstanbul []common.Address
|
||||||
PrecompiledAddressesByzantium []common.Address
|
PrecompiledAddressesByzantium []common.Address
|
||||||
|
|
@ -134,11 +135,17 @@ func init() {
|
||||||
for k := range PrecompiledContractsBerlin {
|
for k := range PrecompiledContractsBerlin {
|
||||||
PrecompiledAddressesBerlin = append(PrecompiledAddressesBerlin, k)
|
PrecompiledAddressesBerlin = append(PrecompiledAddressesBerlin, k)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for k := range PrecompiledContractsNapoli {
|
||||||
|
PrecompiledAddressesNapoli = append(PrecompiledAddressesNapoli, k)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActivePrecompiles returns the precompiles enabled with the current configuration.
|
// ActivePrecompiles returns the precompiles enabled with the current configuration.
|
||||||
func ActivePrecompiles(rules params.Rules) []common.Address {
|
func ActivePrecompiles(rules params.Rules) []common.Address {
|
||||||
switch {
|
switch {
|
||||||
|
case rules.IsNapoli:
|
||||||
|
return PrecompiledAddressesNapoli
|
||||||
case rules.IsBerlin:
|
case rules.IsBerlin:
|
||||||
return PrecompiledAddressesBerlin
|
return PrecompiledAddressesBerlin
|
||||||
case rules.IsIstanbul:
|
case rules.IsIstanbul:
|
||||||
|
|
|
||||||
|
|
@ -423,4 +423,8 @@ func BenchmarkPrecompiledP256Verify(bench *testing.B) {
|
||||||
benchmarkPrecompiled("13", t, bench)
|
benchmarkPrecompiled("13", t, bench)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrecompiledP256Verify(t *testing.T) { testJson("p256Verify", "13", t) }
|
func TestPrecompiledP256Verify(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
testJson("p256Verify", "13", t)
|
||||||
|
}
|
||||||
|
|
|
||||||
2
core/vm/testdata/precompiles/p256Verify.json
vendored
2
core/vm/testdata/precompiles/p256Verify.json
vendored
|
|
@ -6,4 +6,4 @@
|
||||||
"Name": "CallP256Verify",
|
"Name": "CallP256Verify",
|
||||||
"NoBenchmark": false
|
"NoBenchmark": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -649,6 +649,7 @@ type ChainConfig struct {
|
||||||
ShanghaiBlock *big.Int `json:"shanghaiBlock,omitempty"` // Shanghai switch Block (nil = no fork, 0 = already on shanghai)
|
ShanghaiBlock *big.Int `json:"shanghaiBlock,omitempty"` // Shanghai switch Block (nil = no fork, 0 = already on shanghai)
|
||||||
CancunBlock *big.Int `json:"cancunBlock,omitempty"` // Cancun switch Block (nil = no fork, 0 = already on cancun)
|
CancunBlock *big.Int `json:"cancunBlock,omitempty"` // Cancun switch Block (nil = no fork, 0 = already on cancun)
|
||||||
PragueBlock *big.Int `json:"pragueBlock,omitempty"` // Prague switch Block (nil = no fork, 0 = already on prague)
|
PragueBlock *big.Int `json:"pragueBlock,omitempty"` // Prague switch Block (nil = no fork, 0 = already on prague)
|
||||||
|
NapoliBlock *big.Int `json:"napoliBlock,omitempty"` // Napoli switch Block (nil = no fork, 0 = already on Napoli)
|
||||||
|
|
||||||
// TerminalTotalDifficulty is the amount of total difficulty reached by
|
// TerminalTotalDifficulty is the amount of total difficulty reached by
|
||||||
// the network that triggers the consensus upgrade.
|
// the network that triggers the consensus upgrade.
|
||||||
|
|
@ -971,21 +972,26 @@ func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *bi
|
||||||
return parentTotalDiff.Cmp(c.TerminalTotalDifficulty) < 0 && totalDiff.Cmp(c.TerminalTotalDifficulty) >= 0
|
return parentTotalDiff.Cmp(c.TerminalTotalDifficulty) < 0 && totalDiff.Cmp(c.TerminalTotalDifficulty) >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsShanghai returns whether time is either equal to the Shanghai fork time or greater.
|
// IsShanghai returns whether num is either equal to the Shanghai fork block or greater.
|
||||||
func (c *ChainConfig) IsShanghai(num *big.Int) bool {
|
func (c *ChainConfig) IsShanghai(num *big.Int) bool {
|
||||||
return isBlockForked(c.ShanghaiBlock, num)
|
return isBlockForked(c.ShanghaiBlock, num)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsCancun returns whether num is either equal to the Cancun fork time or greater.
|
// IsCancun returns whether num is either equal to the Cancun fork block or greater.
|
||||||
func (c *ChainConfig) IsCancun(num *big.Int) bool {
|
func (c *ChainConfig) IsCancun(num *big.Int) bool {
|
||||||
return isBlockForked(c.CancunBlock, num)
|
return isBlockForked(c.CancunBlock, num)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsPrague returns whether num is either equal to the Prague fork time or greater.
|
// IsPrague returns whether num is either equal to the Prague fork block or greater.
|
||||||
func (c *ChainConfig) IsPrague(num *big.Int) bool {
|
func (c *ChainConfig) IsPrague(num *big.Int) bool {
|
||||||
return isBlockForked(c.PragueBlock, num)
|
return isBlockForked(c.PragueBlock, num)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsNapoli returns whether num is either equal to the Napoli fork block or greater.
|
||||||
|
func (c *ChainConfig) IsNapoli(num *big.Int) bool {
|
||||||
|
return isBlockForked(c.NapoliBlock, num)
|
||||||
|
}
|
||||||
|
|
||||||
// CheckCompatible checks whether scheduled fork transitions have been imported
|
// CheckCompatible checks whether scheduled fork transitions have been imported
|
||||||
// with a mismatching chain configuration.
|
// with a mismatching chain configuration.
|
||||||
func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64, time uint64) *ConfigCompatError {
|
func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64, time uint64) *ConfigCompatError {
|
||||||
|
|
@ -1327,6 +1333,7 @@ type Rules struct {
|
||||||
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
|
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
|
||||||
IsBerlin, IsLondon bool
|
IsBerlin, IsLondon bool
|
||||||
IsMerge, IsShanghai, IsCancun, IsPrague bool
|
IsMerge, IsShanghai, IsCancun, IsPrague bool
|
||||||
|
IsNapoli bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rules ensures c's ChainID is not nil.
|
// Rules ensures c's ChainID is not nil.
|
||||||
|
|
@ -1352,5 +1359,6 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
|
||||||
IsShanghai: c.IsShanghai(num),
|
IsShanghai: c.IsShanghai(num),
|
||||||
IsCancun: c.IsCancun(num),
|
IsCancun: c.IsCancun(num),
|
||||||
IsPrague: c.IsPrague(num),
|
IsPrague: c.IsPrague(num),
|
||||||
|
IsNapoli: c.IsNapoli(num),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue