Skip to content

Commit

Permalink
Merge pull request #71 from morph-l2/cherry-pick-config
Browse files Browse the repository at this point in the history
Add Morph holesky config (#68)
  • Loading branch information
FletcherMan committed Apr 28, 2024
2 parents 279c693 + 16f8016 commit 5cb3e94
Show file tree
Hide file tree
Showing 12 changed files with 103 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 @@ -73,6 +73,7 @@ It expects the genesis file as argument.`,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
},
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 @@ -143,6 +143,8 @@ func remoteConsole(ctx *cli.Context) error {
path = filepath.Join(path, "scroll-sepolia")
} else if ctx.GlobalBool(utils.ScrollFlag.Name) {
path = filepath.Join(path, "scroll")
} else if ctx.GlobalBool(utils.MorphHoleskyFlag.Name) {
path = filepath.Join(path, "morph-holesky")
}
}
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 @@ -88,6 +88,7 @@ Remove blockchain and state databases`,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
},
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 @@ -107,6 +108,7 @@ Remove blockchain and state databases`,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
},
}
dbCompactCmd = cli.Command{
Expand All @@ -124,6 +126,7 @@ Remove blockchain and state databases`,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
utils.CacheFlag,
utils.CacheDatabaseFlag,
},
Expand All @@ -146,6 +149,7 @@ corruption if it is aborted during execution'!`,
utils.GoerliFlag,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.MorphHoleskyFlag,
utils.ScrollFlag,
},
Description: "This command looks up the specified database key from the database.",
Expand All @@ -166,6 +170,7 @@ corruption if it is aborted during execution'!`,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
},
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 @@ -186,6 +191,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
},
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 @@ -206,6 +212,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
},
Description: "This command looks up the specified database key from the database.",
}
Expand All @@ -225,6 +232,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
},
Description: "This command displays information about the freezer index.",
}
Expand All @@ -243,6 +251,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
},
Description: "The import command imports the specific chain data from an RLP encoded stream.",
}
Expand All @@ -261,6 +270,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
},
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 @@ -151,6 +151,7 @@ var (
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
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 @@ -69,6 +69,7 @@ var (
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
utils.CacheTrieJournalFlag,
utils.BloomFilterSizeFlag,
},
Expand Down Expand Up @@ -103,6 +104,7 @@ the trie clean cache with default directory will be deleted.
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
},
Description: `
geth snapshot verify-state <state-root>
Expand All @@ -127,6 +129,7 @@ In other words, this command does the snapshot to trie conversion.
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
},
Description: `
geth snapshot traverse-state <state-root>
Expand All @@ -153,6 +156,7 @@ It's also usable without snapshot enabled.
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
},
Description: `
geth snapshot traverse-rawstate <state-root>
Expand Down Expand Up @@ -180,6 +184,7 @@ It's also usable without snapshot enabled.
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
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 @@ -50,6 +50,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.ScrollAlphaFlag,
utils.ScrollSepoliaFlag,
utils.ScrollFlag,
utils.MorphHoleskyFlag,
utils.SyncModeFlag,
utils.ExitWhenSyncedFlag,
utils.GCModeFlag,
Expand Down
30 changes: 29 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ var (
Name: "scroll",
Usage: "Scroll mainnet",
}
MorphHoleskyFlag = cli.BoolFlag{
Name: "morph-holesky",
Usage: "Morph Holesky test network",
}
DeveloperFlag = cli.BoolFlag{
Name: "dev",
Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled",
Expand Down Expand Up @@ -906,6 +910,9 @@ func MakeDataDir(ctx *cli.Context) string {
if ctx.GlobalBool(ScrollFlag.Name) {
return filepath.Join(path, "scroll")
}
if ctx.GlobalBool(MorphHoleskyFlag.Name) {
return filepath.Join(path, "morph-holesky")
}
return path
}
Fatalf("Cannot determine default data directory, please set manually (--datadir)")
Expand Down Expand Up @@ -968,6 +975,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.ScrollSepoliaBootnodes
case ctx.GlobalBool(ScrollFlag.Name):
urls = params.ScrollMainnetBootnodes
case ctx.GlobalBool(MorphHoleskyFlag.Name):
urls = params.MorphHoleskyBootnodes
case cfg.BootstrapNodes != nil || len(urls) == 0:
return // already set, don't apply defaults.
}
Expand Down Expand Up @@ -1419,6 +1428,8 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "scroll-sepolia")
case ctx.GlobalBool(ScrollFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "scroll")
case ctx.GlobalBool(MorphHoleskyFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "morph-holesky")

}
}
Expand Down Expand Up @@ -1625,7 +1636,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, ScrollFlag)
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RopstenFlag, RinkebyFlag, GoerliFlag, SepoliaFlag, ScrollAlphaFlag, ScrollSepoliaFlag, ScrollFlag, MorphHoleskyFlag)
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 @@ -1827,6 +1838,21 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
// disable prefetch
log.Info("Prefetch disabled")
cfg.NoPrefetch = true
case ctx.GlobalBool(MorphHoleskyFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 2810
}
cfg.Genesis = core.DefaultMorphHoleskyGenesisBlock()
// forced for mainnet
// 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 @@ -2076,6 +2102,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
genesis = core.DefaultScrollSepoliaGenesisBlock()
case ctx.GlobalBool(ScrollFlag.Name):
genesis = core.DefaultScrollMainnetGenesisBlock()
case ctx.GlobalBool(MorphHoleskyFlag.Name):
genesis = core.DefaultMorphHoleskyGenesisBlock()
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 @@ -471,6 +471,18 @@ func DefaultScrollMainnetGenesisBlock() *Genesis {
}
}

// DefaultMorphHoleskyGenesisBlock returns the Morph holesky genesis block.
func DefaultMorphHoleskyGenesisBlock() *Genesis {
return &Genesis{
Config: params.MorphHoleskyChainConfig,
Timestamp: 0x663050a0,
ExtraData: []byte{},
GasLimit: 10000000,
Difficulty: big.NewInt(0),
Alloc: decodePrealloc(morphHoleskyAllocData),
}
}

// 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.

5 changes: 3 additions & 2 deletions core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ func TestGenesisHashes(t *testing.T) {
// {DefaultRinkebyGenesisBlock(), params.RinkebyGenesisHash},
// {DefaultSepoliaGenesisBlock(), params.SepoliaGenesisHash},
// {DefaultScrollAlphaGenesisBlock(), params.ScrollAlphaGenesisHash},
{DefaultScrollSepoliaGenesisBlock(), params.ScrollSepoliaGenesisHash},
{DefaultScrollMainnetGenesisBlock(), params.ScrollMainnetGenesisHash},
// {DefaultScrollSepoliaGenesisBlock(), params.ScrollSepoliaGenesisHash},
// {DefaultScrollMainnetGenesisBlock(), params.ScrollMainnetGenesisHash},
{DefaultMorphHoleskyGenesisBlock(), params.MorphHoleskyGenesisHash},
} {
// Test via MustCommit
if have := c.genesis.MustCommit(rawdb.NewMemoryDatabase()).Hash(); have != c.want {
Expand Down
7 changes: 7 additions & 0 deletions params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ var ScrollMainnetBootnodes = []string{
"enode://c7b2d94e95da343db6e667a01cef90376a592f2d277fbcbf6e9c9186734ed8003d01389571bd10cdbab7a6e5adfa6f0c7b55644d0db24e0b9deb4ec80f842075@54.70.236.187:30303",
}

// MorphHoleskyBootnodes are the enode URLs of the P2P bootstrap nodes running on the Morph Holesky test network.
var MorphHoleskyBootnodes = []string{
"enode://8c400a01a9457ab99219bb7d87677ecdd4638ccf6a5f81c8bcf89abcd59cca91bd27b82071760e7f7d8ef043ca6817278495509197a3fc4ed2fd34fd67fb123b@52.69.21.155:30303",
"enode://8eba7278fcb84a7b836a684fd4b62526af775633297974bf2b48584ea2f831a65a7ae7d914198f66b94820348cdad37533fc7336688b139ca27d30a7713867ab@35.76.156.3:30303",
"enode://588b64f887745a2f53a92312926c9d5ae03c64412860889a9c605570d7b71522a0774d254311752ac2cd44c68c3282ea125874f66ef7e65548573420d6cd98e2@35.78.13.184:30303",
}

var V5Bootnodes = []string{
// Teku team's bootnode
"enr:-KG4QOtcP9X1FbIMOe17QNMKqDxCpm14jcX5tiOE4_TyMrFqbmhPZHK_ZPG2Gxb1GE2xdtodOfx9-cgvNtxnRyHEmC0ghGV0aDKQ9aX9QgAAAAD__________4JpZIJ2NIJpcIQDE8KdiXNlY3AyNTZrMaEDhpehBDbZjM_L9ek699Y7vhUJ-eAdMyQW_Fil522Y0fODdGNwgiMog3VkcIIjKA",
Expand Down
31 changes: 31 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var (
ScrollAlphaGenesisHash = common.HexToHash("0xa4fc62b9b0643e345bdcebe457b3ae898bef59c7203c3db269200055e037afda")
ScrollSepoliaGenesisHash = common.HexToHash("0xaa62d1a8b2bffa9e5d2368b63aae0d98d54928bd713125e3fd9e5c896c68592c")
ScrollMainnetGenesisHash = common.HexToHash("0xbbc05efd412b7cd47a2ed0e5ddfcf87af251e414ea4c801d78b6784513180a80")
MorphHoleskyGenesisHash = common.HexToHash("0x74c3b27ba96d1f17f35849f51f5d786767bae9b1b63c338069a8cbd0e1d0b0b7")
)

// TrustedCheckpoints associates each known checkpoint with the genesis hash of
Expand Down Expand Up @@ -357,6 +358,36 @@ var (
},
}

MorphFeeVaultAddress = common.HexToAddress("0x48442aa154897eef141df231cc1517fc8c1d170f")
MorphHoleskyChainConfig = &ChainConfig{
ChainID: big.NewInt(2810),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: false,
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),
BernoulliBlock: big.NewInt(0),
CurieBlock: nil,
TerminalTotalDifficulty: big.NewInt(0),
Scroll: ScrollConfig{
UseZktrie: true,
MaxTxPerBlock: &ScrollMaxTxPerBlock,
MaxTxPayloadBytesPerBlock: &ScrollMaxTxPayloadBytesPerBlock,
FeeVaultAddress: &MorphFeeVaultAddress,
},
}

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

0 comments on commit 5cb3e94

Please sign in to comment.