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

Support the Arbitrum BoLD Challenge Protocol in Nitro #2362

Merged
merged 720 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
720 commits
Select commit Hold shift + click to select a range
5bba5e0
clean up assertion_on_large_number_of_block_test.go
amsanghi May 31, 2024
9d720a8
clean up bold_challenge_protocol_test.go
amsanghi May 31, 2024
2467ac0
clean up CreateBoldExecutionRun
amsanghi May 31, 2024
22ccdb7
Clean up manager call
amsanghi May 31, 2024
2a44c92
Merge branch 'master' into bold-review
amsanghi May 31, 2024
b8c6502
support bold main
rauljordan Jun 3, 2024
100ad6e
support config
rauljordan Jun 3, 2024
abbcd20
edits
rauljordan Jun 3, 2024
5935794
bold commit
rauljordan Jun 3, 2024
2cb59b9
get staked info
rauljordan Jun 4, 2024
a7f2fbe
support bold initialization in staker
rauljordan Jun 4, 2024
053cb36
support macos in download machine
rauljordan Jun 4, 2024
6c4c401
Merge branch 'master' into bold-review
rauljordan Jun 6, 2024
7b77f7f
address some review comments
rauljordan Jun 6, 2024
4e7b4a5
Merge branch 'bold-review' of github.com:OffchainLabs/nitro into bold…
rauljordan Jun 6, 2024
cbc3f7e
revert arbitrator edits
rauljordan Jun 6, 2024
983a1e8
revert some old stuff
rauljordan Jun 6, 2024
2a313c1
arbitrator
rauljordan Jun 6, 2024
6835a7b
cache comments
rauljordan Jun 7, 2024
099d03c
sync
rauljordan Jun 7, 2024
bfba244
commentary and cleanup
rauljordan Jun 7, 2024
5ccbbb4
edit names
rauljordan Jun 7, 2024
af8cc34
staker switch elsewhere
rauljordan Jun 7, 2024
ba2e3b1
bridgegen
rauljordan Jun 7, 2024
a171c95
more porting
rauljordan Jun 7, 2024
0375950
multiprotocol switcher
rauljordan Jun 7, 2024
b9c6c10
define the multiprotocol staker
rauljordan Jun 7, 2024
c3d8ec8
builds
rauljordan Jun 7, 2024
4e599d4
Merge branch 'master' into bold-review
rauljordan Jun 11, 2024
751f1d9
bold commit
rauljordan Jun 11, 2024
9a9012d
Merge branch 'bold-review' of github.com:OffchainLabs/nitro into bold…
rauljordan Jun 11, 2024
192e047
bold item
rauljordan Jun 11, 2024
6a33e3e
provide block validator
rauljordan Jun 11, 2024
33e2ca8
rev
rauljordan Jun 11, 2024
6470551
use stateless
rauljordan Jun 11, 2024
e57b0b0
add challenge tags
rauljordan Jun 11, 2024
737b99e
Merge branch 'master' into bold-review
rauljordan Jun 11, 2024
9ae02fc
Merge branch 'master' into bold-review
rauljordan Jun 11, 2024
28ba3e6
Merge branch 'bold-review' of github.com:OffchainLabs/nitro into bold…
rauljordan Jun 11, 2024
0b217ac
edit
rauljordan Jun 11, 2024
573880a
Merge branch 'master' into bold-review
rauljordan Jun 11, 2024
9363a29
build
rauljordan Jun 11, 2024
e721188
Merge branch 'bold-review' of github.com:OffchainLabs/nitro into bold…
rauljordan Jun 11, 2024
0b59ee3
master
rauljordan Jun 11, 2024
494d2a6
geth
rauljordan Jun 11, 2024
43d3da8
lint
rauljordan Jun 11, 2024
9aa0a82
Merge branch 'master' into bold-review
rauljordan Jun 12, 2024
99a6252
chal cache
rauljordan Jun 12, 2024
a2d9e45
check positive condition
rauljordan Jun 12, 2024
b2f8e53
config items
rauljordan Jun 12, 2024
06f49df
dedup
rauljordan Jun 12, 2024
6c2781e
logs on switch
rauljordan Jun 12, 2024
6704f92
ensure single instance init and use block latest validated state
rauljordan Jun 12, 2024
2c58a9e
ci for state provider pass
rauljordan Jun 13, 2024
c2b0f82
ci
rauljordan Jun 13, 2024
ad8b825
ci runs but need diff validators
rauljordan Jun 13, 2024
4426b46
ci challenge
rauljordan Jun 13, 2024
e5e4ea1
gotags
rauljordan Jun 13, 2024
6abb7cb
Merge branch 'master' into bold-review
rauljordan Jun 13, 2024
928a8f8
unit tests
rauljordan Jun 13, 2024
d66cc0e
Merge branch 'bold-review' of github.com:OffchainLabs/nitro into bold…
rauljordan Jun 13, 2024
d7efbab
chal timeout
rauljordan Jun 13, 2024
57a0d95
Merge branch 'master' into bold-review
rauljordan Jun 13, 2024
b3f29c0
test flakey when parallel
rauljordan Jun 13, 2024
9565823
rem
rauljordan Jun 13, 2024
528f868
Merge branch 'bold-review' of github.com:OffchainLabs/nitro into bold…
rauljordan Jun 13, 2024
69bc7bd
tags
rauljordan Jun 13, 2024
886a21d
much simpler execution run
rauljordan Jun 13, 2024
e9cc824
include server arb changes
rauljordan Jun 14, 2024
58e093f
exec run pass
rauljordan Jun 14, 2024
f89cbd8
bold commit
rauljordan Jun 14, 2024
6a8b741
Merge branch 'get-machine-hashes-with-step' into bold-review
rauljordan Jun 17, 2024
06663c2
include latest
rauljordan Jun 17, 2024
c3f737e
Merge branch 'bold-challenge-cache' into bold-review
rauljordan Jun 17, 2024
7ed6155
builds
rauljordan Jun 17, 2024
d770502
Merge branch 'get-machine-hashes-with-step' into bold-review
rauljordan Jun 17, 2024
8f8459d
state provider changes
rauljordan Jun 18, 2024
513bee2
Merge branch 'bold-challenge-cache' into bold-review
rauljordan Jun 18, 2024
30f125b
Merge branch 'master' into bold-review
rauljordan Jun 18, 2024
25d0437
Merge branch 'master' into bold-review
rauljordan Jun 20, 2024
8fb0788
bold item
rauljordan Jun 20, 2024
9ab81eb
bold commit
rauljordan Jun 20, 2024
59fc8a5
bold commit
rauljordan Jun 20, 2024
5774b3d
update bold branch
rauljordan Jun 21, 2024
8e3e19a
update bold
rauljordan Jun 24, 2024
0437e7b
add osp logging
rauljordan Jun 24, 2024
4bfe480
Merge branch 'master' into bold-review
rauljordan Jun 24, 2024
9973230
edits
rauljordan Jun 24, 2024
746978c
add in validator
rauljordan Jun 25, 2024
a6a2312
edits
rauljordan Jun 25, 2024
a6a29e1
edit bold commit
rauljordan Jun 25, 2024
a63950c
norace
rauljordan Jun 25, 2024
20a9857
edit bold main
rauljordan Jun 29, 2024
e0154ec
Merge branch 'master' into bold-review
amsanghi Jul 1, 2024
65819f0
Merge branch 'get-machine-hashes-with-step' into bold-review
amsanghi Jul 1, 2024
5589f2b
minor fix
amsanghi Jul 1, 2024
6656d0e
Merge branch 'bold-review' of github.com:OffchainLabs/nitro into bold…
rauljordan Jul 8, 2024
3b9ad4d
edits to state provider
rauljordan Jul 8, 2024
2506150
sync master
rauljordan Jul 8, 2024
7012c91
Merge branch 'master' into bold-review
rauljordan Jul 9, 2024
5f2e60d
edits
rauljordan Jul 9, 2024
658a5ce
commits
rauljordan Jul 9, 2024
7ce2089
Merge branch 'master' into bold-review
rauljordan Jul 10, 2024
8265691
Merge branch 'master' into bold-review
rauljordan Jul 12, 2024
a525bb1
Merge branch 'master' into bold-review
rauljordan Jul 15, 2024
0a078a7
Merge branch 'master' into bold-review
rauljordan Jul 18, 2024
051095f
Merge branch 'master' into bold-review
amsanghi Aug 5, 2024
c56a509
Changes based on PR comments
amsanghi Aug 5, 2024
d3e62a4
fix build and lint
amsanghi Aug 5, 2024
6011b74
Changes based on PR comments and fix build
amsanghi Aug 6, 2024
633f175
Merge branch 'master' into bold-review
amsanghi Aug 6, 2024
57af6a4
reword ExecutionStateAfterPreviousState comment
amsanghi Aug 6, 2024
533fceb
add dangerous option where validator is nil and node just assumes all…
amsanghi Aug 6, 2024
e3b8d70
checks for the wasmModuleRoot in the rollup and updates validator reg…
amsanghi Aug 6, 2024
c6faf78
Changes based on PR comments
amsanghi Aug 6, 2024
2d479d1
Merge branch 'master' into bold-review
amsanghi Aug 6, 2024
e1d40d3
fix test
amsanghi Aug 6, 2024
4914c34
fix test
amsanghi Aug 7, 2024
abdc7a1
rename function
amsanghi Aug 7, 2024
efdeb8d
Merge branch 'master' into bold-review
amsanghi Aug 13, 2024
8446078
Changes based on PR comments
amsanghi Aug 13, 2024
3b2cfdb
Send UpdateLatestStaked and UpdateLatestConfirmed notifications
amsanghi Aug 14, 2024
b28b78c
Merge branch 'master' into bold-review
amsanghi Aug 14, 2024
220d133
Merge branch 'master' into bold-review
amsanghi Aug 27, 2024
3c86220
clean up
amsanghi Aug 27, 2024
2205adb
Merge branch 'master' into bold-review
amsanghi Aug 28, 2024
d97ae8e
fix build
amsanghi Aug 28, 2024
748a9f6
fix build and panic
amsanghi Aug 28, 2024
f3bf2ac
fix test
amsanghi Aug 28, 2024
e734a4d
Add build tags
amsanghi Aug 29, 2024
88d143b
update bold main branch
rauljordan Sep 11, 2024
8e12821
update main
rauljordan Sep 11, 2024
c102262
Merge branch 'master' into bold-review
eljobe Sep 19, 2024
c80e048
Fix rawdb -> ethdb change
eljobe Sep 19, 2024
7975a06
Merge branch 'master' into bold-review
amsanghi Sep 25, 2024
5334e63
Merge branch 'master' into bold-review
amsanghi Sep 26, 2024
b6cb5a1
Changes based on PR comments
amsanghi Sep 26, 2024
027a13b
Merge branch 'master' into bold-review
amsanghi Oct 9, 2024
c305135
fix build
amsanghi Oct 9, 2024
b23ab2c
Merge branch 'master' into bold-review
eljobe Oct 17, 2024
66ebcfc
Update bold to include the history committment optimizations
eljobe Oct 17, 2024
7e77151
Merge branch 'master' into bold-review
eljobe Oct 17, 2024
b3dd61d
Changes based on PR comments
amsanghi Oct 18, 2024
344eb20
Changes based on PR comments
amsanghi Oct 18, 2024
7ededde
refractor
amsanghi Oct 18, 2024
77ff553
Merge branch 'master' into bold-review
amsanghi Oct 23, 2024
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
0a2f031
Update bold-review to the head of bold/main
eljobe 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
ccdc7d8
Merge branch 'master' into bold-review
amsanghi Oct 28, 2024
60daa96
minor fix
amsanghi Oct 29, 2024
8606740
Merge branch 'master' into bold-review
amsanghi Oct 29, 2024
8e39be5
fix linter
amsanghi Oct 29, 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
683d190
Merge branch 'master' into bold-review
eljobe Nov 18, 2024
d763207
Merge branch 'bold-review' into bold-fix-tests
eljobe Nov 18, 2024
bf1838e
Update to the same go-ethereum pin as master
eljobe Nov 18, 2024
d0bf3f4
Fix the path since it was moved down a dir
eljobe Nov 18, 2024
7c1140f
Update the bold pin and remove some logging
eljobe Nov 19, 2024
361a747
Fix 2 lint issues
eljobe Nov 19, 2024
e9373e7
Merge commit '36a7ab854b8d528a50286c680f4b7c1a81d4eee2' into bold-review
eljobe Nov 19, 2024
4a323c3
Merge branch 'bold-review' into bold-fix-tests
eljobe Nov 19, 2024
0aa337a
Merge pull request #2770 from OffchainLabs/bold-fix-tests
eljobe Nov 19, 2024
0f2fd1c
Merge branch 'master' into bold-review
eljobe Nov 19, 2024
7537061
Remove maxNumberOfBlocks from bold state provider
eljobe Nov 20, 2024
b053a14
Merge branch 'master' into bold-review
eljobe Nov 20, 2024
1e0461f
Merge branch 'master' into bold-review
eljobe Nov 21, 2024
6cc1d2f
Update the bold pin to use the tip of main
eljobe Nov 21, 2024
331c12e
Update bold pin and adjust nitro code accordingly
eljobe Nov 21, 2024
f36ed0d
Get the BoLD challenge tests compiling again
eljobe Nov 21, 2024
19bc1ef
Bump nitro-testnode to bold-upgrade branch for bold testing
PlasmaPower Nov 22, 2024
4aba248
Fix bold staker without block validation enabled
PlasmaPower Nov 22, 2024
72ba88d
Fix multi protocol staker legacy staker wallet initialization
PlasmaPower Nov 22, 2024
eed7b12
Sync in the latests changes from the bold repo
eljobe Nov 22, 2024
e0a4a0f
Validator wallet refactor for bold
PlasmaPower Nov 22, 2024
b4f9dad
Address PR comments
PlasmaPower Nov 23, 2024
c2ac13a
Add documentation for the EOA struct
PlasmaPower Nov 23, 2024
0aa0cf8
Make bold state validated check more sturdy
PlasmaPower Nov 24, 2024
2821084
Fix bold state provider test exiting loop early
PlasmaPower Nov 24, 2024
7b92647
bug fix
rauljordan Nov 25, 2024
dac6070
del
rauljordan Nov 25, 2024
1f259a9
add back tag
rauljordan Nov 25, 2024
f1de4c5
edit bold submodule
rauljordan Nov 25, 2024
11b270e
fix conflicts
rauljordan Nov 25, 2024
9e07266
bold submod
rauljordan Nov 25, 2024
8aff5ee
bold submod
rauljordan Nov 25, 2024
cdee55d
Merge branch 'bold-review' into val-wallet-refactor
rauljordan Nov 25, 2024
e9ecd45
Merge pull request #2804 from OffchainLabs/val-wallet-refactor
rauljordan Nov 25, 2024
bd7bd35
Merge branch 'master' into bold-review
rauljordan Nov 25, 2024
b6ee9d2
Make previousGlobalState a value instead of pointer
eljobe Nov 26, 2024
89b4cb5
Update bold repo pin to main
eljobe Nov 27, 2024
6608888
remove nil opts from validation node creation
rauljordan Nov 27, 2024
5cec6a7
remove nil opts from validation node creation
rauljordan Nov 27, 2024
0e6e2a8
rem print
rauljordan Nov 27, 2024
1ad24f2
Test an overflow assertion
eljobe Nov 28, 2024
fd85fcd
Make the finished machine actually pass the global state
eljobe Nov 28, 2024
e5b5354
Merge branch 'bold-review' of github.com:OffchainLabs/nitro into bold…
eljobe Nov 28, 2024
4977148
Add BoLD ascii art for the log
eljobe Nov 28, 2024
e2a41e7
Rename maxInboxCount -> maxSeqInboxCount
eljobe Nov 28, 2024
c63db41
Merge pull request #2811 from OffchainLabs/bold-overflow-test
eljobe Nov 28, 2024
b9e263f
Merge branch 'bold-review' of github.com:OffchainLabs/nitro into bold…
eljobe Nov 28, 2024
6a0754a
Move the Info logging into the staker implmentations
eljobe Nov 29, 2024
abee6b8
commentary from lee addressed, part 1
rauljordan Dec 3, 2024
cdf48cf
address more review comments
rauljordan Dec 3, 2024
c874ed5
check stake token addr
rauljordan Dec 3, 2024
6cd3aec
move to test only file
rauljordan Dec 3, 2024
023ce1e
Merge branch 'master' into bold-review
rauljordan Dec 3, 2024
7b43136
lee feedback on testonly machine wrapper
rauljordan Dec 3, 2024
855462b
Merge branch 'bold-review' of github.com:OffchainLabs/nitro into bold…
rauljordan Dec 3, 2024
17f0bbb
nolint
rauljordan Dec 4, 2024
14796b3
feedback
rauljordan Dec 5, 2024
1d0c06f
more feedback from lee, contexts, no caching module root
rauljordan Dec 5, 2024
027e2bd
address remaining bold commentary
rauljordan Dec 5, 2024
6365875
add back
rauljordan Dec 5, 2024
bd2adae
add back block validator set module root
rauljordan Dec 5, 2024
ec0a917
rm log
rauljordan Dec 5, 2024
828ebf4
assertion hash topic and path defaults
rauljordan Dec 5, 2024
25a0f89
builds
rauljordan Dec 5, 2024
1f436a6
gci
rauljordan Dec 5, 2024
dc36a3f
gci
rauljordan Dec 5, 2024
d706059
build
rauljordan Dec 5, 2024
46d742e
test
rauljordan Dec 5, 2024
8518e3d
Less useBoldMachine pointers
PlasmaPower Dec 6, 2024
1e635e4
builds
rauljordan Dec 6, 2024
d372f30
Merge branch 'bold-review' of github.com:OffchainLabs/nitro into bold…
rauljordan Dec 6, 2024
a64cb81
builds
rauljordan Dec 6, 2024
1a47581
Don't double wrap bold machines
PlasmaPower Dec 6, 2024
76a8a0f
Bump nitro-testnode to latest master to fix CI
PlasmaPower Dec 6, 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
2 changes: 1 addition & 1 deletion bold
Submodule bold updated 0 files
4 changes: 2 additions & 2 deletions cmd/chaininfo/arbitrum_chain_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"sequencer-inbox": "0x1c479675ad559dc151f6ec7ed3fbf8cee79582b6",
"validator-utils": "0x9e40625f52829cf04bc4839f186d621ee33b0e67",
"validator-wallet-creator": "0x960953f7c69cd2bc2322db9223a815c680ccc7ea",
"stake-token": "0x0000000000000000000000000000000000000000",
"stake-token": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"deployed-at": 15411056
}
},
Expand Down Expand Up @@ -91,7 +91,7 @@
"sequencer-inbox": "0x211e1c4c7f1bf5351ac850ed10fd68cffcf6c21b",
"validator-utils": "0x2B081fbaB646D9013f2699BebEf62B7e7d7F0976",
"validator-wallet-creator": "0xe05465Aab36ba1277dAE36aa27a7B74830e74DE4",
"stake-token": "0x0000000000000000000000000000000000000000",
"stake-token": "0x765277eebeca2e31912c9946eae1021199b39c61",
"deployed-at": 15016829
}
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func mainImpl() int {
flag.Usage()
log.Crit("validator must have the parent chain reader enabled")
}
strategy, err := nodeConfig.Node.Staker.ParseStrategy()
strategy, err := legacystaker.ParseStrategy(nodeConfig.Node.Staker.Strategy)
if err != nil {
log.Crit("couldn't parse staker strategy", "err", err)
}
Expand Down
121 changes: 75 additions & 46 deletions staker/bold/bold_staker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"errors"
"fmt"
"math/big"
"os"
"path/filepath"
"time"

