Skip to content

Commit

Permalink
Add morph flag (#156)
Browse files Browse the repository at this point in the history
* add morph mainnet flag

* update

---------

Co-authored-by: fletcher.fan <[email protected]>
  • Loading branch information
FletcherMan and fletcher.fan authored Oct 21, 2024
1 parent 2f006c4 commit 7136388
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ It expects the genesis file as argument.`,
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Expand Down
2 changes: 2 additions & 0 deletions cmd/geth/consolecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ func remoteConsole(ctx *cli.Context) error {
path = filepath.Join(path, "goerli")
} else if ctx.GlobalBool(utils.SepoliaFlag.Name) {
path = filepath.Join(path, "sepolia")
} else if ctx.GlobalBool(utils.MorphFlag.Name) {
path = filepath.Join(path, "morph")
} else if ctx.GlobalBool(utils.MorphHoleskyFlag.Name) {
path = filepath.Join(path, "morph-holesky")
}
Expand Down
10 changes: 10 additions & 0 deletions cmd/geth/dbcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Remove blockchain and state databases`,
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
},
Usage: "Inspect the storage size for each type of data in the database",
Expand All @@ -102,6 +103,7 @@ Remove blockchain and state databases`,
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
},
}
Expand All @@ -117,6 +119,7 @@ Remove blockchain and state databases`,
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
utils.CacheFlag,
utils.CacheDatabaseFlag,
Expand All @@ -138,6 +141,7 @@ corruption if it is aborted during execution'!`,
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
},
Description: "This command looks up the specified database key from the database.",
Expand All @@ -155,6 +159,7 @@ corruption if it is aborted during execution'!`,
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
},
Description: `This command deletes the specified database key from the database.
Expand All @@ -173,6 +178,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
},
Description: `This command sets a given database key to the given value.
Expand All @@ -191,6 +197,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
},
Description: "This command looks up the specified database key from the database.",
Expand All @@ -208,6 +215,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
},
Description: "This command displays information about the freezer index.",
Expand All @@ -224,6 +232,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.RopstenFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
},
Description: "The import command imports the specific chain data from an RLP encoded stream.",
Expand All @@ -240,6 +249,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
utils.RopstenFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
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 @@ -145,6 +145,7 @@ var (
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
utils.VMEnableDebugFlag,
utils.NetworkIdFlag,
Expand Down
6 changes: 6 additions & 0 deletions cmd/geth/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var (
Category: "MISCELLANEOUS COMMANDS",
Flags: []cli.Flag{
utils.DataDirFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
utils.BloomFilterSizeFlag,
},
Expand Down Expand Up @@ -91,6 +92,7 @@ the trie clean cache with default directory will be deleted.
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
utils.CacheTrieJournalFlag,
utils.BloomFilterSizeFlag,
Expand Down Expand Up @@ -123,6 +125,7 @@ the trie clean cache with default directory will be deleted.
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
},
Description: `
Expand All @@ -145,6 +148,7 @@ In other words, this command does the snapshot to trie conversion.
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
},
Description: `
Expand All @@ -169,6 +173,7 @@ It's also usable without snapshot enabled.
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
},
Description: `
Expand All @@ -194,6 +199,7 @@ It's also usable without snapshot enabled.
utils.SepoliaFlag,
utils.RinkebyFlag,
utils.GoerliFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
utils.ExcludeCodeFlag,
utils.ExcludeStorageFlag,
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.RinkebyFlag,
utils.RopstenFlag,
utils.SepoliaFlag,
utils.MorphFlag,
utils.MorphHoleskyFlag,
utils.SyncModeFlag,
utils.ExitWhenSyncedFlag,
Expand Down
30 changes: 29 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ var (
Name: "sepolia",
Usage: "Sepolia network: pre-configured proof-of-work test network",
}
MorphFlag = cli.BoolFlag{
Name: "morph",
Usage: "Morph mainnet network",
}
MorphHoleskyFlag = cli.BoolFlag{
Name: "morph-holesky",
Usage: "Morph Holesky test network",
Expand Down Expand Up @@ -868,6 +872,9 @@ func MakeDataDir(ctx *cli.Context) string {
if ctx.GlobalBool(SepoliaFlag.Name) {
return filepath.Join(path, "sepolia")
}
if ctx.GlobalBool(MorphFlag.Name) {
return filepath.Join(path, "morph")
}
if ctx.GlobalBool(MorphHoleskyFlag.Name) {
return filepath.Join(path, "morph-holesky")
}
Expand Down Expand Up @@ -927,6 +934,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.RinkebyBootnodes
case ctx.GlobalBool(GoerliFlag.Name):
urls = params.GoerliBootnodes
case ctx.GlobalBool(MorphFlag.Name):
urls = params.MorphBootnodes
case ctx.GlobalBool(MorphHoleskyFlag.Name):
urls = params.MorphHoleskyBootnodes
case cfg.BootstrapNodes != nil || len(urls) == 0:
Expand Down Expand Up @@ -1375,6 +1384,8 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "goerli")
case ctx.GlobalBool(SepoliaFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "sepolia")
case ctx.GlobalBool(MorphFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "morph")
case ctx.GlobalBool(MorphHoleskyFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "morph-holesky")

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, MorphHoleskyFlag)
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RopstenFlag, RinkebyFlag, GoerliFlag, SepoliaFlag, MorphFlag, 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 @@ -1739,6 +1750,21 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
}
cfg.Genesis = core.DefaultGoerliGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.GoerliGenesisHash)
case ctx.GlobalBool(MorphFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 2818
}
cfg.Genesis = core.DefaultMorphMainnetGenesisBlock()
// 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(MorphHoleskyFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 2810
Expand Down Expand Up @@ -2010,6 +2036,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
genesis = core.DefaultRinkebyGenesisBlock()
case ctx.GlobalBool(GoerliFlag.Name):
genesis = core.DefaultGoerliGenesisBlock()
case ctx.GlobalBool(MorphFlag.Name):
genesis = core.DefaultMorphMainnetGenesisBlock()
case ctx.GlobalBool(MorphHoleskyFlag.Name):
genesis = core.DefaultMorphHoleskyGenesisBlock()
case ctx.GlobalBool(DeveloperFlag.Name):
Expand Down
11 changes: 11 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,17 @@ func DefaultSepoliaGenesisBlock() *Genesis {
}
}

func DefaultMorphMainnetGenesisBlock() *Genesis {
return &Genesis{
Config: params.MorphMainnetChainConfig,
Timestamp: 0x6715ede0,
ExtraData: []byte{},
GasLimit: 30000000,
Difficulty: big.NewInt(0),
Alloc: decodePrealloc(morphMainnetAllocData),
}
}

// DefaultMorphHoleskyGenesisBlock returns the Morph holesky genesis block.
func DefaultMorphHoleskyGenesisBlock() *Genesis {
return &Genesis{
Expand Down
2 changes: 2 additions & 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 @@ -174,6 +174,7 @@ func TestGenesisHashes(t *testing.T) {
// {DefaultRinkebyGenesisBlock(), params.RinkebyGenesisHash},
// {DefaultSepoliaGenesisBlock(), params.SepoliaGenesisHash},
{DefaultMorphHoleskyGenesisBlock(), params.MorphHoleskyGenesisHash},
{DefaultMorphMainnetGenesisBlock(), params.MorphMainnetGenesisHash},
} {
// Test via MustCommit
if have := c.genesis.MustCommit(rawdb.NewMemoryDatabase()).Hash(); have != c.want {
Expand Down
10 changes: 10 additions & 0 deletions params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ var GoerliBootnodes = []string{
"enode://a59e33ccd2b3e52d578f1fbd70c6f9babda2650f0760d6ff3b37742fdcdfdb3defba5d56d315b40c46b70198c7621e63ffa3f987389c7118634b0fefbbdfa7fd@51.15.119.157:40303",
}

var MorphBootnodes = []string{
"enode://53496aab21ab73f261551d823340b417ecd2cf69652ceba670162b990429e75c4dd6eb622dd96978d65f70c9db9964b3f477886c0b62297a51266168d367bab2@52.193.82.123:30303",
"enode://58773a8b58e70cda8d39ed7500b56f176b22c5d4faab88348a0835f333f25ae3b3a45bf7f3e9fd08245d1ff57d38d01540571c0221be2404ce93568f8472c3a0@52.197.80.227:30303",
"enode://86faa94f8221ae100c6f3aebc2f79941431ce2178f1f4374a73511230846bc26df4c336139e766668f5ba8daea56fdce74f61ecc31a2cba3788e70a2d15f5258@18.177.252.130:30303",
"enode://3e3b6350e0392ace589163e3c26dc27e142acc0e5975a1df57b0da21f1aa27c756dcdb82188a754597f6815e56fce706b033fdbc04e0fefa12b53bcee66b7a0f@18.118.70.50:30303",
"enode://aecc4b91f0a7b1f46a26021f33b0bf0bcadd461312a3140f9dc46dcac82e9943e7e485206862dce2b1d1f210742268b12b048c113ee8be1cf70b29012a22b920@3.134.21.91:30303",
"enode://352f9f59fd1c65442917b81e5b5a78d9590d14921aafc59830d231d34df066da1aff0e986ed272f1cbc76527ac539fbbda8c461e2545389b6cf97f9b26bc3199@3.127.133.228:30303",
"enode://abc60fccd847e9d9d9e5865aa69cef051239f01fa1108ba6a68082d5942f52e560452aeeffbe1aeca88a33afc5a0d97da9ba2111eb825c92cdd5d38727d36e1e@18.199.61.121: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",
Expand Down
32 changes: 32 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"golang.org/x/crypto/sha3"

"github.com/morph-l2/go-ethereum/common"
"github.com/morph-l2/go-ethereum/rollup/rcfg"
)

// Genesis hashes to enforce below configs on.
Expand All @@ -34,6 +35,7 @@ var (
RinkebyGenesisHash = common.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177")
GoerliGenesisHash = common.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a")
MorphHoleskyGenesisHash = common.HexToHash("0x74c3b27ba96d1f17f35849f51f5d786767bae9b1b63c338069a8cbd0e1d0b0b7")
MorphMainnetGenesisHash = common.HexToHash("0x649c9b1f9f831771529dbf286a63dd071530d73c8fa410997eebaf449acfa7a9")
)

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

MorphMainnetChainConfig = &ChainConfig{
ChainID: big.NewInt(2818),
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: big.NewInt(0),
DarwinTime: nil,
TerminalTotalDifficulty: big.NewInt(0),
Morph: MorphConfig{
UseZktrie: true,
MaxTxPerBlock: &MorphMaxTxPerBlock,
MaxTxPayloadBytesPerBlock: &MorphMaxTxPayloadBytesPerBlock,
FeeVaultAddress: &rcfg.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 7136388

Please sign in to comment.