Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bold fixes #2770

Open
wants to merge 25 commits into
base: bold-review
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6497de1
Snapshot of trying to get bold tests passing again
eljobe Oct 23, 2024
f7588dc
Fix state provider and pull in bold unify-req-meta
PlasmaPower Oct 25, 2024
10ffac0
Merge branch 'bold-review' into bold-fix-tests
eljobe Oct 25, 2024
dba3e46
Update to the tip of bold/unify-req-meta
eljobe Oct 25, 2024
a5f3cf7
Get's the bold_state_provider_test.go tests passing
eljobe Oct 25, 2024
5caa3a2
Get TestChallengeProtocolBOLD passing
PlasmaPower Oct 25, 2024
2b1de35
Fix the cache
eljobe Oct 28, 2024
04a8d83
Add a test challenging the start step in BoLD
PlasmaPower Oct 31, 2024
4649a54
Update the pin for the bold submodule
eljobe Oct 31, 2024
b38a1fa
WIP: Add the boldmach wrapper
eljobe Nov 1, 2024
976a18f
Fix the two obviously errored hasStepped bits
eljobe Nov 1, 2024
4c316e5
Fix TestChallengeProtocolBOLDStartStepChallenge
PlasmaPower Nov 2, 2024
11afd69
Fix the execution_run tests
eljobe Nov 4, 2024
c3f806e
Attempt at fixing the virtual leaves issue
eljobe Nov 4, 2024
6e20fc6
Begin work on TestChallengeProtocolBOLDVirtualBlocks
PlasmaPower Nov 5, 2024
e0fd4df
Merge pull request #2769 from OffchainLabs/bold-start-step-test
eljobe Nov 5, 2024
463f167
Complete TestChallengeProtocolBOLDVirtualBlocks
PlasmaPower Nov 5, 2024
259a4eb
Handle challenges in the virtually padded part of the leaaves
eljobe Nov 5, 2024
30af4ff
Get the test to compile
eljobe Nov 6, 2024
e712059
Split virtual blocks test into first and near last virtual block tests
PlasmaPower Nov 6, 2024
d3266db
Update test to better handle virtual blocks returned by honest impl
PlasmaPower Nov 6, 2024
ae1d18a
Fix the CollectProof and CollectMachineHashes calls
eljobe Nov 7, 2024
7056809
Merge branch 'bold-fix-tests' of github.com:OffchainLabs/nitro into b…
eljobe Nov 7, 2024
2f0bc89
Get the branch building again
eljobe Nov 12, 2024
0abf704
Fix the wiring after the giant refactoring in bold repo
eljobe Nov 14, 2024
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
6 changes: 6 additions & 0 deletions arbitrator/prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ pub unsafe extern "C" fn arbitrator_load_wavm_binary(binary_path: *const c_char)
}
}

#[no_mangle]
#[cfg(feature = "native")]
pub unsafe extern "C" fn arbitrator_new_finished() -> *mut Machine {
Box::into_raw(Box::new(Machine::new_finished()))
}

unsafe fn cstr_to_string(c_str: *const c_char) -> String {
CStr::from_ptr(c_str).to_string_lossy().into_owned()
}
Expand Down
42 changes: 42 additions & 0 deletions arbitrator/prover/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,39 @@ impl Machine {
Ok(mach)
}

// new_finished returns a Machine in the Finished state at step 0.
//
// This allows the Mahine to be set up to model the final state of the
// machine at the end of the execution of a block.
//
// Callers should use set_global_state to set the global state of the
// machine to the global state at the end of the block.
pub fn new_finished() -> Machine {
Machine {
steps: 0,
status: MachineStatus::Finished,
global_state: Default::default(),
// The machine is in the Finished state, so nothing else really matters.
// values_stacks and frame_stacks cannot be empty for proof serialization,
// but everything else can just be entirely blank.
thread_state: ThreadState::Main,
value_stacks: vec![Vec::new()],
frame_stacks: vec![Vec::new()],
internal_stack: Default::default(),
modules: Default::default(),
modules_merkle: Default::default(),
pc: Default::default(),
stdio_output: Default::default(),
inbox_contents: Default::default(),
first_too_far: Default::default(),
preimage_resolver: PreimageResolverWrapper::new(Arc::new(|_, _, _| None)),
stylus_modules: Default::default(),
initial_hash: Default::default(),
context: Default::default(),
debug_info: Default::default(),
}
}

pub fn new_from_wavm(wavm_binary: &Path) -> Result<Machine> {
let mut modules: Vec<Module> = {
let compressed = std::fs::read(wavm_binary)?;
Expand Down Expand Up @@ -2867,6 +2900,15 @@ impl Machine {
let mod_merkle = self.get_modules_merkle();
out!(mod_merkle.root());

if self.is_halted() {
// If the machine is halted, instead of serializing the module,
// serialize the global state and return.
// This is for the "kickstart" BoLD proof, but it's backwards compatible
// with the old OSP behavior which reads no further.
out!(self.global_state.serialize());
return data;
}

// End machine serialization, serialize module

let module = &self.modules[self.pc.module()];
Expand Down
2 changes: 1 addition & 1 deletion bold
Submodule bold updated 53 files
+12 −8 api/backend/backend.go
+25 −5 api/db/db.go
+5 −3 api/db/db_test.go
+2 −0 api/db/schema.go
+5 −1 api/server/server.go
+3 −1 api/types.go
+1 −0 assertions/BUILD.bazel
+15 −7 assertions/confirmation.go
+121 −106 assertions/manager.go
+136 −174 assertions/manager_test.go
+19 −7 assertions/poster.go
+16 −27 assertions/poster_test.go
+13 −29 assertions/sync.go
+4 −4 assertions/sync_test.go
+7 −5 chain-abstraction/interfaces.go
+19 −20 chain-abstraction/sol-implementation/assertion_chain.go
+33 −31 chain-abstraction/sol-implementation/assertion_chain_test.go
+10 −15 chain-abstraction/sol-implementation/edge_challenge_manager.go
+55 −126 chain-abstraction/sol-implementation/edge_challenge_manager_test.go
+2 −5 challenge-manager/BUILD.bazel
+1 −0 challenge-manager/chain-watcher/BUILD.bazel
+113 −98 challenge-manager/chain-watcher/watcher.go
+19 −14 challenge-manager/chain-watcher/watcher_test.go
+21 −11 challenge-manager/challenge-tree/add_edge.go
+1 −1 challenge-manager/challenge-tree/tree.go
+31 −36 challenge-manager/challenge-tree/tree_test.go
+71 −39 challenge-manager/challenges.go
+8 −9 challenge-manager/edge-tracker/challenge_confirmation.go
+49 −122 challenge-manager/edge-tracker/tracker.go
+114 −232 challenge-manager/manager.go
+60 −38 challenge-manager/manager_test.go
+229 −0 challenge-manager/stack.go
+11 −18 challenge-manager/types/interfaces.go
+2 −1 challenge-manager/types/mode.go
+182 −140 layer2-state-provider/history_commitment_provider.go
+1 −17 layer2-state-provider/history_commitment_provider_test.go
+54 −29 layer2-state-provider/provider.go
+9 −0 logs/ephemeral/BUILD.bazel
+67 −0 logs/ephemeral/log.go
+70 −0 logs/ephemeral/log_test.go
+1 −0 state-commitments/prefix-proofs/BUILD.bazel
+34 −19 state-commitments/prefix-proofs/prefix_proofs_test.go
+0 −1 testing/endtoend/BUILD.bazel
+28 −31 testing/endtoend/e2e_test.go
+7 −19 testing/endtoend/helpers_test.go
+1 −0 testing/integration/BUILD.bazel
+17 −10 testing/integration/prefixproofs_test.go
+1 −0 testing/mocks/BUILD.bazel
+59 −13 testing/mocks/mocks.go
+9 −10 testing/mocks/state-provider/history_provider.go
+25 −30 testing/mocks/state-provider/history_provider_test.go
+1 −1 testing/mocks/state-provider/layer2_state_provider.go
+31 −34 testing/setup/rollup_stack.go
1 change: 1 addition & 0 deletions cmd/nitro-val/nitro_val.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func mainImpl() int {
func() *valnode.Config { return &liveNodeConfig.Get().Validation },
stack,
fatalErrChan,
nil,
)
if err != nil {
log.Error("couldn't init validation node", "err", err)
Expand Down
1 change: 1 addition & 0 deletions cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ func mainImpl() int {
func() *valnode.Config { return &liveNodeConfig.Get().Validation },
stack,
fatalErrChan,
nil,
)
if err != nil {
valNode = nil
Expand Down
31 changes: 14 additions & 17 deletions staker/bold/bold_staker.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2023, Offchain Labs, Inc.
// For license information, see https://github.com/offchainlabs/bold/blob/main/LICENSE
package boldstaker
package bold

import (
"context"
Expand Down Expand Up @@ -394,31 +394,28 @@ func newBOLDChallengeManager(
scanningInterval := config.AssertionScanningInterval
// The interval at which the manager will attempt to confirm assertions.
confirmingInterval := config.AssertionConfirmingInterval
opts := []challengemanager.Opt{
challengemanager.WithName(config.StateProviderConfig.ValidatorName),
challengemanager.WithMode(BoldModes[config.Mode]),
challengemanager.WithAssertionPostingInterval(postingInterval),
challengemanager.WithAssertionScanningInterval(scanningInterval),
challengemanager.WithAssertionConfirmingInterval(confirmingInterval),
challengemanager.WithAddress(txOpts.From),
// Configure the validator to track only certain challenges if configured to do so.
challengemanager.WithTrackChallengeParentAssertionHashes(config.TrackChallengeParentAssertionHashes),

stackOpts := []challengemanager.StackOpt{
challengemanager.StackWithName(config.StateProviderConfig.ValidatorName),
challengemanager.StackWithMode(BoldModes[config.Mode]),
challengemanager.StackWithPollingInterval(scanningInterval),
challengemanager.StackWithPostingInterval(postingInterval),
challengemanager.StackWithConfirmationInterval(confirmingInterval),
challengemanager.StackWithTrackChallengeParentAssertionHashes(config.TrackChallengeParentAssertionHashes),
}
if config.API {
// Conditionally enables the BOLD API if configured.
opts = append(opts, challengemanager.WithAPIEnabled(fmt.Sprintf("%s:%d", config.APIHost, config.APIPort), config.APIDBPath))
apiAddr := fmt.Sprintf("%s:%d", config.APIHost, config.APIPort)
stackOpts = append(stackOpts, challengemanager.StackWithAPIEnabled(apiAddr, config.APIDBPath))
}
manager, err := challengemanager.New(
ctx,

manager, err := challengemanager.NewChallengeStack(
assertionChain,
provider,
assertionChain.RollupAddress(),
opts...,
stackOpts...,
)
if err != nil {
return nil, fmt.Errorf("could not create challenge manager: %w", err)
}
provider.UpdateAPIDatabase(manager.Database())
return manager, nil
}

Expand Down
Loading
Loading