Skip to content

eth/catalyst: add catalyst API prototype #22641

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

Merged
merged 43 commits into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d9916d1
eth2: introduce RPC apis, catalyst command line option and extra inst…
gballet Apr 14, 2020
fad2587
Enable catalyst with option --catalyst
gballet Apr 8, 2021
9a35a22
Fix rebase and merge errors
gballet Apr 8, 2021
ccfb737
remove the code that isn't needed in rayonism
gballet Apr 9, 2021
26ee92a
Fix unit tests
gballet Apr 9, 2021
dfdff92
integrate review feedback
gballet Apr 14, 2021
dae9d1a
Change difficulty calculations to accept 1 for each block
gballet Apr 15, 2021
de593d0
Bring API up to spec
gballet Apr 15, 2021
ce8fff9
Fix unit tests
gballet Apr 15, 2021
0602ca7
Add a `success` field to the response in GinalizeBlock and SetHead
gballet Apr 15, 2021
8e3adf9
quell linter warning
gballet Apr 15, 2021
78e41ff
fix console test breakage because of the namespace change
gballet Apr 16, 2021
05f75c5
eth, eth/ethconfig: remove Catalyst config flag
fjl Apr 16, 2021
1fdba04
eth/catalyst: move catalyst implementation to its own package
fjl Apr 16, 2021
d267c14
cmd/geth: register catalyst service when --catalyst given
fjl Apr 16, 2021
5c627ef
cmd/utils: disable p2p networking in catalyst mode
fjl Apr 16, 2021
24909f0
core: revert change to tx pool config
fjl Apr 16, 2021
da28171
eth/catalyst: add copyright header
fjl Apr 16, 2021
3f3e879
cmd/utils: improve description of catalyst flag
fjl Apr 16, 2021
ef204fe
eth/catalyst: add test helper for starting eth
fjl Apr 16, 2021
8871cb7
eth/catalyst: use helper in disabled SetHead test
fjl Apr 16, 2021
40cb7cb
eth/catalyst: improve service registration
fjl Apr 16, 2021
962079c
cmd/geth: remove consensus API in console test
fjl Apr 16, 2021
71165f4
Change signature of InsertChainWithoutSealVerification to only accept…
gballet Apr 16, 2021
16be944
Reuse the block number from ExecutableData in NewBlock
gballet Apr 16, 2021
33c465b
Review feedback: a more descriptive name for the execution environment
gballet Apr 16, 2021
09e3867
remove commented code, it won't work out of the box
gballet Apr 16, 2021
2c22b5c
eth/catalyst: remove zeroNonce
fjl Apr 16, 2021
7adf70b
eth/catalyst: unexport API types
fjl Apr 16, 2021
01d16e5
eth/catalyst: fix encoding of API objects
fjl Apr 16, 2021
0eda836
eth/catalyst: fix name of parenthash parameter
fjl Apr 16, 2021
0a5bf45
eth/catalyst: make all params required
fjl Apr 16, 2021
43b88ae
Finalize and SetHead stubs return success upon call
gballet Apr 16, 2021
558649e
Remove outdated comment
gballet Apr 16, 2021
7b0a22d
eth/catalyst: move Register to api.go
fjl Apr 16, 2021
77e5444
eth/catalyst: improve error for misconfigured catalystBlock
fjl Apr 16, 2021
b75abfe
eth/catalyst: remove debug print
fjl Apr 16, 2021
be735b8
eth/catalyst: fix tx signer creation
fjl Apr 16, 2021
b311fc8
eth/catalyst: avoid keeping block env
fjl Apr 16, 2021
dc8295a
eth/catalyst: check error of sender derivation
fjl Apr 16, 2021
d00d4da
eth/catalyst: don't derive optional receipt fields
fjl Apr 16, 2021
5521b0a
eth/catalyst: skip the sender error check again, and explain why
fjl Apr 16, 2021
7eea1cf
eth/catalyst: remove more weird comments
fjl Apr 16, 2021
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
13 changes: 12 additions & 1 deletion cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"gopkg.in/urfave/cli.v1"

"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/eth/catalyst"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/metrics"
Expand Down Expand Up @@ -143,7 +144,17 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
if ctx.GlobalIsSet(utils.OverrideBerlinFlag.Name) {
cfg.Eth.OverrideBerlin = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideBerlinFlag.Name))
}
backend := utils.RegisterEthService(stack, &cfg.Eth)
backend, eth := utils.RegisterEthService(stack, &cfg.Eth)

// Configure catalyst.
if ctx.GlobalBool(utils.CatalystFlag.Name) {
if eth == nil {
utils.Fatalf("Catalyst does not work in light client mode.")
}
if err := catalyst.Register(stack, eth); err != nil {
utils.Fatalf("%v", err)
}
}

// Configure GraphQL if requested
if ctx.GlobalIsSet(utils.GraphQLEnabledFlag.Name) {
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.EVMInterpreterFlag,
utils.MinerNotifyFullFlag,
configFileFlag,
utils.CatalystFlag,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activate --nodiscover when set

}

rpcFlags = []cli.Flag{
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.SnapshotFlag,
utils.BloomFilterSizeFlag,
cli.HelpFlag,
utils.CatalystFlag,
},
},
}
Expand Down
18 changes: 13 additions & 5 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,11 @@ var (
Usage: "External EVM configuration (default = built-in interpreter)",
Value: "",
}

CatalystFlag = cli.BoolFlag{
Name: "catalyst",
Usage: "Catalyst mode (eth2 integration testing)",
}
)

// MakeDataDir retrieves the currently requested data directory, terminating
Expand Down Expand Up @@ -1186,10 +1191,11 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
cfg.NetRestrict = list
}

if ctx.GlobalBool(DeveloperFlag.Name) {
if ctx.GlobalBool(DeveloperFlag.Name) || ctx.GlobalBool(CatalystFlag.Name) {
// --dev mode can't use p2p networking.
cfg.MaxPeers = 0
cfg.ListenAddr = ":0"
cfg.ListenAddr = ""
cfg.NoDial = true
cfg.NoDiscovery = true
cfg.DiscoveryV5 = false
}
Expand Down Expand Up @@ -1693,14 +1699,16 @@ func SetDNSDiscoveryDefaults(cfg *ethconfig.Config, genesis common.Hash) {
}

// RegisterEthService adds an Ethereum client to the stack.
func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) ethapi.Backend {
// The second return value is the full node instance, which may be nil if the
// node is running as a light client.
func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend, *eth.Ethereum) {
if cfg.SyncMode == downloader.LightSync {
backend, err := les.New(stack, cfg)
if err != nil {
Fatalf("Failed to register the Ethereum service: %v", err)
}
stack.RegisterAPIs(tracers.APIs(backend.ApiBackend))
return backend.ApiBackend
return backend.ApiBackend, nil
}
backend, err := eth.New(stack, cfg)
if err != nil {
Expand All @@ -1713,7 +1721,7 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) ethapi.Backend
}
}
stack.RegisterAPIs(tracers.APIs(backend.APIBackend))
return backend.APIBackend
return backend.APIBackend, backend
}

// RegisterEthStatsService configures the Ethereum Stats daemon and adds it to
Expand Down
2 changes: 2 additions & 0 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ func (ethash *Ethash) CalcDifficulty(chain consensus.ChainHeaderReader, time uin
func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int {
next := new(big.Int).Add(parent.Number, big1)
switch {
case config.IsCatalyst(next):
return big.NewInt(1)
case config.IsMuirGlacier(next):
return calcDifficultyEip2384(time, parent)
case config.IsConstantinople(next):
Expand Down
16 changes: 16 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,22 @@ func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) {
return n, err
}

// InsertChainWithoutSealVerification works exactly the same
// except for seal verification, seal verification is omitted
func (bc *BlockChain) InsertChainWithoutSealVerification(block *types.Block) (int, error) {
bc.blockProcFeed.Send(true)
defer bc.blockProcFeed.Send(false)

// Pre-checks passed, start the full block imports
bc.wg.Add(1)
bc.chainmu.Lock()
n, err := bc.insertChain(types.Blocks([]*types.Block{block}), false)
bc.chainmu.Unlock()
bc.wg.Done()

return n, err
}

// insertChain is the internal implementation of InsertChain, which assumes that
// 1) chains are contiguous, and 2) The chain mutex is held.
//
Expand Down
1 change: 1 addition & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
}); err != nil {
return nil, err
}

eth.miner = miner.New(eth, &config.Miner, chainConfig, eth.EventMux(), eth.engine, eth.isLocalBlock)
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))

Expand Down
Loading