Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nitro-testnode
19 changes: 7 additions & 12 deletions staker/bold/bold_staker.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func init() {
}

type BoldConfig struct {
Strategy string `koanf:"strategy"`
// How often to post assertions onchain.
AssertionPostingInterval time.Duration `koanf:"assertion-posting-interval"`
// How often to scan for newly created assertions onchain.
Expand All @@ -83,16 +82,10 @@ type BoldConfig struct {
ParentChainBlockTime time.Duration `koanf:"parent-chain-block-time"`
// How long to wait since parent assertion was created to post a new assertion
MinimumGapToParentAssertion time.Duration `koanf:"minimum-gap-to-parent-assertion"`
strategy legacystaker.StakerStrategy
blockNum rpc.BlockNumber
}

func (c *BoldConfig) Validate() error {
strategy, err := legacystaker.ParseStrategy(c.Strategy)
if err != nil {
return err
}
c.strategy = strategy
var blockNum rpc.BlockNumber
switch strings.ToLower(c.RPCBlockNumber) {
case "safe":
Expand Down Expand Up @@ -133,7 +126,6 @@ var DefaultStateProviderConfig = StateProviderConfig{
}

var DefaultBoldConfig = BoldConfig{
Strategy: "Watchtower",
AssertionPostingInterval: time.Minute * 15,
AssertionScanningInterval: time.Minute,
AssertionConfirmingInterval: time.Minute,
Expand Down Expand Up @@ -163,7 +155,6 @@ var BoldModes = map[legacystaker.StakerStrategy]boldtypes.Mode{
}

func BoldConfigAddOptions(prefix string, f *flag.FlagSet) {
f.String(prefix+".strategy", DefaultBoldConfig.Strategy, "define the bold validator staker strategy, either watchtower, defensive, stakeLatest, or makeNodes")
f.String(prefix+".rpc-block-number", DefaultBoldConfig.RPCBlockNumber, "define the block number to use for reading data onchain, either latest, safe, or finalized")
f.Int64(prefix+".max-get-log-blocks", DefaultBoldConfig.MaxGetLogBlocks, "maximum size for chunk of blocks when using get logs rpc")
f.Duration(prefix+".assertion-posting-interval", DefaultBoldConfig.AssertionPostingInterval, "assertion posting interval")
Expand Down Expand Up @@ -199,6 +190,7 @@ func DelegatedStakingConfigAddOptions(prefix string, f *flag.FlagSet) {
type BOLDStaker struct {
stopwaiter.StopWaiter
config *BoldConfig
strategy legacystaker.StakerStrategy
chalManager *challengemanager.Manager
blockValidator *staker.BlockValidator
rollupAddress common.Address
Expand All @@ -223,6 +215,7 @@ func NewBOLDStaker(
blockValidator *staker.BlockValidator,
statelessBlockValidator *staker.StatelessBlockValidator,
config *BoldConfig,
strategy legacystaker.StakerStrategy,
dataPoster *dataposter.DataPoster,
wallet legacystaker.ValidatorWalletInterface,
stakedNotifiers []legacystaker.LatestStakedNotifier,
Expand All @@ -236,12 +229,13 @@ func NewBOLDStaker(
return nil, err
}
wrappedClient := util.NewBackendWrapper(l1Reader.Client(), rpc.LatestBlockNumber)
manager, err := newBOLDChallengeManager(ctx, stack, rollupAddress, txOpts, l1Reader, wrappedClient, blockValidator, statelessBlockValidator, config, dataPoster, inboxTracker, inboxStreamer, inboxReader)
manager, err := newBOLDChallengeManager(ctx, stack, rollupAddress, txOpts, l1Reader, wrappedClient, blockValidator, statelessBlockValidator, config, strategy, dataPoster, inboxTracker, inboxStreamer, inboxReader)
if err != nil {
return nil, err
}
return &BOLDStaker{
config: config,
strategy: strategy,
chalManager: manager,
blockValidator: blockValidator,
rollupAddress: rollupAddress,
Expand Down Expand Up @@ -269,7 +263,7 @@ func (b *BOLDStaker) Initialize(ctx context.Context) error {
if b.wallet.DataPoster() != nil {
stakerAddr = b.wallet.DataPoster().Sender()
}
log.Info("running as validator", "txSender", stakerAddr, "actingAsWallet", walletAddressOrZero, "strategy", b.config.Strategy)
log.Info("running as validator", "txSender", stakerAddr, "actingAsWallet", walletAddressOrZero, "strategy", b.strategy.ToString())

if b.blockValidator != nil && b.config.StartValidationFromStaked && !b.blockValidator.Started() {
rollupUserLogic, err := boldrollup.NewRollupUserLogic(b.rollupAddress, b.client)
Expand Down Expand Up @@ -463,6 +457,7 @@ func newBOLDChallengeManager(
blockValidator *staker.BlockValidator,
statelessBlockValidator *staker.StatelessBlockValidator,
config *BoldConfig,
strategy legacystaker.StakerStrategy,
dataPoster *dataposter.DataPoster,
inboxTracker staker.InboxTrackerInterface,
inboxStreamer staker.TransactionStreamerInterface,
Expand Down Expand Up @@ -586,7 +581,7 @@ func newBOLDChallengeManager(

stackOpts := []challengemanager.StackOpt{
challengemanager.StackWithName(config.StateProviderConfig.ValidatorName),
challengemanager.StackWithMode(BoldModes[config.strategy]),
challengemanager.StackWithMode(BoldModes[strategy]),
challengemanager.StackWithPollingInterval(scanningInterval),
challengemanager.StackWithPostingInterval(postingInterval),
challengemanager.StackWithConfirmationInterval(confirmingInterval),
Expand Down
17 changes: 17 additions & 0 deletions staker/legacy/staker.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ func ParseStrategy(strategy string) (StakerStrategy, error) {
}
}

func (s StakerStrategy) ToString() string {
switch s {
case WatchtowerStrategy:
return "watchtower"
case DefensiveStrategy:
return "defensive"
case StakeLatestStrategy:
return "stakelatest"
case ResolveNodesStrategy:
return "resolvenodes"
case MakeNodesStrategy:
return "makenodes"
default:
return "Unknown"
}
}

func (c *L1ValidatorConfig) ValidatorRequired() bool {
if !c.Enable {
return false
Expand Down
1 change: 1 addition & 0 deletions staker/multi_protocol/multi_protocol_staker.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ func (m *MultiProtocolStaker) setupBoldStaker(
m.blockValidator,
m.statelessBlockValidator,
m.boldConfig,
m.legacyConfig().StrategyType(),
m.wallet.DataPoster(),
m.wallet,
m.stakedNotifiers,
Expand Down
3 changes: 0 additions & 3 deletions system_tests/bold_l3_support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestL3ChallengeProtocolBOLD(t *testing.T) {
builder.nodeConfig.BlockValidator.Enable = true
builder.nodeConfig.Staker.Enable = true
builder.nodeConfig.Staker.Strategy = "MakeNodes"
builder.nodeConfig.Bold.Strategy = "MakeNodes"
builder.nodeConfig.Bold.RPCBlockNumber = "latest"
builder.nodeConfig.Bold.StateProviderConfig.CheckBatchFinality = false
builder.nodeConfig.Bold.StateProviderConfig.ValidatorName = "L2-validator"
Expand All @@ -59,7 +58,6 @@ func TestL3ChallengeProtocolBOLD(t *testing.T) {
builder.l3Config.nodeConfig.Staker.Enable = true
builder.l3Config.nodeConfig.BlockValidator.Enable = true
builder.l3Config.nodeConfig.Staker.Strategy = "MakeNodes"
builder.l3Config.nodeConfig.Bold.Strategy = "MakeNodes"
builder.l3Config.nodeConfig.Bold.RPCBlockNumber = "latest"
builder.l3Config.nodeConfig.Bold.StateProviderConfig.CheckBatchFinality = false
builder.l3Config.nodeConfig.Bold.StateProviderConfig.ValidatorName = "L3-validator"
Expand All @@ -72,7 +70,6 @@ func TestL3ChallengeProtocolBOLD(t *testing.T) {
secondNodeNodeConfig.BlockValidator.Enable = true
secondNodeNodeConfig.Staker.Enable = true
secondNodeNodeConfig.Staker.Strategy = "Watchtower"
secondNodeNodeConfig.Bold.Strategy = "Watchtower"
secondNodeNodeConfig.Bold.StateProviderConfig.CheckBatchFinality = false
secondNodeNodeConfig.Bold.StateProviderConfig.ValidatorName = "Second-L2-validator"
secondNodeNodeConfig.Bold.RPCBlockNumber = "latest"
Expand Down
Loading