Skip to content

Commit

Permalink
Merge pull request #1902 from OffchainLabs/protocol-system-test
Browse files Browse the repository at this point in the history
Add BOLD System Test That Successfully Completes a Challenge
  • Loading branch information
rauljordan authored Oct 12, 2023
2 parents 73f498d + 726983e commit d0472ef
Show file tree
Hide file tree
Showing 18 changed files with 1,429 additions and 1,058 deletions.
2 changes: 1 addition & 1 deletion bold
Submodule bold updated 50 files
+1 −1 assertions/BUILD.bazel
+27 −37 assertions/poster.go
+123 −24 assertions/poster_test.go
+73 −26 assertions/scanner.go
+5 −5 assertions/scanner_test.go
+10 −0 chain-abstraction/interfaces.go
+1 −0 chain-abstraction/sol-implementation/BUILD.bazel
+12 −0 chain-abstraction/sol-implementation/assertion_chain.go
+4 −2 chain-abstraction/sol-implementation/assertion_chain_test.go
+31 −1 chain-abstraction/sol-implementation/edge_challenge_manager.go
+64 −23 chain-abstraction/sol-implementation/edge_challenge_manager_test.go
+3 −0 challenge-manager/BUILD.bazel
+19 −2 challenge-manager/chain-watcher/watcher.go
+4 −2 challenge-manager/chain-watcher/watcher_test.go
+1 −0 challenge-manager/challenge-tree/BUILD.bazel
+4 −2 challenge-manager/challenge-tree/ancestors_test.go
+2 −4 challenge-manager/challenge-tree/local_timer.go
+4 −0 challenge-manager/challenge-tree/mock/edge.go
+58 −21 challenge-manager/challenge-tree/tree.go
+37 −15 challenge-manager/challenge-tree/tree_test.go
+24 −23 challenge-manager/challenges.go
+122 −99 challenge-manager/edge-tracker/tracker.go
+72 −66 challenge-manager/manager.go
+80 −28 challenge-manager/manager_test.go
+1 −0 containers/threadsafe/BUILD.bazel
+14 −1 containers/threadsafe/slice.go
+1 −1 contracts/package.json
+1 −1 contracts/scripts/boldUpgradeFunctions.ts
+2 −2 contracts/scripts/files/localConfig.json
+1 −1 contracts/scripts/files/localNetwork.json
+14 −5 contracts/src/challengeV2/EdgeChallengeManager.sol
+2 −0 contracts/src/challengeV2/libraries/ChallengeErrors.sol
+12 −29 contracts/src/challengeV2/libraries/EdgeChallengeManagerLib.sol
+209 −66 contracts/test/challengeV2/ChallengeEdgeLib.t.sol
+211 −1 contracts/test/challengeV2/EdgeChallengeManager.t.sol
+790 −243 contracts/test/challengeV2/EdgeChallengeManagerLib.t.sol
+21 −8 layer2-state-provider/history_commitment_provider.go
+9 −5 layer2-state-provider/provider.go
+2 −2 solgen/go/assertionStakingPoolgen/assertionStakingPoolgen.go
+1 −1 solgen/go/bridgegen/bridgegen.go
+65 −3 solgen/go/challengeV2gen/challengeV2gen.go
+2 −2 solgen/go/mocksgen/mocksgen.go
+9 −9 solgen/go/rollupgen/rollupgen.go
+18 −9 state-commitments/prefix-proofs/prefix_proofs_test.go
+5 −6 testing/endtoend/basic_local_test.go
+22 −5 testing/mocks/mocks.go
+4 −2 testing/mocks/state-provider/history_provider.go
+12 −6 testing/mocks/state-provider/history_provider_test.go
+15 −15 testing/mocks/state-provider/layer2_state_provider.go
+2 −2 testing/setup/rollup_stack.go
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ require (
github.com/openzipkin/zipkin-go v0.4.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polydawn/refmt v0.89.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
Expand All @@ -240,6 +241,8 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/samber/lo v1.36.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
Expand Down Expand Up @@ -276,6 +279,7 @@ require (
google.golang.org/grpc v1.53.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
nhooyr.io/websocket v1.8.7 // indirect
)
Expand All @@ -302,7 +306,7 @@ require (
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.2
github.com/huin/goupnp v1.1.0 // indirect
Expand Down
15 changes: 13 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoG
github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811/go.mod h1:Nb5lgvnQ2+oGlE/EyZy4+2/CxRh9KfvCXnag1vtpxVM=
github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ=
github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/codeclysm/extract/v3 v3.0.2 h1:sB4LcE3Php7LkhZwN0n2p8GCwZe92PEQutdbGURf5xc=
github.com/codeclysm/extract/v3 v3.0.2/go.mod h1:NKsw+hqua9H+Rlwy/w/3Qgt9jDonYEgB6wJu+25eOKw=
Expand Down Expand Up @@ -263,6 +264,7 @@ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6Uh
github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI=
github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
Expand Down Expand Up @@ -378,6 +380,7 @@ github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand Down Expand Up @@ -595,8 +598,10 @@ github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs=
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru/v2 v2.0.1 h1:5pv5N1lT1fjLg2VQ5KWc7kmucp2x/kvFOnxuVTqZ6x4=
github.com/hashicorp/golang-lru/v2 v2.0.1/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hashicorp/golang-lru/v2 v2.0.2 h1:Dwmkdr5Nc/oBiXgJS3CDHNhJtIHkuZ3DZF5twqnfBdU=
github.com/hashicorp/golang-lru/v2 v2.0.2/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
Expand Down Expand Up @@ -868,6 +873,7 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
Expand Down Expand Up @@ -1242,6 +1248,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ=
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
Expand Down Expand Up @@ -1383,6 +1390,7 @@ github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAv
github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9 h1:1/WtZae0yGtPq+TI6+Tv1WTxkukpXeMlviSxvL7SRgk=
github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9/go.mod h1:x3N5drFsm2uilKKuuYo6LdyD8vZAW55sH/9w+pbo1sw=
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
Expand Down Expand Up @@ -1565,6 +1573,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
Expand Down Expand Up @@ -1618,6 +1628,7 @@ github.com/wealdtech/go-merkletree v1.0.0/go.mod h1:cdil512d/8ZC7Kx3bfrDvGMQXB25
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc h1:BCPnHtcboadS0DvysUuJXZ4lWVv5Bh5i7+tbIyi+ck4=
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc/go.mod h1:r45hJU7yEoA81k6MWNhpMj/kms0n14dkzkxYHoB96UM=
github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 h1:5HZfQkwe0mIfyDmc1Em5GqlNRzcdtlv4HTNmdpt7XH0=
github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11/go.mod h1:Wlo/SzPmxVp6vXpGt/zaXhHH0fn4IxgqZc82aKg6bpQ=
github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI=
github.com/whyrusleeping/cbor-gen v0.0.0-20230126041949-52956bd4c9aa h1:EyA027ZAkuaCLoxVX4r1TZMPy1d31fM6hbfQ4OU4I5o=
github.com/whyrusleeping/cbor-gen v0.0.0-20230126041949-52956bd4c9aa/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
Expand Down
48 changes: 28 additions & 20 deletions staker/challenge-cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ Use cases:
wavm-module-root-0xab/
message-num-70/
roots.txt
big-step-100/
subchallenge-level-0-big-step-100/
roots.txt
subchallenge-level-1-big-step-100/
roots.txt
We namespace top-level block challenges by wavm module root. Then, we can retrieve
the state roots for any data within a challenge or associated subchallenge based on the hierarchy above.
Expand All @@ -36,7 +38,7 @@ import (
"path/filepath"

protocol "github.com/OffchainLabs/bold/chain-abstraction"
"github.com/OffchainLabs/bold/containers/option"
l2stateprovider "github.com/OffchainLabs/bold/layer2-state-provider"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
)
Expand All @@ -49,11 +51,13 @@ var (
wavmModuleRootPrefix = "wavm-module-root"
messageNumberPrefix = "message-num"
bigStepPrefix = "big-step"
challengeLevelPrefix = "subchallenge-level"
srvlog = log.New("service", "bold-history-commit-cache")
)

// HistoryCommitmentCacher can retrieve history commitment state roots given lookup keys.
type HistoryCommitmentCacher interface {
Get(lookup *Key, readUpTo protocol.Height) ([]common.Hash, error)
Get(lookup *Key, numToRead uint64) ([]common.Hash, error)
Put(lookup *Key, stateRoots []common.Hash) error
}

Expand All @@ -74,23 +78,25 @@ func New(baseDir string) *Cache {
type Key struct {
WavmModuleRoot common.Hash
MessageHeight protocol.Height
BigStepHeight option.Option[protocol.Height]
StepHeights []l2stateprovider.Height
}

// Get a list of state roots from the cache up to a certain index. State roots are saved as files in the directory
// hierarchy for the cache. If a file is not present, ErrNotFoundInCache
// is returned.
func (c *Cache) Get(
lookup *Key,
readUpTo protocol.Height,
numToRead uint64,
) ([]common.Hash, error) {
fName, err := determineFilePath(c.baseDir, lookup)
if err != nil {
return nil, err
}
if _, err := os.Stat(fName); err != nil {
srvlog.Warn("Cache miss", log.Ctx{"fileName": fName})
return nil, ErrNotFoundInCache
}
srvlog.Debug("Cache hit", log.Ctx{"fileName": fName})
f, err := os.Open(fName)
if err != nil {
return nil, err
Expand All @@ -100,7 +106,7 @@ func (c *Cache) Get(
log.Error("Could not close file after reading", "err", err, "file", fName)
}
}()
return readStateRoots(f, readUpTo)
return readStateRoots(f, numToRead)
}

// Put a list of state roots into the cache.
Expand Down Expand Up @@ -149,12 +155,11 @@ func (c *Cache) Put(lookup *Key, stateRoots []common.Hash) error {
}

// Reads 32 bytes at a time from a reader up to a specified height. If none, then read all.
func readStateRoots(r io.Reader, readUpTo protocol.Height) ([]common.Hash, error) {
func readStateRoots(r io.Reader, numToRead uint64) ([]common.Hash, error) {
br := bufio.NewReader(r)
stateRoots := make([]common.Hash, 0)
buf := make([]byte, 0, 32)
totalRead := uint64(0)
for {
for totalRead := uint64(0); totalRead < numToRead; totalRead++ {
n, err := br.Read(buf[:cap(buf)])
if err != nil {
// If we try to read but reach EOF, we break out of the loop.
Expand All @@ -168,15 +173,11 @@ func readStateRoots(r io.Reader, readUpTo protocol.Height) ([]common.Hash, error
return nil, fmt.Errorf("expected to read 32 bytes, got %d bytes", n)
}
stateRoots = append(stateRoots, common.BytesToHash(buf))
if totalRead >= uint64(readUpTo) {
return stateRoots, nil
}
totalRead++
}
if readUpTo >= protocol.Height(len(stateRoots)) {
if protocol.Height(numToRead) > protocol.Height(len(stateRoots)) {
return nil, fmt.Errorf(
"wanted to read up to %d, but only read %d state roots",
readUpTo,
"wanted to read %d roots, but only read %d state roots",
numToRead,
len(stateRoots),
)
}
Expand Down Expand Up @@ -210,16 +211,23 @@ for a given filesystem challenge cache will look as follows:
wavm-module-root-0xab/
message-num-70/
roots.txt
big-step-100/
subchallenge-level-0-big-step-100/
roots.txt
*/
func determineFilePath(baseDir string, lookup *Key) (string, error) {
key := make([]string, 0)
key = append(key, fmt.Sprintf("%s-%s", wavmModuleRootPrefix, lookup.WavmModuleRoot.Hex()))
key = append(key, fmt.Sprintf("%s-%d", messageNumberPrefix, lookup.MessageHeight))
if !lookup.BigStepHeight.IsNone() {
bigStepHeight := lookup.BigStepHeight.Unwrap()
key = append(key, fmt.Sprintf("%s-%d", bigStepPrefix, bigStepHeight))
for challengeLevel, height := range lookup.StepHeights {
key = append(key, fmt.Sprintf(
"%s-%d-%s-%d",
challengeLevelPrefix,
challengeLevel+1, // subchallenges start at 1, as level 0 is the block challenge level.
bigStepPrefix,
height,
),
)

}
key = append(key, stateRootsFileName)
return filepath.Join(baseDir, filepath.Join(key...)), nil
Expand Down
Loading

0 comments on commit d0472ef

Please sign in to comment.