From 1caa6f5d37e99de2e9f9a16e8299d13934ec2731 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Fri, 19 Apr 2024 12:26:38 +0530 Subject: [PATCH] Add config option to track specifi challenge with the specified parent assertion hashes --- arbnode/node.go | 175 +++++++++++++++++++++++++++++++++++++++ bold | 2 +- contracts | 2 +- fastcache | 2 +- go-ethereum | 2 +- nitro-testnode | 2 +- staker/state_provider.go | 67 ++++++++------- 7 files changed, 215 insertions(+), 37 deletions(-) diff --git a/arbnode/node.go b/arbnode/node.go index aa6919d045..1ace697f42 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -573,6 +573,181 @@ func createNodeImpl( statelessBlockValidator = nil } +<<<<<<< HEAD +||||||| parent of 064b081e3 (Add config option to track specifi challenge with the specified parent assertion hashes) + var dp *dataposter.DataPoster + if config.Bold.Enable { + dp, err = StakerDataposter( + ctx, + rawdb.NewTable(arbDb, storage.StakerPrefix), + l1Reader, + txOptsValidator, + configFetcher, + syncMonitor, + parentChainID, + ) + if err != nil { + return nil, err + } + rollupBindings, err := rollupgen.NewRollupUserLogic(deployInfo.Rollup, l1client) + if err != nil { + return nil, fmt.Errorf("could not create rollup bindings: %w", err) + } + chalManager, err := rollupBindings.ChallengeManager(&bind.CallOpts{}) + if err != nil { + return nil, fmt.Errorf("could not get challenge manager: %w", err) + } + assertionChain, err := solimpl.NewAssertionChain(ctx, deployInfo.Rollup, chalManager, txOptsValidator, l1client, solimpl.NewDataPosterTransactor(dp)) + if err != nil { + return nil, fmt.Errorf("could not create assertion chain: %w", err) + } + blockChallengeLeafHeight := l2stateprovider.Height(config.Bold.BlockChallengeLeafHeight) + bigStepHeight := l2stateprovider.Height(config.Bold.BigStepLeafHeight) + smallStepHeight := l2stateprovider.Height(config.Bold.SmallStepLeafHeight) + stateManager, err := staker.NewStateManager( + statelessBlockValidator, + config.Bold.MachineLeavesCachePath, + []l2stateprovider.Height{ + blockChallengeLeafHeight, + bigStepHeight, + smallStepHeight, + }, + 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, + providerHeights, + stateManager, + nil, + ) + 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) + opts := []challengemanager.Opt{ + challengemanager.WithName(config.Bold.ValidatorName), + challengemanager.WithMode(modes.MakeMode), // TODO: Customize. + challengemanager.WithAssertionPostingInterval(postingInterval), + challengemanager.WithAssertionScanningInterval(scanningInteval), + challengemanager.WithAssertionConfirmingInterval(confirmingInterval), + challengemanager.WithEdgeTrackerWakeInterval(edgeWakeInterval), + challengemanager.WithAddress(txOptsValidator.From), + } + if config.Bold.API { + opts = append(opts, challengemanager.WithAPIEnabled(fmt.Sprintf("%s:%d", config.Bold.APIHost, config.Bold.APIPort), config.Bold.APIDBPath)) + } + manager, err := challengemanager.New( + ctx, + assertionChain, + provider, + assertionChain.RollupAddress(), + opts..., + ) + if err != nil { + return nil, fmt.Errorf("could not create challenge manager: %w", err) + } + provider.UpdateAPIDatabase(manager.Database()) + go manager.Start(ctx) + } + +======= + var dp *dataposter.DataPoster + if config.Bold.Enable { + dp, err = StakerDataposter( + ctx, + rawdb.NewTable(arbDb, storage.StakerPrefix), + l1Reader, + txOptsValidator, + configFetcher, + syncMonitor, + parentChainID, + ) + if err != nil { + return nil, err + } + rollupBindings, err := rollupgen.NewRollupUserLogic(deployInfo.Rollup, l1client) + if err != nil { + return nil, fmt.Errorf("could not create rollup bindings: %w", err) + } + chalManager, err := rollupBindings.ChallengeManager(&bind.CallOpts{}) + if err != nil { + return nil, fmt.Errorf("could not get challenge manager: %w", err) + } + assertionChain, err := solimpl.NewAssertionChain(ctx, deployInfo.Rollup, chalManager, txOptsValidator, l1client, solimpl.NewDataPosterTransactor(dp)) + if err != nil { + return nil, fmt.Errorf("could not create assertion chain: %w", err) + } + blockChallengeLeafHeight := l2stateprovider.Height(config.Bold.BlockChallengeLeafHeight) + bigStepHeight := l2stateprovider.Height(config.Bold.BigStepLeafHeight) + smallStepHeight := l2stateprovider.Height(config.Bold.SmallStepLeafHeight) + stateManager, err := staker.NewStateManager( + statelessBlockValidator, + config.Bold.MachineLeavesCachePath, + []l2stateprovider.Height{ + blockChallengeLeafHeight, + bigStepHeight, + smallStepHeight, + }, + 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, + providerHeights, + stateManager, + nil, + ) + 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) + opts := []challengemanager.Opt{ + challengemanager.WithName(config.Bold.ValidatorName), + challengemanager.WithMode(modes.MakeMode), // TODO: Customize. + challengemanager.WithAssertionPostingInterval(postingInterval), + challengemanager.WithAssertionScanningInterval(scanningInteval), + challengemanager.WithAssertionConfirmingInterval(confirmingInterval), + challengemanager.WithEdgeTrackerWakeInterval(edgeWakeInterval), + challengemanager.WithAddress(txOptsValidator.From), + challengemanager.WithTrackChallengeParentAssertionHashes(config.Bold.TrackChallengeParentAssertionHashes), + } + if config.Bold.API { + opts = append(opts, challengemanager.WithAPIEnabled(fmt.Sprintf("%s:%d", config.Bold.APIHost, config.Bold.APIPort), config.Bold.APIDBPath)) + } + manager, err := challengemanager.New( + ctx, + assertionChain, + provider, + assertionChain.RollupAddress(), + opts..., + ) + if err != nil { + return nil, fmt.Errorf("could not create challenge manager: %w", err) + } + provider.UpdateAPIDatabase(manager.Database()) + go manager.Start(ctx) + } + +>>>>>>> 064b081e3 (Add config option to track specifi challenge with the specified parent assertion hashes) var blockValidator *staker.BlockValidator if config.ValidatorRequired() { blockValidator, err = staker.NewBlockValidator( diff --git a/bold b/bold index 6f711615b2..1239b88370 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 6f711615b2c8b94d2915e93fd6287aab756e199b +Subproject commit 1239b8837084ea2e582b8327cf520eee30e22e9a diff --git a/contracts b/contracts index 7a41cd59cd..1cab72ff3d 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 7a41cd59cdf2eb01cf31c2351b8d1ff6fbf52178 +Subproject commit 1cab72ff3dfcfe06ceed371a9db7a54a527e3bfb diff --git a/fastcache b/fastcache index f9d9f11052..8053d350d7 160000 --- a/fastcache +++ b/fastcache @@ -1 +1 @@ -Subproject commit f9d9f11052817d478af08b64d139d5f09ec3a68f +Subproject commit 8053d350d785b5dd877e208e1f0205bbd36faee7 diff --git a/go-ethereum b/go-ethereum index de513a2b2c..22399a74e2 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit de513a2b2c8e9e1239190992fcdaccef81cd387c +Subproject commit 22399a74e2b413e99a4f0d06c65862ced0d021c7 diff --git a/nitro-testnode b/nitro-testnode index c334820b2d..3922df9caf 160000 --- a/nitro-testnode +++ b/nitro-testnode @@ -1 +1 @@ -Subproject commit c334820b2dba6dfa4078f81ed242afbbccc19c91 +Subproject commit 3922df9caf7a65dd4168b8158c1244c5fe88780e diff --git a/staker/state_provider.go b/staker/state_provider.go index 74445923f7..5f131fb2ad 100644 --- a/staker/state_provider.go +++ b/staker/state_provider.go @@ -40,41 +40,43 @@ var ( ) type BoldConfig struct { - Enable bool `koanf:"enable"` - 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"` - API bool `koanf:"api"` - APIHost string `koanf:"api-host"` - APIPort uint16 `koanf:"api-port"` - APIDBPath string `koanf:"api-db-path"` + Enable bool `koanf:"enable"` + 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"` + API bool `koanf:"api"` + APIHost string `koanf:"api-host"` + APIPort uint16 `koanf:"api-port"` + APIDBPath string `koanf:"api-db-path"` + TrackChallengeParentAssertionHashes []string `koanf:"track-challenge-parent-assertion-hashes"` } var DefaultBoldConfig = BoldConfig{ - Enable: false, - Mode: "make-mode", - BlockChallengeLeafHeight: 1 << 5, - BigStepLeafHeight: 1 << 8, - SmallStepLeafHeight: 1 << 10, - NumBigSteps: 3, - ValidatorName: "default-validator", - MachineLeavesCachePath: "/tmp/machine-leaves-cache", - AssertionPostingIntervalSeconds: 30, - AssertionScanningIntervalSeconds: 30, - AssertionConfirmingIntervalSeconds: 60, - EdgeTrackerWakeIntervalSeconds: 1, - API: false, - APIHost: "127.0.0.1", - APIPort: 9393, - APIDBPath: "/tmp/bold-api-db", + Enable: false, + Mode: "make-mode", + BlockChallengeLeafHeight: 1 << 5, + BigStepLeafHeight: 1 << 8, + SmallStepLeafHeight: 1 << 10, + NumBigSteps: 3, + ValidatorName: "default-validator", + MachineLeavesCachePath: "/tmp/machine-leaves-cache", + AssertionPostingIntervalSeconds: 30, + AssertionScanningIntervalSeconds: 30, + AssertionConfirmingIntervalSeconds: 60, + EdgeTrackerWakeIntervalSeconds: 1, + API: false, + APIHost: "127.0.0.1", + APIPort: 9393, + APIDBPath: "/tmp/bold-api-db", + TrackChallengeParentAssertionHashes: []string{}, } func BoldConfigAddOptions(prefix string, f *flag.FlagSet) { @@ -94,6 +96,7 @@ func BoldConfigAddOptions(prefix string, f *flag.FlagSet) { f.String(prefix+".api-host", DefaultBoldConfig.APIHost, "bold api host") f.Uint16(prefix+".api-port", DefaultBoldConfig.APIPort, "bold api port") f.String(prefix+".api-db-path", DefaultBoldConfig.APIDBPath, "bold api db path") + f.StringSlice(prefix+".track-challenge-parent-assertion-hashes", DefaultBoldConfig.TrackChallengeParentAssertionHashes, "only track challenges/edges with these parent assertion hashes") } func (c *BoldConfig) Validate() error {