Skip to content

Commit

Permalink
feat: add new configuration (#526)
Browse files Browse the repository at this point in the history
* add new configuration

* update

* update

* bump version

* remove todo
  • Loading branch information
Thegaram committed Oct 8, 2023
1 parent 68697b0 commit b3d0f16
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 6 deletions.
1 change: 1 addition & 0 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ It expects the genesis file as argument.`,
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `
Expand Down
2 changes: 2 additions & 0 deletions cmd/geth/consolecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ func remoteConsole(ctx *cli.Context) error {
path = filepath.Join(path, "scroll-alpha")
} else if ctx.GlobalBool(utils.ScrollSepoliaFlag.Name) {
path = filepath.Join(path, "scroll-sepolia")
} else if ctx.GlobalBool(utils.ScrollFlag.Name) {
path = filepath.Join(path, "scroll")
}
}
endpoint = fmt.Sprintf("%s/geth.ipc", path)
Expand Down
10 changes: 10 additions & 0 deletions cmd/geth/dbcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Remove blockchain and state databases`,
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
Usage: "Inspect the storage size for each type of data in the database",
Description: `This commands iterates the entire database. If the optional 'prefix' and 'start' arguments are provided, then the iteration is limited to the given subset of data.`,
Expand All @@ -105,6 +106,7 @@ Remove blockchain and state databases`,
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
}
dbCompactCmd = cli.Command{
Expand All @@ -121,6 +123,7 @@ Remove blockchain and state databases`,
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.CacheFlag,
utils.CacheDatabaseFlag,
},
Expand All @@ -143,6 +146,7 @@ corruption if it is aborted during execution'!`,
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
Description: "This command looks up the specified database key from the database.",
}
Expand All @@ -161,6 +165,7 @@ corruption if it is aborted during execution'!`,
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
Description: `This command deletes the specified database key from the database.
WARNING: This is a low-level operation which may cause database corruption!`,
Expand All @@ -180,6 +185,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
Description: `This command sets a given database key to the given value.
WARNING: This is a low-level operation which may cause database corruption!`,
Expand All @@ -199,6 +205,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
Description: "This command looks up the specified database key from the database.",
}
Expand All @@ -217,6 +224,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
Description: "This command displays information about the freezer index.",
}
Expand All @@ -234,6 +242,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
Description: "The import command imports the specific chain data from an RLP encoded stream.",
}
Expand All @@ -251,6 +260,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
Description: "Exports the specified chain data to an RLP encoded stream, optionally gzip-compressed.",
}
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ var (
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.VMEnableDebugFlag,
utils.NetworkIdFlag,
utils.EthStatsURLFlag,
Expand Down
5 changes: 5 additions & 0 deletions cmd/geth/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var (
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.CacheTrieJournalFlag,
utils.BloomFilterSizeFlag,
},
Expand Down Expand Up @@ -101,6 +102,7 @@ the trie clean cache with default directory will be deleted.
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
Description: `
geth snapshot verify-state <state-root>
Expand All @@ -124,6 +126,7 @@ In other words, this command does the snapshot to trie conversion.
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
Description: `
geth snapshot traverse-state <state-root>
Expand All @@ -149,6 +152,7 @@ It's also usable without snapshot enabled.
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
},
Description: `
geth snapshot traverse-rawstate <state-root>
Expand All @@ -175,6 +179,7 @@ It's also usable without snapshot enabled.
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.ExcludeCodeFlag,
utils.ExcludeStorageFlag,
utils.StartKeyFlag,
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.SepoliaFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.SyncModeFlag,
utils.ExitWhenSyncedFlag,
utils.GCModeFlag,
Expand Down
34 changes: 33 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ var (
Name: "scroll-sepolia",
Usage: "Scroll Sepolia test network",
}
ScrollFlag = cli.BoolFlag{
Name: "scroll",
Usage: "Scroll mainnet",
}
DeveloperFlag = cli.BoolFlag{
Name: "dev",
Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled",
Expand Down Expand Up @@ -864,6 +868,9 @@ func MakeDataDir(ctx *cli.Context) string {
if ctx.GlobalBool(ScrollSepoliaFlag.Name) {
return filepath.Join(path, "scroll-sepolia")
}
if ctx.GlobalBool(ScrollFlag.Name) {
return filepath.Join(path, "scroll")
}
return path
}
Fatalf("Cannot determine default data directory, please set manually (--datadir)")
Expand Down Expand Up @@ -922,6 +929,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.ScrollAlphaBootnodes
case ctx.GlobalBool(ScrollSepoliaFlag.Name):
urls = params.ScrollSepoliaBootnodes
case ctx.GlobalBool(ScrollFlag.Name):
urls = params.ScrollMainnetBootnodes
case cfg.BootstrapNodes != nil:
return // already set, don't apply defaults.
}
Expand Down Expand Up @@ -1384,6 +1393,8 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "scroll-alpha")
case ctx.GlobalBool(ScrollSepoliaFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "scroll-sepolia")
case ctx.GlobalBool(ScrollFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "scroll")

}
}
Expand Down Expand Up @@ -1587,7 +1598,7 @@ func CheckExclusive(ctx *cli.Context, args ...interface{}) {
// SetEthConfig applies eth-related command line flags to the config.
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
// Avoid conflicting network flags
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RopstenFlag, RinkebyFlag, GoerliFlag, SepoliaFlag, ScrollAlphaFlag, ScrollSepoliaFlag)
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RopstenFlag, RinkebyFlag, GoerliFlag, SepoliaFlag, ScrollAlphaFlag, ScrollSepoliaFlag, ScrollFlag)
CheckExclusive(ctx, LightServeFlag, SyncModeFlag, "light")
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer
if ctx.GlobalString(GCModeFlag.Name) == GCModeArchive && ctx.GlobalUint64(TxLookupLimitFlag.Name) != 0 {
Expand Down Expand Up @@ -1776,6 +1787,25 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
// disable prefetch
log.Info("Prefetch disabled")
cfg.NoPrefetch = true
case ctx.GlobalBool(ScrollFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 53435222224
}
cfg.Genesis = core.DefaultScrollMainnetGenesisBlock()
// forced for mainnet
log.Info("Setting flag", "--l1.confirmations", "finalized")
stack.Config().L1Confirmations = rpc.FinalizedBlockNumber
log.Info("Setting flag", "--l1.sync.startblock", "18305000")
stack.Config().L1DeploymentBlock = 18305000
// disable pruning
if ctx.GlobalString(GCModeFlag.Name) != GCModeArchive {
log.Crit("Must use --gcmode=archive")
}
log.Info("Pruning disabled")
cfg.NoPruning = true
// disable prefetch
log.Info("Prefetch disabled")
cfg.NoPrefetch = true
case ctx.GlobalBool(DeveloperFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1337
Expand Down Expand Up @@ -2024,6 +2054,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
genesis = core.DefaultScrollAlphaGenesisBlock()
case ctx.GlobalBool(ScrollSepoliaFlag.Name):
genesis = core.DefaultScrollSepoliaGenesisBlock()
case ctx.GlobalBool(ScrollFlag.Name):
genesis = core.DefaultScrollMainnetGenesisBlock()
case ctx.GlobalBool(DeveloperFlag.Name):
Fatalf("Developer chains are ephemeral")
}
Expand Down
12 changes: 12 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,18 @@ func DefaultScrollSepoliaGenesisBlock() *Genesis {
}
}

// DefaultScrollMainnetGenesisBlock returns the Scroll mainnet genesis block.
func DefaultScrollMainnetGenesisBlock() *Genesis {
return &Genesis{
Config: params.ScrollMainnetChainConfig,
Timestamp: 0x6523abf8,
ExtraData: hexutil.MustDecode("0x4c61206573746f6e7465636f206573746173206d616c6665726d6974612e000068340d76bBa5996FC67b5f7152cb3A65f5A398C10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 10000000,
Difficulty: big.NewInt(1),
Alloc: decodePrealloc(scrollMainnetAllocData),
}
}

// DeveloperGenesisBlock returns the 'geth --dev' genesis block.
func DeveloperGenesisBlock(period uint64, gasLimit uint64, faucet common.Address) *Genesis {
// Override the default period to the user requested one
Expand Down
1 change: 1 addition & 0 deletions core/genesis_alloc.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func TestGenesisHashes(t *testing.T) {
// {DefaultSepoliaGenesisBlock(), params.SepoliaGenesisHash},
// {DefaultScrollAlphaGenesisBlock(), params.ScrollAlphaGenesisHash},
{DefaultScrollSepoliaGenesisBlock(), params.ScrollSepoliaGenesisHash},
{DefaultScrollMainnetGenesisBlock(), params.ScrollMainnetGenesisHash},
} {
// Test via MustCommit
if have := c.genesis.MustCommit(rawdb.NewMemoryDatabase()).Hash(); have != c.want {
Expand Down
11 changes: 10 additions & 1 deletion params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,22 @@ var ScrollAlphaBootnodes = []string{
"enode://cf85bfa5828239b1f6b21758579ee8aaaba2a1fb4c658d6967c5f7ed4f040d95dee5b5cef0c77d656a191f6b0875dd03f05b30a3b2b3e15bfcf18b500d8f634c@35.155.117.77:30303",
}

// ScrollSepoliaBootnodes are the enode URLs of the P2P bootstrap nodes running on the Scroll Alpha test network.
// ScrollSepoliaBootnodes are the enode URLs of the P2P bootstrap nodes running on the Scroll Sepolia test network.
var ScrollSepoliaBootnodes = []string{
"enode://ceb1636bac5cbb262e5ad5b2cd22014bdb35ffe7f58b3506970d337a63099481814a338dbcd15f2d28757151e3ecd40ba38b41350b793cd0d910ff0436654f8c@35.85.84.250:30303",
"enode://29cee709c400533ae038a875b9ca975c8abef9eade956dcf3585e940acd5c0ae916968f514bd37d1278775aad1b7db30f7032a70202a87fd7365bd8de3c9f5fc@44.242.39.33:30303",
"enode://dd1ac5433c5c2b04ca3166f4cb726f8ff6d2da83dbc16d9b68b1ea83b7079b371eb16ef41c00441b6e85e32e33087f3b7753ea9e8b1e3f26d3e4df9208625e7f@54.148.111.168:30303",
}

// ScrollMainnetBootnodes are the enode URLs of the P2P bootstrap nodes running on the Scroll mainnet.
var ScrollMainnetBootnodes = []string{
"enode://11f62f1592352bdf47fcd1521a5b4b753e31cedbff5c2ff3f5aafb028c1d774ef3fd5880d73aa871c0f571733cd0dcc93af3ad21e65281794de0c26c96aee2c0@54.186.123.248:30303",
"enode://f2fe493a112d0c5ded394e288be1e95edac0c422f60fc00b6c23ee3c39a6fd91e9c6f62289fd519da692a6f0ff0805c4466715642770c83d215a0ce8224b7eb1@44.227.91.206:30303",
"enode://5bb85c970acff2eff7327d06616434fe50489f0e994e82abdcd7b9d61ebc0e0801f2b931ad0d8b0e9cfc7eac994d729974b9930c2e13c33822406b82f08f1be2@44.237.194.52:30303",
"enode://f15a5982a9fdfc5eb88b1471aeeb4656fb8fa62339769c024af2cd7f57cca9be82d6f49d9c4c77166d706f9d7a7fc748ac7c2e4b14f661b88f9507df015d3b0a@52.35.203.107:30303",
"enode://5623eb16ae4412bead2504d419ccf58a8e3690613531951110e1aa53a65a7bdede1dc02b7b7f05119aa314d1898d1e8fb994c97b445328261624a0b8049ff580@54.70.236.187:30303",
}

var V5Bootnodes = []string{
// Teku team's bootnode
"enr:-KG4QOtcP9X1FbIMOe17QNMKqDxCpm14jcX5tiOE4_TyMrFqbmhPZHK_ZPG2Gxb1GE2xdtodOfx9-cgvNtxnRyHEmC0ghGV0aDKQ9aX9QgAAAAD__________4JpZIJ2NIJpcIQDE8KdiXNlY3AyNTZrMaEDhpehBDbZjM_L9ek699Y7vhUJ-eAdMyQW_Fil522Y0fODdGNwgiMog3VkcIIjKA",
Expand Down
39 changes: 38 additions & 1 deletion params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
GoerliGenesisHash = common.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a")
ScrollAlphaGenesisHash = common.HexToHash("0xa4fc62b9b0643e345bdcebe457b3ae898bef59c7203c3db269200055e037afda")
ScrollSepoliaGenesisHash = common.HexToHash("0xaa62d1a8b2bffa9e5d2368b63aae0d98d54928bd713125e3fd9e5c896c68592c")
ScrollMainnetGenesisHash = common.HexToHash("0xb0763bf0c49a41cf260a5d58113cbd4f2ae630a27ed8d7f260d57593bf4dd407")
)

// TrustedCheckpoints associates each known checkpoint with the genesis hash of
Expand Down Expand Up @@ -297,7 +298,6 @@ var (
},
}

// TODO fix this config
ScrollSepoliaChainConfig = &ChainConfig{
ChainID: big.NewInt(534351),
HomesteadBlock: big.NewInt(0),
Expand Down Expand Up @@ -335,6 +335,43 @@ var (
},
}

ScrollMainnetChainConfig = &ChainConfig{
ChainID: big.NewInt(53435222224),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
MuirGlacierBlock: nil,
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ArrowGlacierBlock: nil,
ArchimedesBlock: big.NewInt(0),
ShanghaiBlock: big.NewInt(0),
Clique: &CliqueConfig{
Period: 3,
Epoch: 30000,
},
Scroll: ScrollConfig{
UseZktrie: true,
MaxTxPerBlock: &ScrollMaxTxPerBlock,
MaxTxPayloadBytesPerBlock: &ScrollMaxTxPayloadBytesPerBlock,
FeeVaultAddress: &rcfg.ScrollFeeVaultAddress,
EnableEIP2718: false,
EnableEIP1559: false,
L1Config: &L1Config{
L1ChainId: 1,
L1MessageQueueAddress: common.HexToAddress("0x72FF472b663Bb201B02258c4d2a34cD75867A6E3"),
NumL1MessagesPerBlock: 10,
},
},
}

// AllEthashProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Ethash consensus.
//
Expand Down
6 changes: 3 additions & 3 deletions params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
)

const (
VersionMajor = 4 // Major version component of the current release
VersionMinor = 5 // Minor version component of the current release
VersionMajor = 5 // Major version component of the current release
VersionMinor = 0 // Minor version component of the current release
VersionPatch = 0 // Patch version component of the current release
VersionMeta = "sepolia" // Version metadata to append to the version string
VersionMeta = "mainnet" // Version metadata to append to the version string
)

// Version holds the textual version string.
Expand Down

0 comments on commit b3d0f16

Please sign in to comment.