Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition: Add support for Hypra and EthashB3 #617

Draft
wants to merge 48 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4ef2a81
Iniital Hypra support
JABirchall Feb 7, 2024
8963f35
Merge branch 'etclabscore:master' into master
JABirchall Feb 7, 2024
824ec66
params: Align Hypra mainnet blocks
JABirchall Feb 7, 2024
009e779
params: Include Veldin definition for Hypra
JABirchall Feb 7, 2024
56c83dd
params: Add reward Schedule, remove etc improvments
JABirchall Feb 7, 2024
1c3036f
params: Add Hypra alloc data
JABirchall Feb 7, 2024
6ef0c0d
flags: Added --hypra flag
JABirchall Feb 7, 2024
16782da
params: Added Hypra bootnodes
JABirchall Feb 7, 2024
d1a8fd8
ethashb3: rename structs to ethashb3, remove classic epoch forks.
JABirchall Feb 8, 2024
cc9e24c
types, params: Added getters and setters for Veldin and fixed some ge…
JABirchall Feb 8, 2024
48ad2b9
type: Add veldin?
JABirchall Feb 8, 2024
10c05c2
gensisT: Veldin needed to be defined here?
JABirchall Feb 8, 2024
5a95422
params: fix *uint64 to uint64
JABirchall Feb 8, 2024
6bea66a
ethconfig: Added ethashb3 to consensus creation
JABirchall Feb 8, 2024
0c9aa5f
ethashb3: does not support ECIP1099Block
JABirchall Feb 8, 2024
6248090
ethconfig: added EthashB3 defaults
JABirchall Feb 8, 2024
e23deb8
ethconfig: accidentally overwrote the ethash defaults with ethashb3
JABirchall Feb 8, 2024
1dc0eff
ethconfig: Added Ethashb3 to CreateCensensusEngine. Defered to Create…
JABirchall Feb 11, 2024
9e3b375
params: Fixed getting Scheduled rewards support for ethashb3
JABirchall Feb 11, 2024
e7a5f5f
params, ethashb3: Added rewards and fixed ethashb3 dynamic difficulty
JABirchall Feb 11, 2024
6836fcc
params: Add ethashb3 to mustset
JABirchall Feb 11, 2024
66ac6e4
Params: update chainspec and genesis hash test
JABirchall Feb 12, 2024
86a3180
params: correct some EthashB3 forks
JABirchall Feb 12, 2024
4eef8b7
flags: makeConsensusEngine rename
JABirchall Feb 12, 2024
1112720
genesis: some changes to include Hypra genesis in other areas.
JABirchall Feb 13, 2024
ba14c5d
params, forkid: Added support for hypra fake use of Grey Glacier for …
JABirchall Feb 13, 2024
0944ae5
Add per network incompatible map for such networks like Hypra who bun…
JABirchall Feb 13, 2024
592cada
forkid: readd other network tests after debugging Hypra
JABirchall Feb 13, 2024
3966827
params: Add some comments and fixed typo
JABirchall Feb 13, 2024
c9f373a
params: Flip the condition correctly getting the rewards for EthashB3
JABirchall Feb 13, 2024
e8b80f4
params: Fix veldin rewards causing invalid merkles
JABirchall Feb 13, 2024
593a6f5
params: Update checkpoint
JABirchall Feb 13, 2024
5a26d5d
core: Uncle maker patch, a miner must be 2 blocks ahead to fork.
JABirchall Feb 13, 2024
18d0b66
params: Better aligned.
JABirchall Feb 13, 2024
80e244d
core: Symatically match Hypra Gaspar to enable EIP3860 EVM changes.
JABirchall Feb 20, 2024
8282bb9
Revert "core: Symatically match Hypra Gaspar to enable EIP3860 EVM ch…
JABirchall Mar 7, 2024
6a72900
Define Gaspar fork block
JABirchall Mar 7, 2024
6f6fdbd
Gaspar EVM flags
JABirchall Mar 8, 2024
655cbb2
Change reward assignment to fix merkle root.
JABirchall Mar 8, 2024
7a2a9e0
Params: Move shanghai fork blocks.
JABirchall Mar 10, 2024
4ce638d
Params: unnecessary blank assignment
JABirchall Mar 10, 2024
a3b77e2
Merge branch 'master' into master
JABirchall Mar 15, 2024
809bc53
Update
Apr 12, 2024
eda3e91
Merge pull request #1 from Yooshikii/master
JABirchall Apr 13, 2024
2787cb6
run toml generate
JABirchall Jun 16, 2024
8170edd
ethconfig - Fix sync issues due to conflicting ethash and ethhasb3 be…
JABirchall Jun 16, 2024
0b97541
les - fix les client
JABirchall Jun 16, 2024
437774a
idea comment
JABirchall Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ run:
- params/alloc_mintme.go
- evmc/*


linters:
disable-all: true
enable:
Expand All @@ -29,7 +30,7 @@ linters:
- durationcheck
- exportloopref
- whitespace

-
# - structcheck # lots of false positives
# - errcheck #lot of false positives
# - contextcheck
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Upstream development from [ethereum/go-ethereum](https://github.com/ethereum/go-
Networks supported by the respective go-ethereum packaged `geth` program.

| Ticker | Consensus | Network | core-geth | ethereum/go-ethereum |
| --- | --- | --- | --- | --- |
| ETC | :zap: | Ethereum Classic | :heavy_check_mark: | |
| ETH | :zap: | Ethereum (Foundation) | :heavy_check_mark: | :heavy_check_mark: |
|--------|-------------------|---------------------------------------| --- | --- |
| ETC | :zap: Etchash | Ethereum Classic | :heavy_check_mark: | |
| ETH | :zap: Ethash | Ethereum (Foundation) | :heavy_check_mark: | :heavy_check_mark: |
| - | :zap: :handshake: | Private chains | :heavy_check_mark: | :heavy_check_mark: |
| | :zap: | Mordor (Geth+Parity ETH PoW Testnet) | :heavy_check_mark: | |
| | :zap: | Morden (Geth+Parity ETH PoW Testnet) | | |
Expand All @@ -31,11 +31,18 @@ Networks supported by the respective go-ethereum packaged `geth` program.
| | :handshake: | Kovan (Parity-only ETH PoA Testnet) | | |
| | | Tobalaba (EWF Testnet) | | |
| | | Ephemeral development PoA network | :heavy_check_mark: | :heavy_check_mark: |
| MINTME | :zap: | MintMe.com Coin | :heavy_check_mark: | |
| MINTME | :zap: Lyra2 | MintMe.com Coin | :heavy_check_mark: | |
| HYP | :zap: EthashB3 | Hypra Network | :heavy_check_mark: | |

- :zap: = __Proof of Work__
- :handshake: = __Proof of Authority__

Supported Algorithms
- Ethash
- Etchash
- EthashB3
- Lyra2

<a name="ellaism-footnote">1</a>: This is originally an [Ellaism
Project](https://github.com/ellaism). However, A [recent hard
fork](https://github.com/ellaism/specs/blob/master/specs/2018-0003-wasm-hardfork.md)
Expand Down
4 changes: 4 additions & 0 deletions cmd/devp2p/nodesetcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ func ethFilter(args []string) (nodeFilter, error) {
case "mintme":
gb := core.GenesisToBlock(params.DefaultMintMeGenesisBlock(), nil)
filter = forkid.NewStaticFilter(params.MintMeChainConfig, gb)
case "hypra":
gb := core.GenesisToBlock(params.DefaultHypraGenesisBlock(), nil)
filter = forkid.NewStaticFilter(params.HypraChainConfig, gb)

default:
return nil, fmt.Errorf("unknown network %q", args[0])
}
Expand Down
1 change: 1 addition & 0 deletions cmd/echainspec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var defaultChainspecValues = map[string]ctypes.Configurator{
"sepolia": params.DefaultSepoliaGenesisBlock(),

"mintme": params.DefaultMintMeGenesisBlock(),
"hypra": params.DefaultHypraGenesisBlock(),
}

var defaultChainspecNames = func() []string {
Expand Down
89 changes: 65 additions & 24 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ import (
"strings"
"time"

"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/ethashb3"
"github.com/ethereum/go-ethereum/params/types/ctypes"

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -194,11 +198,17 @@ var (
Usage: "Sepolia network: pre-configured proof-of-work test network",
Category: flags.EthCategory,
}
HypraFlag = &cli.BoolFlag{
Name: "hypra",
Usage: "Hypra Network mainnet: pre-configured Hypra Network mainnet",
Category: flags.EthCategory,
}
HoleskyFlag = &cli.BoolFlag{
Name: "holesky",
Usage: "Holesky network: pre-configured proof-of-stake test network",
Category: flags.EthCategory,
}

// Dev mode
DeveloperFlag = &cli.BoolFlag{
Name: "dev",
Expand Down Expand Up @@ -1139,6 +1149,7 @@ var (
MainnetFlag,
ClassicFlag,
MintMeFlag,
HypraFlag,
}, TestnetFlags...)

// DatabaseFlags is the flag group of all database flags.
Expand Down Expand Up @@ -1217,6 +1228,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.ClassicBootnodes
case ctx.Bool(MintMeFlag.Name):
urls = params.MintMeBootnodes
case ctx.Bool(HypraFlag.Name):
urls = params.HypraBootnodes
case ctx.Bool(MordorFlag.Name):
urls = params.MordorBootnodes
case ctx.Bool(SepoliaFlag.Name):
Expand Down Expand Up @@ -1260,6 +1273,8 @@ func setBootstrapNodesV5(ctx *cli.Context, cfg *p2p.Config) {
urls = params.GoerliBootnodes
case ctx.Bool(MintMeFlag.Name):
urls = params.MintMeBootnodes
case ctx.Bool(HypraFlag.Name):
urls = params.HypraBootnodes
case cfg.BootstrapNodesV5 != nil:
return // already set, don't apply defaults.
}
Expand Down Expand Up @@ -1730,6 +1745,8 @@ func dataDirPathForCtxChainConfig(ctx *cli.Context, baseDataDirPath string) stri
return filepath.Join(baseDataDirPath, "sepolia")
case ctx.Bool(MintMeFlag.Name):
return filepath.Join(baseDataDirPath, "mintme")
case ctx.Bool(HypraFlag.Name):
return filepath.Join(baseDataDirPath, "hypra")
case ctx.Bool(HoleskyFlag.Name):
return filepath.Join(baseDataDirPath, "holesky")
}
Expand Down Expand Up @@ -1987,7 +2004,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, DeveloperPoWFlag, GoerliFlag, SepoliaFlag, ClassicFlag, MordorFlag, MintMeFlag, HoleskyFlag)
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, DeveloperPoWFlag, GoerliFlag, SepoliaFlag, ClassicFlag, MordorFlag, MintMeFlag, HypraFlag, HoleskyFlag)
CheckExclusive(ctx, LightServeFlag, SyncModeFlag, "light")
CheckExclusive(ctx, DeveloperFlag, DeveloperPoWFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer

Expand Down Expand Up @@ -2560,6 +2577,8 @@ func genesisForCtxChainConfig(ctx *cli.Context) *genesisT.Genesis {
genesis = params.DefaultGoerliGenesisBlock()
case ctx.Bool(MintMeFlag.Name):
genesis = params.DefaultMintMeGenesisBlock()
case ctx.Bool(HypraFlag.Name):
genesis = params.DefaultHypraGenesisBlock()
case ctx.Bool(HoleskyFlag.Name):
genesis = params.DefaultHoleskyGenesisBlock()
case ctx.Bool(DeveloperFlag.Name):
Expand All @@ -2581,31 +2600,10 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
gspec = MakeGenesis(ctx)
chainDb = MakeChainDatabase(ctx, stack, readonly)
)
cliqueConfig, err := core.LoadCliqueConfig(chainDb, gspec)
if err != nil {
Fatalf("%v", err)
}
ethashConfig := ethconfig.Defaults.Ethash

// ETC-specific configuration: ECIP1099 modifies the original Ethash algo, doubling the epoch size.
if gspec != nil && gspec.Config != nil {
ethashConfig.ECIP1099Block = gspec.GetEthashECIP1099Transition() // This will panic if the genesis config field is not nil.
}

var lyra2Config *lyra2.Config
if ctx.Bool(MintMeFlag.Name) {
lyra2Config = &lyra2.Config{}
}
engine := makeConsensusEngine(ctx, stack, gspec, chainDb)

// Toggle PoW modes at user request.
if ctx.Bool(FakePoWFlag.Name) {
ethashConfig.PowMode = ethash.ModeFake
} else if ctx.Bool(FakePoWPoissonFlag.Name) {
ethashConfig.PowMode = ethash.ModePoissonFake
}

engine := ethconfig.CreateConsensusEngine(stack, &ethashConfig, cliqueConfig, lyra2Config, nil, false, chainDb)
if gcmode := ctx.String(GCModeFlag.Name); gcmode != gcModeFull && gcmode != gcModeArchive {
if gcmode := ctx.String(GCModeFlag.Name); gcmode != "full" && gcmode != "archive" {
Fatalf("--%s must be either 'full' or 'archive'", GCModeFlag.Name)
}
scheme, err := rawdb.ParseStateScheme(ctx.String(StateSchemeFlag.Name), chainDb)
Expand Down Expand Up @@ -2651,6 +2649,49 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
return chain, chainDb
}

// Create a Consensus Engine for a specific chains config
func makeConsensusEngine(ctx *cli.Context, stack *node.Node, gspec *genesisT.Genesis, chainDb ethdb.Database) (engine consensus.Engine) {
switch gspec.GetConsensusEngineType() {
case ctypes.ConsensusEngineT_Ethash:
ethashConfig := ethconfig.Defaults.Ethash
if gspec != nil && gspec.Config != nil {
ethashConfig.ECIP1099Block = gspec.GetEthashECIP1099Transition() // This will panic if the genesis config field is not nil.
}
if ctx.Bool(FakePoWFlag.Name) {
ethashConfig.PowMode = ethash.ModeFake
} else if ctx.Bool(FakePoWPoissonFlag.Name) {
ethashConfig.PowMode = ethash.ModePoissonFake
}
engine = ethconfig.CreateConsensusEngineEthash(stack, &ethashConfig, nil, false)

case ctypes.ConsensusEngineT_EthashB3:
ethashb3Config := ethconfig.Defaults.EthashB3
if ctx.Bool(FakePoWFlag.Name) {
ethashb3Config.PowMode = ethashb3.ModeFake
} else if ctx.Bool(FakePoWPoissonFlag.Name) {
ethashb3Config.PowMode = ethashb3.ModePoissonFake
}
engine = ethconfig.CreateConsensusEngineEthashB3(stack, &ethashb3Config, nil, false)

case ctypes.ConsensusEngineT_Clique:
cliqueConfig, err := core.LoadCliqueConfig(chainDb, gspec)
if err != nil {
Fatalf("%v", err)
}
engine = ethconfig.CreateConsensusEngineClique(cliqueConfig, chainDb)

case ctypes.ConsensusEngineT_Lyra2:
var lyra2Config *lyra2.Config
if ctx.Bool(MintMeFlag.Name) {
lyra2Config = &lyra2.Config{}
}
engine = ethconfig.CreateConsensusEngineLyra2(lyra2Config, nil, false)

}

return engine
}

// MakeConsolePreloads retrieves the absolute paths for the console JavaScript
// scripts to preload before starting.
func MakeConsolePreloads(ctx *cli.Context) []string {
Expand Down
2 changes: 1 addition & 1 deletion consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ func (ethash *Ethash) Prepare(chain consensus.ChainHeaderReader, header *types.H
// Finalize implements consensus.Engine, accumulating the block and uncle rewards.
func (ethash *Ethash) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) {
// Accumulate any block and uncle rewards and commit the final state root
mutations.AccumulateRewards(chain.Config(), state, header, uncles)
mutations.AccumulateRewards(chain.Config(), state, header, uncles, txs)
}

// FinalizeAndAssemble implements consensus.Engine, accumulating the block and
Expand Down
Loading