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

RC/messnet 1 #182

Closed
wants to merge 48 commits into from
Closed
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
4949222
core: refactor reorganization function and data
meowsbits Sep 10, 2020
7c86e18
core: refactor writeBlockWithState reorg logic
meowsbits Sep 10, 2020
468b152
core: init ecbp11355 (MESS) implementation
meowsbits Sep 10, 2020
9ea9d7e
core,coregeth,ctypes,genesisT,goethereum,multigeth,parity: init ECBP1…
meowsbits Sep 10, 2020
2718253
core: implement new blockReorgMeter in reorg method
meowsbits Sep 10, 2020
9d82e60
core,eth: implement AF safety mechanisms at sync level
meowsbits Sep 10, 2020
df45f0a
params: set MESS activation numbers for classic and mordor
meowsbits Sep 10, 2020
379294e
core,eth: refactor af enable/disable for cleaner logs
meowsbits Sep 10, 2020
c050c21
core: break af logic to own file
meowsbits Sep 10, 2020
2d2c979
:nail_care:
meowsbits Sep 10, 2020
9101fe5
params: default MessNet chain config and genesis
meowsbits Sep 10, 2020
295c436
core: increase logging precision for MESS outcome
meowsbits Sep 10, 2020
ec27ad4
core: case-based tests for easy/hard MESS chain acceptance
meowsbits Sep 10, 2020
2fa5056
eth: actually install artificialFinalitySafetyLoop goroutine
meowsbits Sep 10, 2020
ae203d2
params: add comments on ETA for classic and mordor MESS activations
meowsbits Sep 10, 2020
88d5439
core: increase MESS log precision to 5
meowsbits Sep 10, 2020
84b87dd
core: add more test cases showing approaching limits
meowsbits Sep 10, 2020
0268698
core,params: (lint): goimports -w
meowsbits Sep 10, 2020
a34bf53
core: refactor reorg logic in writeBlockWithState
meowsbits Sep 11, 2020
905564e
core: refactor and document fn alternatives, select sinusoidal
meowsbits Sep 11, 2020
26047a5
core,go.mod,go.sum: include test that makes graphs, and remove same s…
meowsbits Sep 11, 2020
94e7fed
forkid: update forkid tests with classic,mordor ecbp11355 activations
meowsbits Sep 11, 2020
d8c7680
.golangci.yml: include AF unused functions in allowed deadcode
meowsbits Sep 11, 2020
f66da3f
core: lint, add sin fn test
meowsbits Sep 11, 2020
49e02ff
core: re-include redundant reorg condition
meowsbits Sep 11, 2020
9ff67d4
core: (lint): goimports -w
meowsbits Sep 11, 2020
9a62f37
ethash,go.mod,go.sum: init implement fakedelay for ethash pow faker s…
meowsbits Sep 11, 2020
fb26108
utils: set ethash config faker mode if FakePoW flag is set
meowsbits Sep 12, 2020
0177c08
ethash: improve test cases
meowsbits Sep 12, 2020
ccef362
forkid,confp: forkid skips BestPractice (BP) transitions
meowsbits Sep 11, 2020
6433598
core: improve and add AF log context when enabled
meowsbits Sep 11, 2020
b0f0144
params: no MESS activation set on ETC mainnet
meowsbits Sep 12, 2020
e3c5da3
core: refactor and tinker with logic around equivalent short reorg ac…
meowsbits Sep 12, 2020
c8234bb
eth,web3ext: install admin_ecbp11355 method
meowsbits Sep 12, 2020
e0cf2a0
main,utils: install --ecbp11355 flag for chain config overrides
meowsbits Sep 12, 2020
4fbe2d9
main,utils,core,eth,web3ext,params,coregeth,ctypes,genesisT,goethereu…
meowsbits Sep 12, 2020
52a0da1
params: (lint): goimports -w
meowsbits Sep 12, 2020
0c46755
confp: refactor method cross-compatibility namespacing logic
meowsbits Sep 12, 2020
5bc3fc2
core: fix typos, prettify ecbp1100 logging
meowsbits Sep 13, 2020
5c5b001
Merge branch 'feat/fakepow-delaysealer' into rc/messnet-1
meowsbits Sep 13, 2020
62f29e8
main,utils: init --messnet flag
meowsbits Sep 12, 2020
dff2851
go.sum: go mod update
meowsbits Sep 13, 2020
ae6babd
params: bump version to v1.11.14-rc-messnet-1
meowsbits Sep 13, 2020
f841a35
params: bump version to v1.11.14-rc-messnet-1+
meowsbits Sep 13, 2020
2093f14
eth,web3ext: admin_maxPeers RPC call
meowsbits Sep 15, 2020
6cdf1ba
Merge branch 'feat/admin-maxpeers' into rc/messnet-1
meowsbits Sep 15, 2020
af4b82e
params: bump version to v1.11.14-rc-messnet-2
meowsbits Sep 15, 2020
c52fc58
params: bump version to v1.11.14-rc-messnet-2+
meowsbits Sep 15, 2020
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: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ issues:
- path: cmd/faucet/
linters:
- deadcode
- path: core/blockchain_af.go
linters:
- deadcode
1 change: 1 addition & 0 deletions cmd/echainspec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var defaultChainspecValues = map[string]ctypes.Configurator{
"rinkeby": params.DefaultRinkebyGenesisBlock(),
"goerli": params.DefaultGoerliGenesisBlock(),
"yolov1": params.DefaultYoloV1GenesisBlock(),
"messnet": params.DefaultMessNetGenesisBlock(),

"social": params.DefaultSocialGenesisBlock(),
"ethersocial": params.DefaultEthersocialGenesisBlock(),
Expand Down
2 changes: 2 additions & 0 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ The export-preimages command export hash preimages to an RLP encoded stream`,
utils.SyncModeFlag,
utils.FakePoWFlag,
utils.ClassicFlag,
utils.MessNetFlag,
utils.MordorFlag,
utils.KottiFlag,
utils.SocialFlag,
Expand Down Expand Up @@ -221,6 +222,7 @@ Use "ethereum dump 0" to dump the genesis block.`,
utils.AncientFlag,
utils.CacheFlag,
utils.ClassicFlag,
utils.MessNetFlag,
utils.MordorFlag,
utils.KottiFlag,
utils.SocialFlag,
Expand Down
2 changes: 2 additions & 0 deletions cmd/geth/consolecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ func remoteConsole(ctx *cli.Context) error {
path = filepath.Join(path, "kotti")
} else if ctx.GlobalBool(utils.ClassicFlag.Name) {
path = filepath.Join(path, "classic")
} else if ctx.GlobalBool(utils.MessNetFlag.Name) {
path = filepath.Join(path, "messnet")
} else if ctx.GlobalBool(utils.MordorFlag.Name) {
path = filepath.Join(path, "mordor")
} else if ctx.GlobalBool(utils.SocialFlag.Name) {
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/consolecmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func TestConsoleCmdNetworkIdentities(t *testing.T) {
{[]string{"--social"}, 28, 28, params.SocialGenesisHash.Hex()},
{[]string{"--ethersocial"}, 1, 31102, params.EthersocialGenesisHash.Hex()},
{[]string{"--yolov1"}, 133519467574833, 133519467574833, params.YoloV1GenesisHash.Hex()},
{[]string{"--messnet"}, 6161, 6161, "0xb2957ab683ae69176b2eb7858f2baedb93752cb7cb45284529d543eebe20652e"},
}
for i, p := range chainIdentityCases {

Expand Down
5 changes: 5 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ var (
utils.DeveloperFlag,
utils.DeveloperPeriodFlag,
utils.ClassicFlag,
utils.MessNetFlag,
utils.MordorFlag,
utils.SocialFlag,
utils.MixFlag,
Expand All @@ -166,6 +167,7 @@ var (
utils.LegacyGpoPercentileFlag,
utils.EWASMInterpreterFlag,
utils.EVMInterpreterFlag,
utils.ECBP1100Flag,
configFileFlag,
}

Expand Down Expand Up @@ -313,6 +315,9 @@ func checkMainnet(ctx *cli.Context) bool {
case ctx.GlobalIsSet(utils.ClassicFlag.Name):
log.Info("Starting Geth on Ethereum Classic...")

case ctx.GlobalIsSet(utils.MessNetFlag.Name):
log.Info("Starting Geth on MessNet...")

case ctx.GlobalIsSet(utils.MordorFlag.Name):
log.Info("Starting Geth on Mordor testnet...")

Expand Down
2 changes: 2 additions & 0 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.RinkebyFlag,
utils.YoloV1Flag,
utils.RopstenFlag,
utils.MessNetFlag,
utils.SyncModeFlag,
utils.ExitWhenSyncedFlag,
utils.GCModeFlag,
Expand All @@ -60,6 +61,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.IdentityFlag,
utils.LightKDFFlag,
utils.WhitelistFlag,
utils.ECBP1100Flag,
},
},
{
Expand Down
26 changes: 24 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ var (
}
NetworkIdFlag = cli.Uint64Flag{
Name: "networkid",
Usage: "Network identifier (integer, 1=Mainnet, 2=Morden (disused), 3=Ropsten, 4=Rinkeby, 5=Goerli, 6=Kotti, YoloV1=133519467574833, developer=1337)",
Usage: "Network identifier (integer, 1=Mainnet, 2=Morden (disused), 3=Ropsten, 4=Rinkeby, 5=Goerli, 6=Kotti, YoloV1=133519467574833, 6161=MessNet, developer=1337)",
Value: eth.DefaultConfig.NetworkId,
}
ClassicFlag = cli.BoolFlag{
Expand Down Expand Up @@ -179,6 +179,10 @@ var (
Name: "goerli",
Usage: "Görli network: pre-configured proof-of-authority test network",
}
MessNetFlag = cli.BoolFlag{
Name: "messnet",
Usage: "MESS network: temporary dedicated test network for MESS testing",
}
DeveloperFlag = cli.BoolFlag{
Name: "dev",
Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled",
Expand Down Expand Up @@ -749,6 +753,10 @@ var (
Usage: "External EVM configuration (default = built-in interpreter)",
Value: "",
}
ECBP1100Flag = cli.Uint64Flag{
Name: "ecbp1100",
Usage: "Configure ECBP-1100 (MESS) block activation number",
}
)

// MakeDataDir retrieves the currently requested data directory, terminating
Expand Down Expand Up @@ -1295,6 +1303,8 @@ func dataDirPathForCtxChainConfig(ctx *cli.Context, baseDataDirPath string) stri
return filepath.Join(baseDataDirPath, "ropsten")
case ctx.GlobalBool(ClassicFlag.Name):
return filepath.Join(baseDataDirPath, "classic")
case ctx.GlobalBool(MessNetFlag.Name):
return filepath.Join(baseDataDirPath, "messnet")
case ctx.GlobalBool(MordorFlag.Name):
return filepath.Join(baseDataDirPath, "mordor")
case ctx.GlobalBool(SocialFlag.Name):
Expand Down Expand Up @@ -1411,6 +1421,9 @@ func setTxPool(ctx *cli.Context, cfg *core.TxPoolConfig) {
}

func setEthash(ctx *cli.Context, cfg *eth.Config) {
if ctx.GlobalBool(FakePoWFlag.Name) {
cfg.Ethash.PowMode = ethash.ModeFake
}
if ctx.GlobalIsSet(EthashCacheDirFlag.Name) {
cfg.Ethash.CacheDir = ctx.GlobalString(EthashCacheDirFlag.Name)
}
Expand Down Expand Up @@ -1553,7 +1566,7 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) {
// SetEthConfig applies eth-related command line flags to the config.
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
// Avoid conflicting network flags
CheckExclusive(ctx, DeveloperFlag, LegacyTestnetFlag, RopstenFlag, RinkebyFlag, GoerliFlag, YoloV1Flag, ClassicFlag, KottiFlag, MordorFlag, EthersocialFlag, SocialFlag)
CheckExclusive(ctx, DeveloperFlag, LegacyTestnetFlag, RopstenFlag, RinkebyFlag, GoerliFlag, YoloV1Flag, ClassicFlag, KottiFlag, MordorFlag, EthersocialFlag, SocialFlag, MessNetFlag)
CheckExclusive(ctx, LegacyLightServFlag, LightServeFlag, SyncModeFlag, "light")
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer
CheckExclusive(ctx, GCModeFlag, "archive", TxLookupLimitFlag)
Expand Down Expand Up @@ -1664,6 +1677,13 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
if gen := genesisForCtxChainConfig(ctx); gen != nil {
cfg.Genesis = gen
}
// Handle temporary chain configuration override cases.
if ctx.GlobalIsSet(ECBP1100Flag.Name) {
n := ctx.GlobalUint64(ECBP1100Flag.Name)
if err := cfg.Genesis.Config.SetECBP1100Transition(&n); err != nil {
Fatalf("Failed to set ECBP-1100 activation number: %v", err)
}
}

// Establish NetworkID.
// If dev-mode is used, then NetworkID will be overridden.
Expand Down Expand Up @@ -1894,6 +1914,8 @@ func genesisForCtxChainConfig(ctx *cli.Context) *genesisT.Genesis {
switch {
case ctx.GlobalBool(ClassicFlag.Name):
genesis = params.DefaultClassicGenesisBlock()
case ctx.GlobalBool(MessNetFlag.Name):
genesis = params.DefaultMessNetGenesisBlock()
case ctx.GlobalBool(MordorFlag.Name):
genesis = params.DefaultMordorGenesisBlock()
case ctx.GlobalBool(SocialFlag.Name):
Expand Down
16 changes: 16 additions & 0 deletions consensus/ethash/ethash.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,22 @@ const (
ModeFullFake
)

func (m Mode) String() string {
switch m {
case ModeNormal:
return "Normal"
case ModeShared:
return "Shared"
case ModeTest:
return "Test"
case ModeFake:
return "Fake"
case ModeFullFake:
return "FullFake"
}
return "unknown"
}

// Config are the configuration parameters of the ethash.
type Config struct {
CacheDir string
Expand Down
52 changes: 44 additions & 8 deletions consensus/ethash/sealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core/types"
"gonum.org/v1/gonum/stat/distuv"
)

const (
Expand All @@ -46,18 +47,53 @@ var (
errInvalidSealResult = errors.New("invalid or stale proof-of-work solution")
)

// makeFakeDelay uses the ethash.threads value as a mean time (lambda)
// for a Poisson distribution, returning a random value from
// that discrete function. I think a Poisson distribution probably
// fairly accurately models real world block times.
// Note that this is a hacky way to use ethash.threads since
// lower values will yield faster blocks, but it saves having
// to add or modify any more code than necessary.
func (ethash *Ethash) makeFakeDelay() float64 {
p := distuv.Poisson{
Lambda: float64(ethash.Threads()),
}
return p.Rand()
}

// Seal implements consensus.Engine, attempting to find a nonce that satisfies
// the block's difficulty requirements.
func (ethash *Ethash) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
// If we're running a fake PoW, simply return a 0 nonce immediately
if ethash.config.PowMode == ModeFake || ethash.config.PowMode == ModeFullFake {
header := block.Header()
header.Nonce, header.MixDigest = types.BlockNonce{}, common.Hash{}
select {
case results <- block.WithSeal(header):
default:
ethash.config.Log.Warn("Sealing result is not read by miner", "mode", "fake", "sealhash", ethash.SealHash(block.Header()))
}
faking := ethash.config.PowMode == ModeFake || ethash.config.PowMode == ModeFullFake
if faking {
go func(header *types.Header) {
// Assign random (but non-zero) values to header nonce and mix.
header.Nonce = types.EncodeNonce(uint64(rand.Int63n(math.MaxInt64)))
b, _ := header.Nonce.MarshalText()
header.MixDigest = common.BytesToHash(b)

// Wait some amount of time.
timeout := time.NewTimer(time.Duration(ethash.makeFakeDelay()) * time.Second)
defer timeout.Stop()

select {
case <-stop:
return
case <-ethash.update:
timeout.Stop()
if err := ethash.Seal(chain, block, results, stop); err != nil {
ethash.config.Log.Error("Failed to restart sealing after update", "err", err)
}
case <-timeout.C:
// Send the results when the timeout expires.
select {
case results <- block.WithSeal(header):
default:
ethash.config.Log.Warn("Sealing result is not read by miner", "mode", "fake", "sealhash", ethash.SealHash(block.Header()))
}
}
}(block.Header())
return nil
}
// If we're running a shared PoW, delegate sealing to it
Expand Down
19 changes: 19 additions & 0 deletions consensus/ethash/sealer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"math/big"
"net/http"
"net/http/httptest"
"sort"
"testing"
"time"

Expand All @@ -31,6 +32,24 @@ import (
"github.com/ethereum/go-ethereum/log"
)

func TestSealFakeDelay(t *testing.T) {
cases := []int{
3, 10, 19, 33,
}
for _, c := range cases {
e := &Ethash{threads: c} // "threads" is actually the desired MEAN (lambda) of the Poisson distribution
got := []float64{}
for i := 0; i < 20; i++ {
d := e.makeFakeDelay()
got = append(got, d)
}
sort.Slice(got, func(i, j int) bool {
return got[i] < got[j]
})
t.Logf("ethash.threads,lamda=%2d %v", c, got)
}
}

// Tests whether remote HTTP servers are correctly notified of new work.
func TestRemoteNotify(t *testing.T) {
// Start a simple web server to capture notifications.
Expand Down
Loading