Skip to content

Commit be02672

Browse files
committed
identation and fix config check
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
1 parent 43f44f5 commit be02672

2 files changed

Lines changed: 122 additions & 122 deletions

File tree

cmd/nitro/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ func (c *NodeConfig) Validate() error {
173173
if c.Node.Sequencer || c.Node.BatchPoster.Enable {
174174
return errors.New("sequencing and batch-posting are currently not supported when connecting to an execution client over RPC")
175175
}
176-
} else if c.Execution.RPCServer.Enable && c.Execution.ConsensusRPCClient.URL != "" {
176+
} else if c.Execution.RPCServer.Enable && c.Execution.ConsensusRPCClient.URL == "" {
177177
return errors.New("communication over rpc is enabled on execution but consensus RPC client is not set")
178-
} else if c.Node.RPCServer.Enable && c.Node.ExecutionRPCClient.URL != "" {
178+
} else if c.Node.RPCServer.Enable && c.Node.ExecutionRPCClient.URL == "" {
179179
return errors.New("communication over rpc is enabled on consensus but execution RPC client is not set")
180180
}
181181
if err := c.BlocksReExecutor.Validate(); err != nil {

cmd/nitro/nitro.go

Lines changed: 120 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ func mainImpl() int {
203203
}
204204

205205
if consensusNodeEnabled {
206-
if nodeConfig.Node.SeqCoordinator.Enable && !nodeConfig.Node.ParentChainReader.Enable {
207-
log.Error("Sequencer coordinator must be enabled with parent chain reader, try starting node with --parent-chain.connection.url")
208-
return 1
209-
}
206+
if nodeConfig.Node.SeqCoordinator.Enable && !nodeConfig.Node.ParentChainReader.Enable {
207+
log.Error("Sequencer coordinator must be enabled with parent chain reader, try starting node with --parent-chain.connection.url")
208+
return 1
209+
}
210210
}
211211

212212
if nodeConfig.Execution.Sequencer.Enable && !nodeConfig.Execution.Sequencer.Timeboost.Enable && nodeConfig.Node.TransactionStreamer.TrackBlockMetadataFrom != 0 {
@@ -218,60 +218,60 @@ func mainImpl() int {
218218
var l1TransactionOptsBatchPoster *bind.TransactOpts
219219

220220
if consensusNodeEnabled {
221-
// If sequencer and signing is enabled or batchposter is enabled without
222-
// external signing sequencer will need a key.
223-
sequencerNeedsKey := (nodeConfig.Node.Sequencer && nodeConfig.Node.Feed.Output.Signed) ||
224-
(nodeConfig.Node.BatchPoster.Enable && (nodeConfig.Node.BatchPoster.DataPoster.ExternalSigner.URL == "" || nodeConfig.Node.DA.AnyTrust.Enable))
225-
validatorNeedsKey := nodeConfig.Node.Staker.OnlyCreateWalletContract ||
226-
(nodeConfig.Node.Staker.Enable && !strings.EqualFold(nodeConfig.Node.Staker.Strategy, "watchtower") && nodeConfig.Node.Staker.DataPoster.ExternalSigner.URL == "")
227-
228-
defaultL1WalletConfig := conf.DefaultL1WalletConfig
229-
defaultL1WalletConfig.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
230-
231-
nodeConfig.Node.Staker.ParentChainWallet.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
232-
defaultValidatorL1WalletConfig := legacystaker.DefaultValidatorL1WalletConfig
233-
defaultValidatorL1WalletConfig.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
234-
235-
nodeConfig.Node.BatchPoster.ParentChainWallet.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
236-
defaultBatchPosterL1WalletConfig := arbnode.DefaultBatchPosterL1WalletConfig
237-
defaultBatchPosterL1WalletConfig.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
238-
239-
if sequencerNeedsKey || nodeConfig.Node.BatchPoster.ParentChainWallet.OnlyCreateKey {
240-
l1TransactionOptsBatchPoster, dataSigner, err = util.OpenWallet("l1-batch-poster", &nodeConfig.Node.BatchPoster.ParentChainWallet, new(big.Int).SetUint64(nodeConfig.ParentChain.ID))
241-
if err != nil {
242-
pflag.Usage()
243-
log.Crit("error opening Batch poster parent chain wallet", "path", nodeConfig.Node.BatchPoster.ParentChainWallet.Pathname, "account", nodeConfig.Node.BatchPoster.ParentChainWallet.Account, "err", err)
244-
}
245-
if nodeConfig.Node.BatchPoster.ParentChainWallet.OnlyCreateKey {
246-
return 0
221+
// If sequencer and signing is enabled or batchposter is enabled without
222+
// external signing sequencer will need a key.
223+
sequencerNeedsKey := (nodeConfig.Node.Sequencer && nodeConfig.Node.Feed.Output.Signed) ||
224+
(nodeConfig.Node.BatchPoster.Enable && (nodeConfig.Node.BatchPoster.DataPoster.ExternalSigner.URL == "" || nodeConfig.Node.DA.AnyTrust.Enable))
225+
validatorNeedsKey := nodeConfig.Node.Staker.OnlyCreateWalletContract ||
226+
(nodeConfig.Node.Staker.Enable && !strings.EqualFold(nodeConfig.Node.Staker.Strategy, "watchtower") && nodeConfig.Node.Staker.DataPoster.ExternalSigner.URL == "")
227+
228+
defaultL1WalletConfig := conf.DefaultL1WalletConfig
229+
defaultL1WalletConfig.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
230+
231+
nodeConfig.Node.Staker.ParentChainWallet.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
232+
defaultValidatorL1WalletConfig := legacystaker.DefaultValidatorL1WalletConfig
233+
defaultValidatorL1WalletConfig.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
234+
235+
nodeConfig.Node.BatchPoster.ParentChainWallet.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
236+
defaultBatchPosterL1WalletConfig := arbnode.DefaultBatchPosterL1WalletConfig
237+
defaultBatchPosterL1WalletConfig.ResolveDirectoryNames(nodeConfig.Persistent.Chain)
238+
239+
if sequencerNeedsKey || nodeConfig.Node.BatchPoster.ParentChainWallet.OnlyCreateKey {
240+
l1TransactionOptsBatchPoster, dataSigner, err = util.OpenWallet("l1-batch-poster", &nodeConfig.Node.BatchPoster.ParentChainWallet, new(big.Int).SetUint64(nodeConfig.ParentChain.ID))
241+
if err != nil {
242+
pflag.Usage()
243+
log.Crit("error opening Batch poster parent chain wallet", "path", nodeConfig.Node.BatchPoster.ParentChainWallet.Pathname, "account", nodeConfig.Node.BatchPoster.ParentChainWallet.Account, "err", err)
244+
}
245+
if nodeConfig.Node.BatchPoster.ParentChainWallet.OnlyCreateKey {
246+
return 0
247+
}
247248
}
248-
}
249249

250-
if validatorNeedsKey || nodeConfig.Node.Staker.ParentChainWallet.OnlyCreateKey {
251-
l1TransactionOptsValidator, _, err = util.OpenWallet("l1-validator", &nodeConfig.Node.Staker.ParentChainWallet, new(big.Int).SetUint64(nodeConfig.ParentChain.ID))
252-
if err != nil {
253-
pflag.Usage()
254-
log.Crit("error opening Validator parent chain wallet", "path", nodeConfig.Node.Staker.ParentChainWallet.Pathname, "account", nodeConfig.Node.Staker.ParentChainWallet.Account, "err", err)
255-
}
256-
if nodeConfig.Node.Staker.ParentChainWallet.OnlyCreateKey {
257-
return 0
250+
if validatorNeedsKey || nodeConfig.Node.Staker.ParentChainWallet.OnlyCreateKey {
251+
l1TransactionOptsValidator, _, err = util.OpenWallet("l1-validator", &nodeConfig.Node.Staker.ParentChainWallet, new(big.Int).SetUint64(nodeConfig.ParentChain.ID))
252+
if err != nil {
253+
pflag.Usage()
254+
log.Crit("error opening Validator parent chain wallet", "path", nodeConfig.Node.Staker.ParentChainWallet.Pathname, "account", nodeConfig.Node.Staker.ParentChainWallet.Account, "err", err)
255+
}
256+
if nodeConfig.Node.Staker.ParentChainWallet.OnlyCreateKey {
257+
return 0
258+
}
258259
}
259-
}
260260

261-
if nodeConfig.Node.Staker.Enable {
262-
if !nodeConfig.Node.ParentChainReader.Enable {
263-
pflag.Usage()
264-
log.Crit("validator must have the parent chain reader enabled")
265-
}
266-
strategy, err := legacystaker.ParseStrategy(nodeConfig.Node.Staker.Strategy)
267-
if err != nil {
268-
log.Crit("couldn't parse staker strategy", "err", err)
269-
}
270-
if strategy != legacystaker.WatchtowerStrategy && !nodeConfig.Node.Staker.Dangerous.WithoutBlockValidator {
271-
nodeConfig.Node.BlockValidator.Enable = true
261+
if nodeConfig.Node.Staker.Enable {
262+
if !nodeConfig.Node.ParentChainReader.Enable {
263+
pflag.Usage()
264+
log.Crit("validator must have the parent chain reader enabled")
265+
}
266+
strategy, err := legacystaker.ParseStrategy(nodeConfig.Node.Staker.Strategy)
267+
if err != nil {
268+
log.Crit("couldn't parse staker strategy", "err", err)
269+
}
270+
if strategy != legacystaker.WatchtowerStrategy && !nodeConfig.Node.Staker.Dangerous.WithoutBlockValidator {
271+
nodeConfig.Node.BlockValidator.Enable = true
272+
}
272273
}
273274
}
274-
}
275275

276276
if nodeConfig.Execution.RPC.MaxRecreateStateDepth == arbitrum.UninitializedMaxRecreateStateDepth {
277277
if nodeConfig.Execution.Caching.Archive {
@@ -315,9 +315,9 @@ func mainImpl() int {
315315
log.Info("connected to l1 chain", "l1url", nodeConfig.ParentChain.Connection.URL, "l1chainid", nodeConfig.ParentChain.ID)
316316

317317
if consensusNodeEnabled {
318-
rollupAddrs, err = chaininfo.GetRollupAddressesConfig(nodeConfig.Chain.ID, nodeConfig.Chain.Name, nodeConfig.Chain.InfoFiles, nodeConfig.Chain.InfoJson)
319-
if err != nil {
320-
log.Crit("error getting rollup addresses", "err", err)
318+
rollupAddrs, err = chaininfo.GetRollupAddressesConfig(nodeConfig.Chain.ID, nodeConfig.Chain.Name, nodeConfig.Chain.InfoFiles, nodeConfig.Chain.InfoJson)
319+
if err != nil {
320+
log.Crit("error getting rollup addresses", "err", err)
321321
}
322322
}
323323
arbSys, _ := precompilesgen.NewArbSys(types.ArbSysAddress, l1Client)
@@ -442,9 +442,9 @@ func mainImpl() int {
442442
}
443443

444444
if executionNodeEnabled {
445-
if err := gethexec.PopulateStylusTargetCache(&nodeConfig.Execution.StylusTarget); err != nil {
446-
log.Error("error populating stylus target cache", "err", err)
447-
return 1
445+
if err := gethexec.PopulateStylusTargetCache(&nodeConfig.Execution.StylusTarget); err != nil {
446+
log.Error("error populating stylus target cache", "err", err)
447+
return 1
448448
}
449449
}
450450

@@ -559,50 +559,50 @@ func mainImpl() int {
559559
seqInboxMaxDataSize := 117964
560560

561561
if consensusNodeEnabled {
562-
consensusNode, err = arbnode.CreateConsensusNode(
563-
ctx,
564-
stack,
565-
execNode,
566-
consensusDB,
567-
&config.ConsensusNodeConfigFetcher{LiveConfig: liveNodeConfig},
568-
l2BlockChain.Config(),
569-
l1Client,
570-
&rollupAddrs,
571-
l1TransactionOptsValidator,
572-
l1TransactionOptsBatchPoster,
573-
dataSigner,
574-
fatalErrChan,
575-
new(big.Int).SetUint64(nodeConfig.ParentChain.ID),
576-
blobReader,
577-
wasmModuleRoot,
578-
)
579-
if err != nil {
580-
log.Error("failed to create consensus node", "err", err)
581-
return 1
582-
}
583-
584-
// Validate sequencer's MaxTxDataSize and batchPoster's MaxSize params.
585-
// SequencerInbox's maxDataSize is defaulted to 117964 which is 90% of Geth's 128KB tx size limit, leaving ~13KB for proving.
586-
if nodeConfig.Node.ParentChainReader.Enable {
587-
seqInbox, err := bridgegen.NewSequencerInbox(rollupAddrs.SequencerInbox, l1Client)
562+
consensusNode, err = arbnode.CreateConsensusNode(
563+
ctx,
564+
stack,
565+
execNode,
566+
consensusDB,
567+
&config.ConsensusNodeConfigFetcher{LiveConfig: liveNodeConfig},
568+
l2BlockChain.Config(),
569+
l1Client,
570+
&rollupAddrs,
571+
l1TransactionOptsValidator,
572+
l1TransactionOptsBatchPoster,
573+
dataSigner,
574+
fatalErrChan,
575+
new(big.Int).SetUint64(nodeConfig.ParentChain.ID),
576+
blobReader,
577+
wasmModuleRoot,
578+
)
588579
if err != nil {
589-
log.Error("failed to create sequencer inbox for validating sequencer's MaxTxDataSize and batchposter's MaxSize", "err", err)
580+
log.Error("failed to create consensus node", "err", err)
590581
return 1
591582
}
592-
res, err := seqInbox.MaxDataSize(&bind.CallOpts{Context: ctx})
593-
if err == nil {
594-
seqInboxMaxDataSize = int(res.Int64())
595-
} else if !headerreader.IsExecutionReverted(err) {
596-
log.Error("error fetching MaxDataSize from sequencer inbox", "err", err)
597-
return 1
583+
584+
// Validate sequencer's MaxTxDataSize and batchPoster's MaxSize params.
585+
// SequencerInbox's maxDataSize is defaulted to 117964 which is 90% of Geth's 128KB tx size limit, leaving ~13KB for proving.
586+
if nodeConfig.Node.ParentChainReader.Enable {
587+
seqInbox, err := bridgegen.NewSequencerInbox(rollupAddrs.SequencerInbox, l1Client)
588+
if err != nil {
589+
log.Error("failed to create sequencer inbox for validating sequencer's MaxTxDataSize and batchposter's MaxSize", "err", err)
590+
return 1
591+
}
592+
res, err := seqInbox.MaxDataSize(&bind.CallOpts{Context: ctx})
593+
if err == nil {
594+
seqInboxMaxDataSize = int(res.Int64())
595+
} else if !headerreader.IsExecutionReverted(err) {
596+
log.Error("error fetching MaxDataSize from sequencer inbox", "err", err)
597+
return 1
598+
}
598599
}
599-
}
600-
// If batchPoster is enabled, validate MaxCalldataBatchSize to be at least 10kB below the sequencer inbox's maxDataSize if AnyTrust DA is not enabled.
601-
// The 10kB gap is because its possible for the batch poster to exceed its MaxCalldataBatchSize limit and produce batches of slightly larger size.
602-
if nodeConfig.Node.BatchPoster.Enable && !nodeConfig.Node.DA.AnyTrust.Enable {
603-
if nodeConfig.Node.BatchPoster.MaxCalldataBatchSize > seqInboxMaxDataSize-10000 {
604-
log.Error("batchPoster's MaxCalldataBatchSize is too large")
605-
return 1
600+
// If batchPoster is enabled, validate MaxCalldataBatchSize to be at least 10kB below the sequencer inbox's maxDataSize if AnyTrust DA is not enabled.
601+
// The 10kB gap is because its possible for the batch poster to exceed its MaxCalldataBatchSize limit and produce batches of slightly larger size.
602+
if nodeConfig.Node.BatchPoster.Enable && !nodeConfig.Node.DA.AnyTrust.Enable {
603+
if nodeConfig.Node.BatchPoster.MaxCalldataBatchSize > seqInboxMaxDataSize-10000 {
604+
log.Error("batchPoster's MaxCalldataBatchSize is too large")
605+
return 1
606606
}
607607
}
608608
}
@@ -621,25 +621,25 @@ func mainImpl() int {
621621
}
622622

623623
if consensusNodeEnabled {
624-
liveNodeConfig.SetOnReloadHook(func(oldCfg *config.NodeConfig, newCfg *config.NodeConfig) error {
625-
if err := genericconf.InitLog(newCfg.LogType, newCfg.LogLevel, &newCfg.FileLogging, genericconf.DefaultPathResolver(nodeConfig.Persistent.LogDir)); err != nil {
626-
return fmt.Errorf("failed to re-init logging: %w", err)
627-
}
628-
return consensusNode.OnConfigReload(&oldCfg.Node, &newCfg.Node)
629-
})
624+
liveNodeConfig.SetOnReloadHook(func(oldCfg *config.NodeConfig, newCfg *config.NodeConfig) error {
625+
if err := genericconf.InitLog(newCfg.LogType, newCfg.LogLevel, &newCfg.FileLogging, genericconf.DefaultPathResolver(nodeConfig.Persistent.LogDir)); err != nil {
626+
return fmt.Errorf("failed to re-init logging: %w", err)
627+
}
628+
return consensusNode.OnConfigReload(&oldCfg.Node, &newCfg.Node)
629+
})
630630

631-
if nodeConfig.Node.Dangerous.NoL1Listener && nodeConfig.Init.DevInit {
632-
// If we don't have any messages, we're not connected to the L1, and we're using a dev init,
633-
// we should create our own fake init message.
634-
count, err := consensusNode.TxStreamer.GetMessageCount()
635-
if err != nil {
636-
log.Warn("Getmessagecount failed. Assuming new database", "err", err)
637-
count = 0
638-
}
639-
if count == 0 {
640-
err = consensusNode.TxStreamer.AddFakeInitMessage()
631+
if nodeConfig.Node.Dangerous.NoL1Listener && nodeConfig.Init.DevInit {
632+
// If we don't have any messages, we're not connected to the L1, and we're using a dev init,
633+
// we should create our own fake init message.
634+
count, err := consensusNode.TxStreamer.GetMessageCount()
641635
if err != nil {
642-
panic(err)
636+
log.Warn("Getmessagecount failed. Assuming new database", "err", err)
637+
count = 0
638+
}
639+
if count == 0 {
640+
err = consensusNode.TxStreamer.AddFakeInitMessage()
641+
if err != nil {
642+
panic(err)
643643
}
644644
}
645645
}
@@ -689,11 +689,11 @@ func mainImpl() int {
689689
}
690690

691691
if executionNodeEnabled {
692-
gqlConf := nodeConfig.GraphQL
693-
if execNode != nil && gqlConf.Enable {
694-
if err := graphql.New(stack, execNode.Backend.APIBackend(), execNode.FilterSystem, gqlConf.CORSDomain, gqlConf.VHosts); err != nil {
695-
log.Error("failed to register the GraphQL service", "err", err)
696-
return 1
692+
gqlConf := nodeConfig.GraphQL
693+
if execNode != nil && gqlConf.Enable {
694+
if err := graphql.New(stack, execNode.Backend.APIBackend(), execNode.FilterSystem, gqlConf.CORSDomain, gqlConf.VHosts); err != nil {
695+
log.Error("failed to register the GraphQL service", "err", err)
696+
return 1
697697
}
698698
}
699699
}

0 commit comments

Comments
 (0)