flag "github.com/spf13/pflag"
Expand All @@ -22,10 +24,12 @@ import (
challengemanager "github.com/offchainlabs/bold/challenge-manager"
boldtypes "github.com/offchainlabs/bold/challenge-manager/types"
l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider"
"github.com/offchainlabs/bold/solgen/go/challengeV2gen"
boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen"
"github.com/offchainlabs/bold/util"
"github.com/offchainlabs/nitro/arbnode/dataposter"
"github.com/offchainlabs/nitro/arbutil"
"github.com/offchainlabs/nitro/cmd/conf"
"github.com/offchainlabs/nitro/staker"
legacystaker "github.com/offchainlabs/nitro/staker/legacy"
"github.com/offchainlabs/nitro/util/headerreader"
Expand All @@ -34,6 +38,7 @@ import (
)

var assertionCreatedId common.Hash
var homeDir string

func init() {
rollupAbi, err := boldrollup.RollupCoreMetaData.GetAbi()
Expand All @@ -45,17 +50,16 @@ func init() {
panic("RollupCore ABI missing AssertionCreated event")
}
assertionCreatedId = assertionCreatedEvent.ID
homeDirPath, err := os.UserHomeDir()
if err != nil {
panic(err)
}
homeDir = homeDirPath
}

type BoldConfig struct {
Enable bool `koanf:"enable"`
Mode string `koanf:"mode"`
// The height constants at each challenge level for the BOLD challenge manager.
BlockChallengeLeafHeight uint64 `koanf:"block-challenge-leaf-height"`
BigStepLeafHeight uint64 `koanf:"big-step-leaf-height"`
SmallStepLeafHeight uint64 `koanf:"small-step-leaf-height"`
// Number of big step challenges in the BOLD protocol.
NumBigSteps uint64 `koanf:"num-big-steps"`
Enable bool `koanf:"enable"`
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 @@ -70,6 +74,16 @@ type BoldConfig struct {
CheckStakerSwitchInterval time.Duration `koanf:"check-staker-switch-interval"`
StateProviderConfig StateProviderConfig `koanf:"state-provider-config"`
StartValidationFromStaked bool `koanf:"start-validation-from-staked"`
PlasmaPower marked this conversation as resolved.
Show resolved Hide resolved
strategy legacystaker.StakerStrategy
}

func (c *BoldConfig) Validate() error {
strategy, err := legacystaker.ParseStrategy(c.Strategy)
if err != nil {
return err
}
c.strategy = strategy
return nil
}

type StateProviderConfig struct {
Expand All @@ -83,43 +97,35 @@ type StateProviderConfig struct {
var DefaultStateProviderConfig = StateProviderConfig{
ValidatorName: "default-validator",
CheckBatchFinality: true,
MachineLeavesCachePath: "/tmp/machine-leaves-cache",
MachineLeavesCachePath: filepath.Join(homeDir, conf.PersistentConfigDefault.GlobalConfig, "machine-hashes-cache"),
PlasmaPower marked this conversation as resolved.
Show resolved Hide resolved
}

var DefaultBoldConfig = BoldConfig{
Enable: false,
Mode: "make-mode",
BlockChallengeLeafHeight: 1 << 26,
BigStepLeafHeight: 1 << 23,
SmallStepLeafHeight: 1 << 19,
NumBigSteps: 1,
Strategy: "Watchtower",
AssertionPostingInterval: time.Minute * 15,
AssertionScanningInterval: time.Minute,
AssertionConfirmingInterval: time.Minute,
API: false,
APIHost: "127.0.0.1",
APIPort: 9393,
APIDBPath: "/tmp/bold-api-db",
APIDBPath: filepath.Join(homeDir, conf.PersistentConfigDefault.GlobalConfig, "bold-api-db"),
rauljordan marked this conversation as resolved.
Show resolved Hide resolved
TrackChallengeParentAssertionHashes: []string{},
CheckStakerSwitchInterval: time.Minute, // Every minute, check if the Nitro node staker should switch to using BOLD.
StateProviderConfig: DefaultStateProviderConfig,
StartValidationFromStaked: true,
}

var BoldModes = map[string]boldtypes.Mode{
"watchtower-mode": boldtypes.WatchTowerMode,
"resolve-mode": boldtypes.ResolveMode,
"defensive-mode": boldtypes.DefensiveMode,
"make-mode": boldtypes.MakeMode,
var BoldModes = map[legacystaker.StakerStrategy]boldtypes.Mode{
legacystaker.WatchtowerStrategy: boldtypes.WatchTowerMode,
legacystaker.DefensiveStrategy: boldtypes.DefensiveMode,
legacystaker.ResolveNodesStrategy: boldtypes.ResolveMode,
legacystaker.MakeNodesStrategy: boldtypes.MakeMode,
}

func BoldConfigAddOptions(prefix string, f *flag.FlagSet) {
f.Bool(prefix+".enable", DefaultBoldConfig.Enable, "enable bold challenge protocol")
f.String(prefix+".mode", DefaultBoldConfig.Mode, "define the bold validator staker strategy")
f.Uint64(prefix+".block-challenge-leaf-height", DefaultBoldConfig.BlockChallengeLeafHeight, "block challenge leaf height")
f.Uint64(prefix+".big-step-leaf-height", DefaultBoldConfig.BigStepLeafHeight, "big challenge leaf height")
f.Uint64(prefix+".small-step-leaf-height", DefaultBoldConfig.SmallStepLeafHeight, "small challenge leaf height")
f.Uint64(prefix+".num-big-steps", DefaultBoldConfig.NumBigSteps, "num big steps")
f.String(prefix+".strategy", DefaultBoldConfig.Strategy, "define the bold validator staker strategy, either watchtower, defensive, stakeLatest, or makeNodes")
f.Duration(prefix+".assertion-posting-interval", DefaultBoldConfig.AssertionPostingInterval, "assertion posting interval")
f.Duration(prefix+".assertion-scanning-interval", DefaultBoldConfig.AssertionScanningInterval, "scan assertion interval")
f.Duration(prefix+".assertion-confirming-interval", DefaultBoldConfig.AssertionConfirmingInterval, "confirm assertion interval")
Expand Down Expand Up @@ -147,7 +153,6 @@ type BOLDStaker struct {
statelessBlockValidator *staker.StatelessBlockValidator
rollupAddress common.Address
l1Reader *headerreader.HeaderReader
lastWasmModuleRoot common.Hash
client protocol.ChainBackend
callOpts bind.CallOpts
wallet legacystaker.ValidatorWalletInterface
Expand All @@ -169,6 +174,9 @@ func NewBOLDStaker(
stakedNotifiers []legacystaker.LatestStakedNotifier,
confirmedNotifiers []legacystaker.LatestConfirmedNotifier,
) (*BOLDStaker, error) {
if err := config.Validate(); err != nil {
return nil, err
}
wrappedClient := util.NewBackendWrapper(l1Reader.Client(), rpc.LatestBlockNumber)
manager, err := newBOLDChallengeManager(ctx, rollupAddress, txOpts, l1Reader, wrappedClient, blockValidator, statelessBlockValidator, config, dataPoster)
if err != nil {
Expand All @@ -192,15 +200,16 @@ func NewBOLDStaker(
// Initialize Updates the block validator module root.
// And updates the init state of the block validator if block validator has not started yet.
func (b *BOLDStaker) Initialize(ctx context.Context) error {
if err := b.updateBlockValidatorModuleRoot(ctx); err != nil {
return err
err := b.updateBlockValidatorModuleRoot(ctx)
if err != nil {
log.Warn("error updating latest wasm module root", "err", err)
}
walletAddressOrZero := b.wallet.AddressOrZero()
var stakerAddr common.Address
if b.wallet.DataPoster() != nil {
stakerAddr = b.wallet.DataPoster().Sender()
}
log.Info("running as validator", "txSender", stakerAddr, "actingAsWallet", walletAddressOrZero, "mode", b.config.Mode)
log.Info("running as validator", "txSender", stakerAddr, "actingAsWallet", walletAddressOrZero, "strategy", b.config.Strategy)

if b.blockValidator != nil && b.config.StartValidationFromStaked && !b.blockValidator.Started() {
rollupUserLogic, err := boldrollup.NewRollupUserLogic(b.rollupAddress, b.client)
Expand Down Expand Up @@ -326,16 +335,7 @@ func (b *BOLDStaker) updateBlockValidatorModuleRoot(ctx context.Context) error {
if err != nil {
return err
}
if moduleRoot != b.lastWasmModuleRoot {
err := b.blockValidator.SetCurrentWasmModuleRoot(moduleRoot)
if err != nil {
return err
}
b.lastWasmModuleRoot = moduleRoot
} else if (moduleRoot == common.Hash{}) {
return errors.New("wasmModuleRoot in rollup is zero")
}
return nil
return b.blockValidator.SetCurrentWasmModuleRoot(moduleRoot)
}

func (b *BOLDStaker) getCallOpts(ctx context.Context) *bind.CallOpts {
Expand Down Expand Up @@ -367,13 +367,43 @@ func newBOLDChallengeManager(
if err != nil {
return nil, fmt.Errorf("could not get challenge manager: %w", err)
}
chalManagerBindings, err := challengeV2gen.NewEdgeChallengeManager(chalManager, client)
if err != nil {
return nil, fmt.Errorf("could not create challenge manager bindings: %w", err)
}
assertionChain, err := solimpl.NewAssertionChain(ctx, rollupAddress, chalManager, txOpts, client, NewDataPosterTransactor(dataPoster))
if err != nil {
return nil, fmt.Errorf("could not create assertion chain: %w", err)
}
blockChallengeLeafHeight := l2stateprovider.Height(config.BlockChallengeLeafHeight)
bigStepHeight := l2stateprovider.Height(config.BigStepLeafHeight)
smallStepHeight := l2stateprovider.Height(config.SmallStepLeafHeight)

blockChallengeHeightBig, err := chalManagerBindings.LAYERZEROBLOCKEDGEHEIGHT(&bind.CallOpts{})
if err != nil {
return nil, fmt.Errorf("could not get block challenge height: %w", err)
}
if !blockChallengeHeightBig.IsUint64() {
return nil, errors.New("block challenge height was not a uint64")
}
bigStepHeightBig, err := chalManagerBindings.LAYERZEROBIGSTEPEDGEHEIGHT(&bind.CallOpts{})
if err != nil {
return nil, fmt.Errorf("could not get big step challenge height: %w", err)
}
if !bigStepHeightBig.IsUint64() {
return nil, errors.New("big step challenge height was not a uint64")
}
smallStepHeightBig, err := chalManagerBindings.LAYERZEROSMALLSTEPEDGEHEIGHT(&bind.CallOpts{})
if err != nil {
return nil, fmt.Errorf("could not get small step challenge height: %w", err)
}
if !smallStepHeightBig.IsUint64() {
return nil, errors.New("small step challenge height was not a uint64")
}
numBigSteps, err := chalManagerBindings.NUMBIGSTEPLEVEL(&bind.CallOpts{})
if err != nil {
return nil, fmt.Errorf("could not get number of big steps: %w", err)
}
blockChallengeLeafHeight := l2stateprovider.Height(blockChallengeHeightBig.Uint64())
bigStepHeight := l2stateprovider.Height(bigStepHeightBig.Uint64())
smallStepHeight := l2stateprovider.Height(smallStepHeightBig.Uint64())

// Sets up the state provider interface that BOLD will use to request data such as
// execution states for assertions, history commitments for machine execution, and one step proofs.
Expand All @@ -389,7 +419,7 @@ func newBOLDChallengeManager(
return nil, fmt.Errorf("could not create state manager: %w", err)
}
providerHeights := []l2stateprovider.Height{blockChallengeLeafHeight}
for i := uint64(0); i < config.NumBigSteps; i++ {
for i := uint8(0); i < numBigSteps; i++ {
providerHeights = append(providerHeights, bigStepHeight)
}
providerHeights = append(providerHeights, smallStepHeight)
Expand All @@ -410,7 +440,7 @@ func newBOLDChallengeManager(

stackOpts := []challengemanager.StackOpt{
challengemanager.StackWithName(config.StateProviderConfig.ValidatorName),
challengemanager.StackWithMode(BoldModes[config.Mode]),
challengemanager.StackWithMode(BoldModes[config.strategy]),
challengemanager.StackWithPollingInterval(scanningInterval),
challengemanager.StackWithPostingInterval(postingInterval),
challengemanager.StackWithConfirmationInterval(confirmingInterval),
Expand Down Expand Up @@ -453,7 +483,6 @@ func readBoldAssertionCreationInfo(
return nil, errors.New("rollup deployment block was not a uint64")
}
creationBlock = rollupDeploymentBlock.Uint64()
topics = [][]common.Hash{{assertionCreatedId}}
} else {
var b [32]byte
copy(b[:], assertionHash[:])
Expand All @@ -462,8 +491,8 @@ func readBoldAssertionCreationInfo(
return nil, err
}
creationBlock = node.CreatedAtBlock
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work for L3s? Is CreatedAtBlock the parent chain block number or the L1 block number?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is set by the rollup contract as block.number when the assertion is created on the parent chain. I presume this will refer to the parent chain block number for L3s

Copy link
Collaborator

@PlasmaPower PlasmaPower Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, unfortunately block.number on arb1 returns the L1 block number not the L2 block number. For the old rollup we had a separate lookup table for this accessible via getNodeCreationBlockForLogLookup. Do we have the same in bold?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we'll have to change a few places inside of the bold/ folder as well to fix this behavior. Added to tasks here https://linear.app/offchain-labs/issue/NIT-2971/bold-l3-support-is-broken-as-assertioncreatedatblock-points-to-the-l1s. It seems L3 support won't work until we fix it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, since this only blocks L3 support I don't think it needs to block merging

topics = [][]common.Hash{{assertionCreatedId}, {assertionHash}}
}
topics = [][]common.Hash{{assertionCreatedId}, {assertionHash}}
var query = ethereum.FilterQuery{
FromBlock: new(big.Int).SetUint64(creationBlock),
ToBlock: new(big.Int).SetUint64(creationBlock),
Expand Down
26 changes: 15 additions & 11 deletions staker/bold/bold_state_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ func NewBOLDStateProvider(
// assertion. Returns the state at maxSeqInboxCount or blockChallengeLeafHeight
// after the previous state, whichever is earlier. If previousGlobalState is
// nil, defaults to returning the state at maxSeqInboxCount.
//
// TODO: Check the block validator has validated the execution state we are
// proposing.
func (s *BOLDStateProvider) ExecutionStateAfterPreviousState(
ctx context.Context,
maxSeqInboxCount uint64,
Expand Down Expand Up @@ -373,7 +370,8 @@ func (s *BOLDStateProvider) CollectMachineHashes(
}
// TODO: Enable Redis streams.
wasmModRoot := cfg.AssertionMetadata.WasmModuleRoot
execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input).Await(ctx)
useBoldMachine := true
execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, &useBoldMachine).Await(ctx)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -458,9 +456,6 @@ func ctxWithCheckAlive(ctxIn context.Context, execRun validator.ExecutionRun) (c
// This is to ensure that we do not have the validator froze indefinitely if
// the execution run is no longer alive.
ctx, cancel := context.WithCancel(ctxIn)
// Create a context with cancel, so that we can cancel the check alive routine
// once the calling function returns.
ctxCheckAlive, cancelCheckAlive := context.WithCancel(ctxIn)
go func() {
// Call cancel so that the calling function is canceled if the check alive
// routine fails/returns.
Expand All @@ -469,12 +464,12 @@ func ctxWithCheckAlive(ctxIn context.Context, execRun validator.ExecutionRun) (c
defer ticker.Stop()
for {
select {
case <-ctxCheckAlive.Done():
case <-ctx.Done():
return
case <-ticker.C:
// Create a context with a timeout, so that the check alive routine does
// not run indefinitely.
ctxCheckAliveWithTimeout, cancelCheckAliveWithTimeout := context.WithTimeout(ctxCheckAlive, 5*time.Second)
ctxCheckAliveWithTimeout, cancelCheckAliveWithTimeout := context.WithTimeout(ctx, 5*time.Second)
err := execRun.CheckAlive(ctxCheckAliveWithTimeout)
if err != nil {
executionNodeOfflineGauge.Inc(1)
Expand All @@ -485,7 +480,7 @@ func ctxWithCheckAlive(ctxIn context.Context, execRun validator.ExecutionRun) (c
}
}
}()
return ctx, cancelCheckAlive
return ctx, cancel
}

// CollectProof collects a one-step proof at a message number and OpcodeIndex.
Expand All @@ -507,6 +502,14 @@ func (s *BOLDStateProvider) CollectProof(
if vs.IsSome() {
m := server_arb.NewFinishedMachine(vs.Unwrap())
defer m.Destroy()
log.Info(
"Getting machine OSP from virtual state",
"fromBatch", assertionMetadata.FromState.Batch,
"fromPosInBatch", assertionMetadata.FromState.PosInBatch,
"blockChallengeHeight", blockChallengeHeight,
"messageNum", messageNum,
"machineIndex", machineIndex,
)
return m.ProveNextStep(), nil
rauljordan marked this conversation as resolved.
Show resolved Hide resolved
}
entry, err := s.statelessValidator.CreateReadyValidationEntry(ctx, messageNum)
Expand All @@ -527,7 +530,8 @@ func (s *BOLDStateProvider) CollectProof(
"startState", fmt.Sprintf("%+v", input.StartState),
)
wasmModRoot := assertionMetadata.WasmModuleRoot
execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input).Await(ctx)
useBoldMachine := true
execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, &useBoldMachine).Await(ctx)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions staker/challenge-cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ type Cache struct {

// New cache from a base directory path.
func New(baseDir string) (*Cache, error) {
if _, err := os.Stat(baseDir); err != nil {
//nolint:errcheck
os.MkdirAll(baseDir, os.ModePerm)
if err := os.MkdirAll(baseDir, os.ModePerm); err != nil {
return nil, err
}
// We create a temp directory to write our hashes to first when putting to the cache.
// Once writing succeeds, we rename in an atomic operation to the correct file name
Expand Down
3 changes: 2 additions & 1 deletion staker/legacy/challenge_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ func (m *ChallengeManager) createExecutionBackend(ctx context.Context, step uint
var execRun validator.ExecutionRun
for _, spawner := range m.validator.ExecutionSpawners() {
if validator.SpawnerSupportsModule(spawner, m.wasmModuleRoot) {
execRun, err = spawner.CreateExecutionRun(m.wasmModuleRoot, input).Await(ctx)
useBold := false
execRun, err = spawner.CreateExecutionRun(m.wasmModuleRoot, input, &useBold).Await(ctx)
if err != nil {
return fmt.Errorf("error creating execution backend for msg %v: %w", initialCount, err)
}
Expand Down
Loading
Loading