Skip to content

Commit

Permalink
add new configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Thegaram committed Sep 30, 2023
1 parent fe8232a commit 1c8c7ae
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 3 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 @@ -858,6 +862,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 @@ -916,6 +923,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 @@ -1378,6 +1387,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 @@ -1573,7 +1584,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 @@ -1761,6 +1772,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 = 53435222222 // TODO
}
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", "18221690")
stack.Config().L1DeploymentBlock = 18221690 // TODO
// 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 @@ -2003,6 +2033,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: 0x6513fa42,
ExtraData: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000069b800387f915A5fc6397f4C0e679F11360cFb880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), // TODO
GasLimit: 8000000, // TODO
Difficulty: big.NewInt(1),
Alloc: decodePrealloc(scrollMainnetAllocData), // TODO
}
}

// 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
12 changes: 11 additions & 1 deletion params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,23 @@ 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.
// TODO
var ScrollMainnetBootnodes = []string{
"enode://0266832ec9bf7d99ad14021733dbe1605f5a9fba4120c9134a4352ee8771acfe6f70b4d45db5d0b10f893512f649a4572a190e8593acac9f9746dd87261b29ea@54.186.123.248:30303",
"enode://12530ec316670bb96f31b90edb31aa8318ed7811d9b4d980ecd5a7b24d55df93e363da6bc2c455c2947641b95e1b6e26225f833cfa598eda620017821b75ffcb@44.227.91.206:30303",
"enode://7a836c8f6cdec771f7bbed49781c625b6dea86502e6e8194f24912e529b61cea8fad759a3592f2a4449adda35430931643da6388697d89953158359e4559735c@44.237.194.52:30303",
"enode://47854542163cabf6fdc86eb063306e43b57be4e368329613933875bba519da6bae6f5180cc8825ba2e04ba839703035c555e70f90c9e17135203a5b24000e2ea@52.35.203.107:30303",
"enode://a4c51001f947606510f18c73937780b1276131009839f03702fe0b2b78ec2fb210f6eee6b3818c1dcafc87ea4630f9364d767f4e7a93e5ffba345b9763491d9d@54.70.236.187:30303",
}

var V5Bootnodes = []string{
// Teku team's bootnode
"enr:-KG4QOtcP9X1FbIMOe17QNMKqDxCpm14jcX5tiOE4_TyMrFqbmhPZHK_ZPG2Gxb1GE2xdtodOfx9-cgvNtxnRyHEmC0ghGV0aDKQ9aX9QgAAAAD__________4JpZIJ2NIJpcIQDE8KdiXNlY3AyNTZrMaEDhpehBDbZjM_L9ek699Y7vhUJ-eAdMyQW_Fil522Y0fODdGNwgiMog3VkcIIjKA",
Expand Down
40 changes: 39 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("0x6fe824d0b25fbd1e81414e085779491a13a9dfdf919506dec52ae444e5eb4ed9") // TODO
)

// 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,44 @@ var (
},
}

// TODO update
ScrollMainnetChainConfig = &ChainConfig{
ChainID: big.NewInt(53435222222), // TODO
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("0x10c250C5357a84e42DB8F36F6242D49c8f01bd53"), // TODO
NumL1MessagesPerBlock: 10,
},
},
}

// AllEthashProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Ethash consensus.
//
Expand Down

0 comments on commit 1c8c7ae

Please sign in to comment.