Skip to content

Commit

Permalink
fully configurable bold
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan committed Nov 1, 2023
1 parent ae34d92 commit e9a2b3b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 24 deletions.
42 changes: 22 additions & 20 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ var ConfigDefault = Config{
MessagePruner: DefaultMessagePrunerConfig,
BlockValidator: staker.DefaultBlockValidatorConfig,
Feed: broadcastclient.FeedConfigDefault,
Bold: staker.DefaultBoldConfig,
Staker: staker.DefaultL1ValidatorConfig,
SeqCoordinator: DefaultSeqCoordinatorConfig,
DataAvailability: das.DefaultDataAvailabilityConfig,
Expand Down Expand Up @@ -765,49 +766,50 @@ func createNodeImpl(
if err != nil {
return nil, fmt.Errorf("could not create assertion chain: %w", err)
}
bigStepHeight := l2stateprovider.Height(1 << 5)
smallStepHeight := l2stateprovider.Height(1 << 7)
blockChallengeLeafHeight := l2stateprovider.Height(config.Bold.BlockChallengeLeafHeight)
bigStepHeight := l2stateprovider.Height(config.Bold.BigStepLeafHeight)
smallStepHeight := l2stateprovider.Height(config.Bold.SmallStepLeafHeight)
stateManager, err := staker.NewStateManager(
statelessBlockValidator,
"/tmp/good", // TODO: Customize from config.
config.Bold.MachineLeavesCachePath,
[]l2stateprovider.Height{
// TODO: Customize heights.
l2stateprovider.Height(32),
blockChallengeLeafHeight,
bigStepHeight,
smallStepHeight,
},
"good", // TODO: Customize from config.
config.Bold.ValidatorName,
)
if err != nil {
return nil, fmt.Errorf("could not create state manager: %w", err)
}
providerHeights := []l2stateprovider.Height{blockChallengeLeafHeight}
for i := uint64(0); i < config.Bold.NumBigSteps; i++ {
providerHeights = append(providerHeights, bigStepHeight)
}
providerHeights = append(providerHeights, smallStepHeight)
provider := l2stateprovider.NewHistoryCommitmentProvider(
stateManager,
stateManager,
stateManager,
[]l2stateprovider.Height{
l2stateprovider.Height(32),
bigStepHeight,
bigStepHeight,
bigStepHeight,
bigStepHeight,
bigStepHeight,
smallStepHeight,
},
providerHeights,
stateManager,
)
postingInterval := time.Second * time.Duration(config.Bold.AssertionPostingIntervalSeconds)
scanningInteval := time.Second * time.Duration(config.Bold.AssertionScanningIntervalSeconds)
confirmingInterval := time.Second * time.Duration(config.Bold.AssertionConfirmingIntervalSeconds)
edgeWakeInterval := time.Second * time.Duration(config.Bold.EdgeTrackerWakeIntervalSeconds)
manager, err := challengemanager.New(
ctx,
assertionChain,
l1client,
provider,
assertionChain.RollupAddress(),
challengemanager.WithName("honest"),
challengemanager.WithName(config.Bold.ValidatorName),
challengemanager.WithMode(modes.MakeMode),
challengemanager.WithAssertionPostingInterval(time.Second*30),
challengemanager.WithAssertionScanningInterval(time.Second*5),
challengemanager.WithAssertionConfirmingInterval(time.Minute),
challengemanager.WithEdgeTrackerWakeInterval(time.Millisecond*200),
challengemanager.WithAssertionPostingInterval(postingInterval),
challengemanager.WithAssertionScanningInterval(scanningInteval),
challengemanager.WithAssertionConfirmingInterval(confirmingInterval),
challengemanager.WithEdgeTrackerWakeInterval(edgeWakeInterval),
challengemanager.WithAddress(txOptsValidator.From),
)
if err != nil {
Expand Down
34 changes: 30 additions & 4 deletions staker/state_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,36 @@ var (
)

type BoldConfig struct {
Enable bool `koanf:"enable"`
Evil bool `koanf:"evil"`
Mode string `koanf:"mode"`
ValidatorPrivateKey string `koanf:"validator-private-key"`
Enable bool `koanf:"enable"`
Evil bool `koanf:"evil"`
Mode string `koanf:"mode"`
BlockChallengeLeafHeight uint64 `koanf:"block-challenge-leaf-height"`
BigStepLeafHeight uint64 `koanf:"big-step-leaf-height"`
SmallStepLeafHeight uint64 `koanf:"small-step-leaf-height"`
NumBigSteps uint64 `koanf:"num-big-steps"`
ValidatorName string `koanf:"validator-name"`
MachineLeavesCachePath string `koanf:"machine-leaves-cache-path"`
AssertionPostingIntervalSeconds uint64 `koanf:"assertion-posting-interval-seconds"`
AssertionScanningIntervalSeconds uint64 `koanf:"assertion-scanning-interval-seconds"`
AssertionConfirmingIntervalSeconds uint64 `koanf:"assertion-confirming-interval-seconds"`
EdgeTrackerWakeIntervalSeconds uint64 `koanf:"edge-tracker-wake-interval-seconds"`
ValidatorPrivateKey string `koanf:"validator-private-key"`
}

var DefaultBoldConfig = BoldConfig{
Enable: false,
Evil: false,
Mode: "make-mode",
BlockChallengeLeafHeight: 1 << 5,
BigStepLeafHeight: 1 << 5,
SmallStepLeafHeight: 1 << 7,
NumBigSteps: 5,
ValidatorName: "default-validator",
MachineLeavesCachePath: "/tmp/machine-leaves-cache",
AssertionPostingIntervalSeconds: 30,
AssertionScanningIntervalSeconds: 30,
AssertionConfirmingIntervalSeconds: 60,
EdgeTrackerWakeIntervalSeconds: 1,
}

func (c *BoldConfig) Validate() error {
Expand Down

0 comments on commit e9a2b3b

Please sign in to comment.