Skip to content

Commit ca0b9eb

Browse files
committed
fix: ID-genesis.json -> ID-genesis-l2.json
1 parent 3139854 commit ca0b9eb

File tree

3 files changed

+68
-5
lines changed

3 files changed

+68
-5
lines changed

kurtosis-devnet/op-program-svc/README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
# Trigger new build:
1+
# op-program-svc
2+
3+
This small service is a temporary measure until we come up with a better way
4+
of generating/serving prestate files based on chain information.
5+
6+
# API
7+
8+
The API is intentionally extremely simple:
9+
- `POST /`: generate new prestates from provided inputs
10+
- `GET /HASH.(bin.gz|json)`: get prestate data
11+
- `GET /info.json`: get prestates mapping
12+
13+
The idea is for this service to be basically a function
14+
(chains_specs, deptsets) -> prestates.
15+
16+
In the future, we definitely want to replace the implementation of that
17+
function (see implementation notes below)
18+
19+
## Trigger new build:
20+
21+
Example using curl
222

323
```
424
$ curl -X POST -H "Content-Type: multipart/form-data" \
@@ -9,3 +29,30 @@ $ curl -X POST -H "Content-Type: multipart/form-data" \
929
-F "files[][email protected]" \
1030
http://localhost:8080
1131
```
32+
33+
## Retrieve prestates mapping
34+
35+
```
36+
$ curl -q http://localhost:8080/info.json
37+
{
38+
"prestate": "0x03f4b7435fec731578c72635d8e8180f7b48703073d038fc7f8c494eeed1ce19",
39+
"prestate_interop": "0x034731331d519c93fc0562643e0728c43f8e45a0af1160ad4c57c4e5141d2bbb",
40+
"prestate_mt64": "0x0325bb0ca8521b468bb8234d8ba54b1b74db60e2b5bc75d0077a0fe2098b6b45"
41+
}
42+
```
43+
44+
## Implementation notes
45+
46+
Unfortunately, op-program-client relies on embedded (using `//go:embed`)
47+
configuration files to store unannounced chain configs.
48+
49+
This means that in the context of devnets, we need to store the configs
50+
(which are available only mid-deployment) into the **source tree** and
51+
trigger a late build step.
52+
53+
So effectively, we need to package the relevant part of the sources into
54+
a container, deploy that one alongside the devnet, and run that build step
55+
on demand.
56+
57+
This is ugly, unsafe, easy to run a DOS against,... we need to do better.
58+
But for now this is what we have.

kurtosis-devnet/op-program-svc/build.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ func (b *Builder) ExecuteBuild() ([]byte, error) {
147147
return output.Bytes(), nil
148148
}
149149

150+
// This is a convenience hack to natively support the file format of op-deployer
150151
func (b *Builder) normalizeFilename(filename string) string {
151152
// Get just the filename without directories
152153
filename = filepath.Base(filename)
@@ -156,8 +157,13 @@ func (b *Builder) normalizeFilename(filename string) string {
156157
if numStr := strings.TrimSuffix(parts[1], ".json"); numStr != parts[1] {
157158
// Check if the number part is actually numeric
158159
if _, err := strconv.Atoi(numStr); err == nil {
159-
// It matches the pattern and has a valid number, reorder to NUMBER-PREFIX.json
160-
return numStr + "-" + parts[0] + ".json"
160+
// Handle specific cases
161+
if parts[0] == "genesis" {
162+
return numStr + "-" + parts[0] + "-l2.json"
163+
} else if parts[0] == "rollup" {
164+
return numStr + "-" + "rollup.json"
165+
}
166+
// For all other cases, leave the filename unchanged
161167
}
162168
}
163169
}

kurtosis-devnet/op-program-svc/build_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,19 @@ func TestNormalizeFilename(t *testing.T) {
167167
expected string
168168
}{
169169
{
170-
name: "standard format",
170+
name: "standard format - unchanged",
171171
input: "prefix-123.json",
172-
expected: "123-prefix.json",
172+
expected: "prefix-123.json",
173+
},
174+
{
175+
name: "genesis format",
176+
input: "genesis-123.json",
177+
expected: "123-genesis-l2.json",
178+
},
179+
{
180+
name: "rollup format",
181+
input: "rollup-456.json",
182+
expected: "456-rollup.json",
173183
},
174184
{
175185
name: "no number",

0 commit comments

Comments
 (0)