mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +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{
|
||||
utils.DataDirFlag,
|
||||
utils.HeimdallURLFlag,
|
||||
utils.WithoutHeimdallFlag,
|
||||
utils.CacheFlag,
|
||||
utils.SyncModeFlag,
|
||||
utils.GCModeFlag,
|
||||
|
|
|
|||
|
|
@ -148,7 +148,12 @@ func enableWhisper(ctx *cli.Context) bool {
|
|||
func makeFullNode(ctx *cli.Context) *node.Node {
|
||||
stack, cfg := makeConfigNode(ctx)
|
||||
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)
|
||||
|
||||
// Whisper must be explicitly enabled by specifying at least 1 whisper flag or in dev mode
|
||||
|
|
|
|||
|
|
@ -211,6 +211,7 @@ var (
|
|||
|
||||
borFlags = []cli.Flag{
|
||||
utils.HeimdallURLFlag,
|
||||
utils.WithoutHeimdallFlag,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -751,12 +751,22 @@ var (
|
|||
Value: "",
|
||||
}
|
||||
|
||||
//
|
||||
// Bor Specific flags
|
||||
//
|
||||
|
||||
// HeimdallURLFlag flag for heimdall url
|
||||
HeimdallURLFlag = cli.StringFlag{
|
||||
Name: "heimdall",
|
||||
Usage: "URL of Heimdall service",
|
||||
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
|
||||
|
|
@ -1872,7 +1882,11 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readOnly bool) (chain *core.B
|
|||
if config.Clique != nil {
|
||||
engine = clique.New(config.Clique, chainDb)
|
||||
} 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-")
|
||||
if err != nil {
|
||||
Fatalf("failed to create temporary keystore: %v", err)
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ type Bor struct {
|
|||
validatorSetABI abi.ABI
|
||||
stateReceiverABI abi.ABI
|
||||
HeimdallClient IHeimdallClient
|
||||
WithoutHeimdall bool
|
||||
|
||||
stateSyncFeed event.Feed
|
||||
scope event.SubscriptionScope
|
||||
|
|
@ -237,6 +238,7 @@ func New(
|
|||
db ethdb.Database,
|
||||
ethAPI *ethapi.PublicBlockChainAPI,
|
||||
heimdallURL string,
|
||||
withoutHeimdall bool,
|
||||
) *Bor {
|
||||
// get bor config
|
||||
borConfig := chainConfig.Bor
|
||||
|
|
@ -264,6 +266,7 @@ func New(
|
|||
stateReceiverABI: sABI,
|
||||
GenesisContractsClient: genesisContractsClient,
|
||||
HeimdallClient: heimdallClient,
|
||||
WithoutHeimdall: withoutHeimdall,
|
||||
}
|
||||
|
||||
return c
|
||||
|
|
@ -653,7 +656,7 @@ func (c *Bor) Prepare(chain consensus.ChainReader, header *types.Header) error {
|
|||
// rewards given.
|
||||
func (c *Bor) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header) {
|
||||
headerNumber := header.Number.Uint64()
|
||||
if headerNumber%c.config.Sprint == 0 {
|
||||
if !c.WithoutHeimdall && headerNumber%c.config.Sprint == 0 {
|
||||
cx := chainContext{Chain: chain, Bor: c}
|
||||
// check and commit span
|
||||
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.
|
||||
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()
|
||||
if headerNumber%c.config.Sprint == 0 {
|
||||
if !c.WithoutHeimdall && headerNumber%c.config.Sprint == 0 {
|
||||
cx := chainContext{Chain: chain, Bor: c}
|
||||
|
||||
// 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 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
|
||||
|
|
|
|||
|
|
@ -182,4 +182,7 @@ type Config struct {
|
|||
|
||||
// URL to connect to Heimdall node
|
||||
HeimdallURL string
|
||||
|
||||
// No heimdall service
|
||||
WithoutHeimdall bool
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue