Skip to content

Commit

Permalink
Added bor.useheimdallapp flag
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKrishna committed Feb 3, 2023
1 parent 902d057 commit 9758fc2
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ The dumpgenesis command dumps the genesis block configuration in JSON format to
utils.HeimdallgRPCAddressFlag,
utils.RunHeimdallFlag,
utils.RunHeimdallArgsFlag,
utils.UseHeimdallAppFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `
Expand Down
10 changes: 9 additions & 1 deletion cmd/utils/bor_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var (
// RunHeimdallFlag flag for running heimdall internally from bor
RunHeimdallFlag = cli.BoolFlag{
Name: "bor.runheimdall",
Usage: "Run Heimdall service as a child process [ WIP ]",
Usage: "Run Heimdall service as a child process",
}

RunHeimdallArgsFlag = cli.StringFlag{
Expand All @@ -50,13 +50,20 @@ var (
Value: "",
}

// UseHeimdallApp flag for using internall heimdall app to fetch data
UseHeimdallAppFlag = cli.BoolFlag{
Name: "bor.useheimdallapp",
Usage: "Use child heimdall process to fetch data, Only works when bor.runheimdall is true",
}

// BorFlags all bor related flags
BorFlags = []cli.Flag{
HeimdallURLFlag,
WithoutHeimdallFlag,
HeimdallgRPCAddressFlag,
RunHeimdallFlag,
RunHeimdallArgsFlag,
UseHeimdallAppFlag,
}
)

Expand All @@ -82,6 +89,7 @@ func SetBorConfig(ctx *cli.Context, cfg *eth.Config) {
cfg.HeimdallgRPCAddress = ctx.GlobalString(HeimdallgRPCAddressFlag.Name)
cfg.RunHeimdall = ctx.GlobalBool(RunHeimdallFlag.Name)
cfg.RunHeimdallArgs = ctx.GlobalString(RunHeimdallArgsFlag.Name)
cfg.UseHeimdallApp = ctx.GlobalBool(UseHeimdallAppFlag.Name)
}

// CreateBorEthereum Creates bor ethereum object from eth.Config
Expand Down
1 change: 1 addition & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2037,6 +2037,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
HeimdallgRPCAddress: ctx.GlobalString(HeimdallgRPCAddressFlag.Name),
RunHeimdall: ctx.GlobalBool(RunHeimdallFlag.Name),
RunHeimdallArgs: ctx.GlobalString(RunHeimdallArgsFlag.Name),
UseHeimdallApp: ctx.GlobalBool(UseHeimdallAppFlag.Name),
})
engine = ethereum.Engine()
} else {
Expand Down
5 changes: 4 additions & 1 deletion eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ type Config struct {
// Arguments to pass to heimdall service
RunHeimdallArgs string

// Use child heimdall process to fetch data, Only works when RunHeimdall is true
UseHeimdallApp bool

// Bor logs flag
BorLogs bool

Expand Down Expand Up @@ -259,7 +262,7 @@ func CreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, et
return bor.New(chainConfig, db, blockchainAPI, spanner, nil, genesisContractsClient)
} else {
var heimdallClient bor.IHeimdallClient
if ethConfig.RunHeimdall {
if ethConfig.RunHeimdall && ethConfig.UseHeimdallApp {
heimdallClient = heimdallapp.NewHeimdallAppClient()
} else if ethConfig.HeimdallgRPCAddress != "" {
heimdallClient = heimdallgrpc.NewHeimdallGRPCClient(ethConfig.HeimdallgRPCAddress)
Expand Down
4 changes: 4 additions & 0 deletions internal/cli/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ type HeimdallConfig struct {

// RunHeimdal args are the arguments to run heimdall with
RunHeimdallArgs string `hcl:"bor.runheimdallargs,optional" toml:"bor.runheimdallargs,optional"`

// UseHeimdallApp is used to fetch data from heimdall app when running heimdall as a child process
UseHeimdallApp bool `hcl:"bor.useheimdallapp,optional" toml:"bor.useheimdallapp,optional"`
}

type TxPoolConfig struct {
Expand Down Expand Up @@ -672,6 +675,7 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*
n.HeimdallgRPCAddress = c.Heimdall.GRPCAddress
n.RunHeimdall = c.Heimdall.RunHeimdall
n.RunHeimdallArgs = c.Heimdall.RunHeimdallArgs
n.UseHeimdallApp = c.Heimdall.UseHeimdallApp

// gas price oracle
{
Expand Down
8 changes: 7 additions & 1 deletion internal/cli/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (c *Command) Flags() *flagset.Flagset {
})
f.BoolFlag(&flagset.BoolFlag{
Name: "bor.runheimdall",
Usage: "Run Heimdall service as a child process [ WIP ]",
Usage: "Run Heimdall service as a child process",
Value: &c.cliConfig.Heimdall.RunHeimdall,
Default: c.cliConfig.Heimdall.RunHeimdall,
})
Expand All @@ -104,6 +104,12 @@ func (c *Command) Flags() *flagset.Flagset {
Value: &c.cliConfig.Heimdall.RunHeimdallArgs,
Default: c.cliConfig.Heimdall.RunHeimdallArgs,
})
f.BoolFlag(&flagset.BoolFlag{
Name: "bor.useheimdallapp",
Usage: "Use child heimdall process to fetch data, Only works when bor.runheimdall is true",
Value: &c.cliConfig.Heimdall.UseHeimdallApp,
Default: c.cliConfig.Heimdall.UseHeimdallApp,
})

// txpool options
f.SliceStringFlag(&flagset.SliceStringFlag{
Expand Down

0 comments on commit 9758fc2

Please sign in to comment.