mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 06:23:47 +00:00
new: add without-heimdall flag for testing purpose
This commit is contained in:
parent
f8673af612
commit
49aff6eca7
7 changed files with 32 additions and 5 deletions
|
|
@ -78,6 +78,7 @@ The dumpgenesis command dumps the genesis block configuration in JSON format to
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
utils.DataDirFlag,
|
utils.DataDirFlag,
|
||||||
utils.HeimdallURLFlag,
|
utils.HeimdallURLFlag,
|
||||||
|
utils.WithoutHeimdallFlag,
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
utils.GCModeFlag,
|
utils.GCModeFlag,
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,12 @@ func enableWhisper(ctx *cli.Context) bool {
|
||||||
func makeFullNode(ctx *cli.Context) *node.Node {
|
func makeFullNode(ctx *cli.Context) *node.Node {
|
||||||
stack, cfg := makeConfigNode(ctx)
|
stack, cfg := makeConfigNode(ctx)
|
||||||
cfg.Eth.HeimdallURL = ctx.GlobalString(utils.HeimdallURLFlag.Name)
|
cfg.Eth.HeimdallURL = ctx.GlobalString(utils.HeimdallURLFlag.Name)
|
||||||
log.Info("Connecting to heimdall service on...", "heimdallURL", cfg.Eth.HeimdallURL)
|
cfg.Eth.WithoutHeimdall = ctx.GlobalBool(utils.WithoutHeimdallFlag.Name)
|
||||||
|
if cfg.Eth.WithoutHeimdall {
|
||||||
|
log.Info("Running without Heimdall node")
|
||||||
|
} else {
|
||||||
|
log.Info("Connecting to Heimdall node", "heimdallURL", cfg.Eth.HeimdallURL)
|
||||||
|
}
|
||||||
utils.RegisterEthService(stack, &cfg.Eth)
|
utils.RegisterEthService(stack, &cfg.Eth)
|
||||||
|
|
||||||
// Whisper must be explicitly enabled by specifying at least 1 whisper flag or in dev mode
|
// Whisper must be explicitly enabled by specifying at least 1 whisper flag or in dev mode
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,7 @@ var (
|
||||||
|
|
||||||
borFlags = []cli.Flag{
|
borFlags = []cli.Flag{
|
||||||
utils.HeimdallURLFlag,
|
utils.HeimdallURLFlag,
|
||||||
|
utils.WithoutHeimdallFlag,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -751,12 +751,22 @@ var (
|
||||||
Value: "",
|
Value: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// Bor Specific flags
|
// Bor Specific flags
|
||||||
|
//
|
||||||
|
|
||||||
|
// HeimdallURLFlag flag for heimdall url
|
||||||
HeimdallURLFlag = cli.StringFlag{
|
HeimdallURLFlag = cli.StringFlag{
|
||||||
Name: "heimdall",
|
Name: "heimdall",
|
||||||
Usage: "URL of Heimdall service",
|
Usage: "URL of Heimdall service",
|
||||||
Value: "http://localhost:1317",
|
Value: "http://localhost:1317",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithoutHeimdallFlag no heimdall (for testing purpose)
|
||||||
|
WithoutHeimdallFlag = cli.BoolFlag{
|
||||||
|
Name: "without-heimdall",
|
||||||
|
Usage: "Run without Heimdall service (for testing purpose)",
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// MakeDataDir retrieves the currently requested data directory, terminating
|
// MakeDataDir retrieves the currently requested data directory, terminating
|
||||||
|
|
@ -1872,7 +1882,11 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readOnly bool) (chain *core.B
|
||||||
if config.Clique != nil {
|
if config.Clique != nil {
|
||||||
engine = clique.New(config.Clique, chainDb)
|
engine = clique.New(config.Clique, chainDb)
|
||||||
} else if config.Bor != nil {
|
} else if config.Bor != nil {
|
||||||
cfg := ð.Config{Genesis: genesis, HeimdallURL: ctx.GlobalString(HeimdallURLFlag.Name)}
|
cfg := ð.Config{
|
||||||
|
Genesis: genesis,
|
||||||
|
HeimdallURL: ctx.GlobalString(HeimdallURLFlag.Name),
|
||||||
|
WithoutHeimdall: ctx.GlobalBool(WithoutHeimdallFlag.Name),
|
||||||
|
}
|
||||||
workspace, err := ioutil.TempDir("", "console-tester-")
|
workspace, err := ioutil.TempDir("", "console-tester-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("failed to create temporary keystore: %v", err)
|
Fatalf("failed to create temporary keystore: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,7 @@ type Bor struct {
|
||||||
validatorSetABI abi.ABI
|
validatorSetABI abi.ABI
|
||||||
stateReceiverABI abi.ABI
|
stateReceiverABI abi.ABI
|
||||||
HeimdallClient IHeimdallClient
|
HeimdallClient IHeimdallClient
|
||||||
|
WithoutHeimdall bool
|
||||||
|
|
||||||
stateSyncFeed event.Feed
|
stateSyncFeed event.Feed
|
||||||
scope event.SubscriptionScope
|
scope event.SubscriptionScope
|
||||||
|
|
@ -237,6 +238,7 @@ func New(
|
||||||
db ethdb.Database,
|
db ethdb.Database,
|
||||||
ethAPI *ethapi.PublicBlockChainAPI,
|
ethAPI *ethapi.PublicBlockChainAPI,
|
||||||
heimdallURL string,
|
heimdallURL string,
|
||||||
|
withoutHeimdall bool,
|
||||||
) *Bor {
|
) *Bor {
|
||||||
// get bor config
|
// get bor config
|
||||||
borConfig := chainConfig.Bor
|
borConfig := chainConfig.Bor
|
||||||
|
|
@ -264,6 +266,7 @@ func New(
|
||||||
stateReceiverABI: sABI,
|
stateReceiverABI: sABI,
|
||||||
GenesisContractsClient: genesisContractsClient,
|
GenesisContractsClient: genesisContractsClient,
|
||||||
HeimdallClient: heimdallClient,
|
HeimdallClient: heimdallClient,
|
||||||
|
WithoutHeimdall: withoutHeimdall,
|
||||||
}
|
}
|
||||||
|
|
||||||
return c
|
return c
|
||||||
|
|
@ -653,7 +656,7 @@ func (c *Bor) Prepare(chain consensus.ChainReader, header *types.Header) error {
|
||||||
// rewards given.
|
// rewards given.
|
||||||
func (c *Bor) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header) {
|
func (c *Bor) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header) {
|
||||||
headerNumber := header.Number.Uint64()
|
headerNumber := header.Number.Uint64()
|
||||||
if headerNumber%c.config.Sprint == 0 {
|
if !c.WithoutHeimdall && headerNumber%c.config.Sprint == 0 {
|
||||||
cx := chainContext{Chain: chain, Bor: c}
|
cx := chainContext{Chain: chain, Bor: c}
|
||||||
// check and commit span
|
// check and commit span
|
||||||
if err := c.checkAndCommitSpan(state, header, cx); err != nil {
|
if err := c.checkAndCommitSpan(state, header, cx); err != nil {
|
||||||
|
|
@ -677,7 +680,7 @@ func (c *Bor) Finalize(chain consensus.ChainReader, header *types.Header, state
|
||||||
// nor block rewards given, and returns the final block.
|
// nor block rewards given, and returns the final block.
|
||||||
func (c *Bor) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
|
func (c *Bor) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
|
||||||
headerNumber := header.Number.Uint64()
|
headerNumber := header.Number.Uint64()
|
||||||
if headerNumber%c.config.Sprint == 0 {
|
if !c.WithoutHeimdall && headerNumber%c.config.Sprint == 0 {
|
||||||
cx := chainContext{Chain: chain, Bor: c}
|
cx := chainContext{Chain: chain, Bor: c}
|
||||||
|
|
||||||
// check and commit span
|
// check and commit span
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@ func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainCo
|
||||||
|
|
||||||
// If Matic Bor is requested, set it up
|
// If Matic Bor is requested, set it up
|
||||||
if chainConfig.Bor != nil {
|
if chainConfig.Bor != nil {
|
||||||
return bor.New(chainConfig, db, ee, ethConfig.HeimdallURL)
|
return bor.New(chainConfig, db, ee, ethConfig.HeimdallURL, ethConfig.WithoutHeimdall)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise assume proof-of-work
|
// Otherwise assume proof-of-work
|
||||||
|
|
|
||||||
|
|
@ -182,4 +182,7 @@ type Config struct {
|
||||||
|
|
||||||
// URL to connect to Heimdall node
|
// URL to connect to Heimdall node
|
||||||
HeimdallURL string
|
HeimdallURL string
|
||||||
|
|
||||||
|
// No heimdall service
|
||||||
|
WithoutHeimdall bool
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue