Replace --override.shanghaiTime flag with --override.cancun (#7964)

Prerequisite: https://github.com/ledgerwatch/erigon-lib/pull/1067
This commit is contained in:
Andrew Ashikhmin 2023-08-03 16:05:35 +02:00 committed by GitHub
parent 2c2ccb6e27
commit d014da4dc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 90 deletions

View File

@ -104,9 +104,9 @@ var (
Name: "whitelist",
Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)",
}
OverrideShanghaiTime = flags.BigFlag{
Name: "override.shanghaiTime",
Usage: "Manually specify Shanghai fork time, overriding the bundled setting",
OverrideCancunFlag = flags.BigFlag{
Name: "override.cancun",
Usage: "Manually specify the Cancun fork time, overriding the bundled setting",
}
TrustedSetupFile = cli.StringFlag{
Name: "trusted-setup-file",
@ -1584,9 +1584,9 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
}
}
if ctx.IsSet(OverrideShanghaiTime.Name) {
cfg.OverrideShanghaiTime = flags.GlobalBig(ctx, OverrideShanghaiTime.Name)
cfg.TxPool.OverrideShanghaiTime = cfg.OverrideShanghaiTime
if ctx.IsSet(OverrideCancunFlag.Name) {
cfg.OverrideCancunTime = flags.GlobalBig(ctx, OverrideCancunFlag.Name)
cfg.TxPool.OverrideCancunTime = cfg.OverrideCancunTime
}
if ctx.IsSet(InternalConsensusFlag.Name) && clparams.EmbeddedEnabledByDefault(cfg.NetworkID) {

View File

@ -69,13 +69,13 @@ func CommitGenesisBlock(db kv.RwDB, genesis *types.Genesis, tmpDir string, logge
return CommitGenesisBlockWithOverride(db, genesis, nil, tmpDir, logger)
}
func CommitGenesisBlockWithOverride(db kv.RwDB, genesis *types.Genesis, overrideShanghaiTime *big.Int, tmpDir string, logger log.Logger) (*chain.Config, *types.Block, error) {
func CommitGenesisBlockWithOverride(db kv.RwDB, genesis *types.Genesis, overrideCancunTime *big.Int, tmpDir string, logger log.Logger) (*chain.Config, *types.Block, error) {
tx, err := db.BeginRw(context.Background())
if err != nil {
return nil, nil, err
}
defer tx.Rollback()
c, b, err := WriteGenesisBlock(tx, genesis, overrideShanghaiTime, tmpDir, logger)
c, b, err := WriteGenesisBlock(tx, genesis, overrideCancunTime, tmpDir, logger)
if err != nil {
return c, b, err
}
@ -86,7 +86,7 @@ func CommitGenesisBlockWithOverride(db kv.RwDB, genesis *types.Genesis, override
return c, b, nil
}
func WriteGenesisBlock(tx kv.RwTx, genesis *types.Genesis, overrideShanghaiTime *big.Int, tmpDir string, logger log.Logger) (*chain.Config, *types.Block, error) {
func WriteGenesisBlock(tx kv.RwTx, genesis *types.Genesis, overrideCancunTime *big.Int, tmpDir string, logger log.Logger) (*chain.Config, *types.Block, error) {
var storedBlock *types.Block
if genesis != nil && genesis.Config == nil {
return params.AllProtocolChanges, nil, types.ErrGenesisNoConfig
@ -98,8 +98,8 @@ func WriteGenesisBlock(tx kv.RwTx, genesis *types.Genesis, overrideShanghaiTime
}
applyOverrides := func(config *chain.Config) {
if overrideShanghaiTime != nil {
config.ShanghaiTime = overrideShanghaiTime
if overrideCancunTime != nil {
config.CancunTime = overrideCancunTime
}
}

View File

@ -1,65 +0,0 @@
package kzg
// import (
// "errors"
// "fmt"
// "math/big"
// gokzg4844 "github.com/crate-crypto/go-kzg-4844"
// libkzg "github.com/ledgerwatch/erigon-lib/crypto/kzg"
// )
// const (
// PrecompileInputLength int = 192
// )
// var (
// errInvalidInputLength = errors.New("invalid input length")
// // The value that gets returned when the `verify_kzg_proof“ precompile is called
// precompileReturnValue [64]byte
// )
// // InitializeCrypytoCtx initializes the global context object returned via CryptoCtx
// func init() {
// new(big.Int).SetUint64(gokzg4844.ScalarsPerBlob).FillBytes(precompileReturnValue[:32])
// copy(precompileReturnValue[32:], gokzg4844.BlsModulus[:])
// }
// // PointEvaluationPrecompile implements point_evaluation_precompile from EIP-4844
// func PointEvaluationPrecompile(input []byte) ([]byte, error) {
// if len(input) != PrecompileInputLength {
// return nil, errInvalidInputLength
// }
// // versioned hash: first 32 bytes
// var versionedHash [32]byte
// copy(versionedHash[:], input[:32])
// var x, y [32]byte
// // Evaluation point: next 32 bytes
// copy(x[:], input[32:64])
// // Expected output: next 32 bytes
// copy(y[:], input[64:96])
// // input kzg point: next 48 bytes
// var dataKZG [48]byte
// copy(dataKZG[:], input[96:144])
// if libkzg.KZGToVersionedHash(dataKZG) != versionedHash {
// return nil, errors.New("mismatched versioned hash")
// }
// // Quotient kzg: next 48 bytes
// var quotientKZG [48]byte
// copy(quotientKZG[:], input[144:PrecompileInputLength])
// cryptoCtx := libkzg.Ctx()
// err := cryptoCtx.VerifyKZGProof(dataKZG, x, y, quotientKZG)
// if err != nil {
// return nil, fmt.Errorf("verify_kzg_proof error: %v", err)
// }
// result := precompileReturnValue // copy the value
// return result[:], nil
// }

View File

@ -299,7 +299,7 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
genesisSpec = nil
}
var genesisErr error
chainConfig, genesis, genesisErr = core.WriteGenesisBlock(tx, genesisSpec, config.OverrideShanghaiTime, tmpdir, logger)
chainConfig, genesis, genesisErr = core.WriteGenesisBlock(tx, genesisSpec, config.OverrideCancunTime, tmpdir, logger)
if _, ok := genesisErr.(*chain.ConfigCompatError); genesisErr != nil && !ok {
return genesisErr
}

View File

@ -246,7 +246,7 @@ type Config struct {
SentinelPort uint64
ExperimentalConsensusSeparation bool
OverrideShanghaiTime *big.Int `toml:",omitempty"`
OverrideCancunTime *big.Int `toml:",omitempty"`
DropUselessPeers bool
}

4
go.mod
View File

@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon
go 1.19
require (
github.com/ledgerwatch/erigon-lib v0.0.0-20230803063510-d4f8da719e8f
github.com/ledgerwatch/erigon-lib v0.0.0-20230803133728-0a6037d12f5a
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230622075030-1d69651854c2
github.com/ledgerwatch/log/v3 v3.8.0
github.com/ledgerwatch/secp256k1 v1.0.0
@ -169,7 +169,6 @@ require (
github.com/koron/go-ssdp v0.0.4 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/ledgerwatch/interfaces v0.0.0-20230731192530-801b5852e33e // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-cidranger v1.1.0 // indirect
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
@ -183,7 +182,6 @@ require (
github.com/lispad/go-generics-tools v1.1.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/matryer/moq v0.3.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect

10
go.sum
View File

@ -499,14 +499,10 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/ledgerwatch/erigon-lib v0.0.0-20230801161656-f33b0bc5382c h1:n1bMHtplRq5CoiX64kIRWs5WUvyk3fByVDR4yRDwHGk=
github.com/ledgerwatch/erigon-lib v0.0.0-20230801161656-f33b0bc5382c/go.mod h1:v9r+BsZyoO1CFZ7BwTcRpfVNXzJhGA5qokUUxtahxXw=
github.com/ledgerwatch/erigon-lib v0.0.0-20230803063510-d4f8da719e8f h1:oAA0cTo3NHErzFOOe/U/bp+i5erNvnSAkV8HejPLoko=
github.com/ledgerwatch/erigon-lib v0.0.0-20230803063510-d4f8da719e8f/go.mod h1:v9r+BsZyoO1CFZ7BwTcRpfVNXzJhGA5qokUUxtahxXw=
github.com/ledgerwatch/erigon-lib v0.0.0-20230803133728-0a6037d12f5a h1:zrNdGvXMp23kpFJlI0lS9J5Gj8hlFCS5/Ejvm5Xxozk=
github.com/ledgerwatch/erigon-lib v0.0.0-20230803133728-0a6037d12f5a/go.mod h1:v9r+BsZyoO1CFZ7BwTcRpfVNXzJhGA5qokUUxtahxXw=
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230622075030-1d69651854c2 h1:Ls2itRGHMOr2PbHRDA4g1HH8HQdwfJhRVfMPEaLQe94=
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230622075030-1d69651854c2/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo=
github.com/ledgerwatch/interfaces v0.0.0-20230731192530-801b5852e33e h1:a++pG0zOOAOpF/2yRwTwbh7urXLUfO7YZQfb182vjqA=
github.com/ledgerwatch/interfaces v0.0.0-20230731192530-801b5852e33e/go.mod h1:ugQv1QllJzBny3cKZKxUrSnykkjkBgm27eQM6dnGAcc=
github.com/ledgerwatch/log/v3 v3.8.0 h1:gCpp7uGtIerEz1jKVPeDnbIopFPud9ZnCpBLlLBGqPU=
github.com/ledgerwatch/log/v3 v3.8.0/go.mod h1:J2Jl6zV/58LeA6LTaVVnCGyf1/cYYSEOOLHY4ZN8S2A=
github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ=
@ -550,8 +546,6 @@ github.com/maticnetwork/crand v1.0.2 h1:Af0tAivC8zrxXDpGWNWVT/0s1fOz8w0eRbahZgUR
github.com/maticnetwork/crand v1.0.2/go.mod h1:/NRNL3bj2eYdqpWmoIP5puxndTpi0XRxpj5ZKxfHjyg=
github.com/maticnetwork/polyproto v0.0.2 h1:cPxuxbIDItdwGnucc3lZB58U8Zfe1mH73PWTGd15554=
github.com/maticnetwork/polyproto v0.0.2/go.mod h1:e1mU2EXSwEpn5jM7GfNwu3AupsV6WAGoPFFfswXOF0o=
github.com/matryer/moq v0.3.2 h1:z7oltmpTxiQ9nKNg0Jc7z45TM+eO7OhCVohxRxwaudM=
github.com/matryer/moq v0.3.2/go.mod h1:RJ75ZZZD71hejp39j4crZLsEDszGk6iH4v4YsWFKH4s=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=

View File

@ -147,7 +147,7 @@ var DefaultFlags = []cli.Flag{
&utils.BorBlockPeriodFlag,
&utils.BorBlockSizeFlag,
&utils.EthStatsURLFlag,
&utils.OverrideShanghaiTime,
&utils.OverrideCancunFlag,
&utils.ConfigFlag,