diff --git a/cmd/bor/config.go b/cmd/bor/config.go index b525cedb091005bdfd453bf2e7f9153aed64fbce..4929d826eb0be37d7b9cec6c3f56d8130a33ac4e 100644 --- a/cmd/bor/config.go +++ b/cmd/bor/config.go @@ -29,6 +29,7 @@ import ( "github.com/maticnetwork/bor/cmd/utils" "github.com/maticnetwork/bor/dashboard" "github.com/maticnetwork/bor/eth" + "github.com/maticnetwork/bor/log" "github.com/maticnetwork/bor/node" "github.com/maticnetwork/bor/params" whisper "github.com/maticnetwork/bor/whisper/whisperv6" @@ -150,6 +151,8 @@ func enableWhisper(ctx *cli.Context) bool { func makeFullNode(ctx *cli.Context) *node.Node { stack, cfg := makeConfigNode(ctx) + cfg.Eth.HeimdallURL = ctx.String(utils.HeimdallURLFlag.Name) + log.Info("Connecting to heimdall service on...", "heimdallURL", cfg.Eth.HeimdallURL) utils.RegisterEthService(stack, &cfg.Eth) if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) { diff --git a/cmd/bor/main.go b/cmd/bor/main.go index d187f40d71e375adae7dec25172af5b86cad2dec..d5ba1b9f6057139f7aafd9a66a35d10ab40512c9 100644 --- a/cmd/bor/main.go +++ b/cmd/bor/main.go @@ -190,6 +190,10 @@ var ( utils.MetricsInfluxDBPasswordFlag, utils.MetricsInfluxDBTagsFlag, } + + borFlags = []cli.Flag{ + utils.HeimdallURLFlag, + } ) func init() { @@ -233,6 +237,7 @@ func init() { app.Flags = append(app.Flags, debug.Flags...) app.Flags = append(app.Flags, whisperFlags...) app.Flags = append(app.Flags, metricsFlags...) + app.Flags = append(app.Flags, borFlags...) app.Before = func(ctx *cli.Context) error { logdir := "" diff --git a/cmd/bor/usage.go b/cmd/bor/usage.go index 6d3260e7017891e16a5698b9bf7a648531d7501e..fe680d31c3fdf17c773e19d40e060cd31e7924ac 100644 --- a/cmd/bor/usage.go +++ b/cmd/bor/usage.go @@ -246,6 +246,10 @@ var AppHelpFlagGroups = []flagGroup{ Name: "METRICS AND STATS", Flags: metricsFlags, }, + { + Name: "BOR", + Flags: borFlags, + }, { Name: "WHISPER (EXPERIMENTAL)", Flags: whisperFlags, diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index 439143586c482b12f00c8b793e998cd3cd5984eb..695005f0907af8c41a6c6bf5c53c1644cad8cc53 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -113,7 +113,6 @@ func (w *wizard) makeGenesis() { Sprint: 60, ValidatorContract: "0x0000000000000000000000000000000000001000", StateReceiverContract: "0x0000000000000000000000000000000000001001", - Heimdall: "http://localhost:1317", } // We also need the initial list of signers diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 94f79edc6605b1a405f875d8ad599b61ce7c893d..fa0aa9bf163027368bad09af0375bb4f6687c11f 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -741,6 +741,13 @@ var ( Usage: "External EVM configuration (default = built-in interpreter)", Value: "", } + + // Bor Specific flags + HeimdallURLFlag = cli.StringFlag{ + Name: "heimdall", + Usage: "URL of Heimdall service", + Value: "http://localhost:1317", + } ) // MakeDataDir retrieves the currently requested data directory, terminating @@ -1161,7 +1168,6 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) { setNodeUserIdent(ctx, cfg) setDataDir(ctx, cfg) setSmartCard(ctx, cfg) - if ctx.GlobalIsSet(ExternalSignerFlag.Name) { cfg.ExternalSigner = ctx.GlobalString(ExternalSignerFlag.Name) } diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go index bd55a745e7c9530ecb116275309975f84722bd44..a59fecd2e8f3750ad9fe7fbbb21d808dacf7fc6d 100644 --- a/consensus/bor/bor.go +++ b/consensus/bor/bor.go @@ -257,6 +257,7 @@ func New( chainConfig *params.ChainConfig, db ethdb.Database, ethAPI *ethapi.PublicBlockChainAPI, + heimdallURL string, ) *Bor { // get bor config borConfig := chainConfig.Bor @@ -271,7 +272,7 @@ func New( signatures, _ := lru.NewARC(inmemorySignatures) vABI, _ := abi.JSON(strings.NewReader(validatorsetABI)) sABI, _ := abi.JSON(strings.NewReader(stateReceiverABI)) - heimdallClient, _ := NewHeimdallClient(chainConfig.Bor.Heimdall) + heimdallClient, _ := NewHeimdallClient(heimdallURL) c := &Bor{ chainConfig: chainConfig, diff --git a/consensus/bor/bor_test/genesis.json b/consensus/bor/bor_test/genesis.json index 737cb600dd806393d8f157d6f7cc9859244001c7..32b9cd5b2aa474f4d6a629a87dec04e5a5f32b3b 100644 --- a/consensus/bor/bor_test/genesis.json +++ b/consensus/bor/bor_test/genesis.json @@ -13,8 +13,7 @@ "producerDelay": 4, "sprint": 1, "validatorContract": "0x0000000000000000000000000000000000001000", - "stateReceiverContract": "0x0000000000000000000000000000000000001001", - "heimdall": "http://localhost:1317" + "stateReceiverContract": "0x0000000000000000000000000000000000001001" } }, "nonce": "0x0", diff --git a/eth/backend.go b/eth/backend.go index edb253111f2b53e938769046b96cf0754aaffe03..271103c991dc3ba9559ddeeaba509a8b19248ae1 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -165,7 +165,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { } eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams) ethAPI := ethapi.NewPublicBlockChainAPI(eth.APIBackend) - eth.engine = CreateConsensusEngine(ctx, chainConfig, &config.Ethash, config.Miner.Notify, config.Miner.Noverify, chainDb, ethAPI) + eth.engine = CreateConsensusEngine(ctx, chainConfig, config, chainDb, ethAPI) bcVersion := rawdb.ReadDatabaseVersion(chainDb) var dbVer = "<nil>" @@ -252,8 +252,12 @@ func makeExtraData(extra []byte) []byte { return extra } -// CreateConsensusEngine creates the required type of consensus engine instance for an Ethereum service -func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainConfig, config *ethash.Config, notify []string, noverify bool, db ethdb.Database, ee *ethapi.PublicBlockChainAPI) consensus.Engine { +// func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainConfig, config *ethash.Config, notify []string, noverify bool, db ethdb.Database, ee *ethapi.PublicBlockChainAPI) consensus.Engine { +func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainConfig, ethConfig *Config, db ethdb.Database, ee *ethapi.PublicBlockChainAPI) consensus.Engine { + config := ðConfig.Ethash + notify := ethConfig.Miner.Notify + noverify := ethConfig.Miner.Noverify + // If proof-of-authority is requested, set it up if chainConfig.Clique != nil { return clique.New(chainConfig.Clique, db) @@ -261,7 +265,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) + return bor.New(chainConfig, db, ee, ethConfig.HeimdallURL) } // Otherwise assume proof-of-work diff --git a/eth/config.go b/eth/config.go index f201b7cc9dfca8c44126d2c3ad8c82cc31c12c2c..60bf9d359343b452e5e36fe4aa98fa1f1908cd00 100644 --- a/eth/config.go +++ b/eth/config.go @@ -154,4 +154,7 @@ type Config struct { // CheckpointOracle is the configuration for checkpoint oracle. CheckpointOracle *params.CheckpointOracleConfig + + // URL to connect to Heimdall node + HeimdallURL string } diff --git a/params/config.go b/params/config.go index 0573a762872dd0afbf5951e59ce3e8cb1a455e98..e56336fe2d5f6d01a12c247f6ca846817d6eb251 100644 --- a/params/config.go +++ b/params/config.go @@ -321,7 +321,6 @@ type BorConfig struct { Sprint uint64 `json:"sprint"` // Epoch length to proposer ValidatorContract string `json:"validatorContract"` // Validator set contract StateReceiverContract string `json:"stateReceiverContract"` // State receiver contract - Heimdall string `json:"heimdall"` // heimdall light client url } // String implements the stringer interface, returning the consensus engine details.