Skip to content

Commit

Permalink
Add config option to track specifi challenge with the specified paren…
Browse files Browse the repository at this point in the history
…t assertion hashes
  • Loading branch information
amsanghi authored and rauljordan committed Jun 3, 2024
1 parent b8c6502 commit 1caa6f5
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 37 deletions.
175 changes: 175 additions & 0 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 46 files
+0 −1 .prettierignore
+1 −7 foundry.toml
+2 −4 package.json
+5 −0 remappings.txt
+1 −2 scripts/config.ts.example
+1 −11 scripts/createERC20Rollup.ts
+1 −10 scripts/createEthRollup.ts
+1 −6 scripts/deployment.ts
+51 −108 scripts/deploymentUtils.ts
+0 −117 scripts/local-deployment/deployCreatorAndCreateRollup.ts
+48 −221 scripts/rollupCreation.ts
+0 −208 src/chain/CacheManager.sol
+45 −0 src/challenge/ChallengeLib.sol
+9 −24 src/challenge/ChallengeManager.sol
+0 −13 src/challenge/IChallengeManager.sol
+0 −52 src/mocks/Benchmarks.sol
+0 −117 src/mocks/MultiCallTest.sol
+0 −126 src/mocks/Program.sol
+0 −176 src/mocks/SdkStorage.sol
+0 −22 src/mocks/SimpleCacheManager.sol
+0 −10 src/osp/IOneStepProofEntry.sol
+7 −81 src/osp/OneStepProofEntry.sol
+20 −64 src/osp/OneStepProver0.sol
+2 −201 src/osp/OneStepProverHostIo.sol
+33 −4 src/osp/OneStepProverMemory.sol
+0 −2 src/precompiles/ArbDebug.sol
+9 −51 src/precompiles/ArbOwner.sol
+0 −119 src/precompiles/ArbWasm.sol
+0 −33 src/precompiles/ArbWasmCache.sol
+47 −88 src/state/Deserialize.sol
+3 −38 src/state/Instructions.sol
+15 −92 src/state/Machine.sol
+4 −22 src/state/MerkleProof.sol
+1 −3 src/state/Module.sol
+0 −54 src/state/ModuleMemory.sol
+0 −58 src/state/MultiStack.sol
+1 −6 src/state/StackFrame.sol
+1 −13 src/state/Value.sol
+1 −6 src/state/ValueStack.sol
+0 −167 test/foundry/CacheManager.t.sol
+10 −107 test/foundry/ChallengeManager.t.sol
+1 −3 test/signatures/ChallengeManager
+0 −9 test/signatures/OneStepProofEntry
+1 −1 test/signatures/test-sigs.bash
+0 −1 test/storage/ChallengeManager
+139 −149 yarn.lock
2 changes: 1 addition & 1 deletion fastcache
2 changes: 1 addition & 1 deletion go-ethereum
Submodule go-ethereum updated 692 files
67 changes: 35 additions & 32 deletions staker/state_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down

0 comments on commit 1caa6f5

Please sign in to comment.