Skip to content

Commit fd01136

Browse files
authored
[NAT] Pivot to being a test runner (#171)
* Renamed to op-acceptor * Focused on being a test runner
1 parent 08b49e3 commit fd01136

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2757
-2079
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ workflows:
2222
op-ufm/.* run-build-op-ufm true
2323
proxyd/.* run-build-proxyd true
2424
cci-stats/.* run-build-cci-stats true
25-
op-nat/.* run-build-op-nat true
25+
op-acceptor/.* run-build-op-acceptor true
2626
.circleci/.* run-all true
2727
.github/.* run-all true
2828
filters:

.circleci/continue_config.yml

+20-20
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ parameters:
2525
run-build-cci-stats:
2626
type: boolean
2727
default: false
28-
run-build-op-nat:
28+
run-build-op-acceptor:
2929
type: boolean
3030
default: false
3131
run-all:
@@ -96,7 +96,7 @@ jobs:
9696
echo "run-build-pms: << pipeline.parameters.run-build-pms >>"
9797
echo "run-build-op-ufm: << pipeline.parameters.run-build-op-ufm >>"
9898
echo "run-build-proxyd: << pipeline.parameters.run-build-proxyd >>"
99-
echo "run-build-op-nat: << pipeline.parameters.run-build-op-nat >>"
99+
echo "run-build-op-acceptor: << pipeline.parameters.run-build-op-acceptor >>"
100100
echo "run-all: << pipeline.parameters.run-all >>"
101101
echo ""
102102
echo "Pipeline Trigger Information:"
@@ -143,10 +143,10 @@ jobs:
143143
echo "op-ufm tag regex match: false"
144144
fi
145145
146-
if [[ $CURRENT_TAG =~ ^op-nat/v.* ]]; then
147-
echo "op-nat tag regex match: true"
146+
if [[ $CURRENT_TAG =~ ^op-acceptor/v.* ]]; then
147+
echo "op-acceptor tag regex match: true"
148148
else
149-
echo "op-nat tag regex match: false"
149+
echo "op-acceptor tag regex match: false"
150150
fi
151151
152152
docker-build:
@@ -519,35 +519,35 @@ workflows:
519519
docker_name: cci-stats
520520
docker_tags: <<pipeline.git.revision>>,<<pipeline.git.branch>>
521521
docker_context: .
522-
op-nat:
522+
op-acceptor:
523523
when:
524-
or: [<< pipeline.parameters.run-build-op-nat >>, << pipeline.parameters.run-all >>]
524+
or: [<< pipeline.parameters.run-build-op-acceptor >>, << pipeline.parameters.run-all >>]
525525
jobs:
526526
- go-lint:
527-
name: op-nat-lint
528-
module: op-nat
527+
name: op-acceptor-lint
528+
module: op-acceptor
529529
- go-test:
530-
name: op-nat-tests
531-
module: op-nat
530+
name: op-acceptor-tests
531+
module: op-acceptor
532532
- docker-build:
533-
name: op-nat-docker-build
534-
docker_file: op-nat/Dockerfile
535-
docker_name: op-nat
533+
name: op-acceptor-docker-build
534+
docker_file: op-acceptor/Dockerfile
535+
docker_name: op-acceptor
536536
docker_tags: <<pipeline.git.revision>>,<<pipeline.git.branch>>
537537
docker_context: .
538538
release:
539539
jobs:
540540
- log-config-results:
541541
filters:
542542
tags:
543-
only: /^(op-nat|cci-stats|peer-mgmt-service|proxyd|ufm-[a-z0-9\-]*|op-[a-z0-9\-]*)\/v.*/
543+
only: /^(cci-stats|peer-mgmt-service|proxyd|ufm-[a-z0-9\-]*|op-[a-z0-9\-]*)\/v.*/
544544
branches:
545545
ignore: /.*/
546546
- hold:
547547
type: approval
548548
filters:
549549
tags:
550-
only: /^(op-nat|cci-stats|peer-mgmt-service|proxyd|ufm-[a-z0-9\-]*|op-[a-z0-9\-]*)\/v.*/
550+
only: /^(cci-stats|peer-mgmt-service|proxyd|ufm-[a-z0-9\-]*|op-[a-z0-9\-]*)\/v.*/
551551
branches:
552552
ignore: /.*/
553553
- docker-build:
@@ -561,7 +561,7 @@ workflows:
561561
- op-conductor-mon
562562
- peer-mgmt-service
563563
- cci-stats
564-
- op-nat
564+
- op-acceptor
565565
name: <<matrix.docker_name>>-docker-build
566566
filters:
567567
tags:
@@ -584,7 +584,7 @@ workflows:
584584
- op-conductor-mon
585585
- peer-mgmt-service
586586
- cci-stats
587-
- op-nat
587+
- op-acceptor
588588
name: <<matrix.docker_name>>-docker-publish
589589
filters:
590590
tags:
@@ -605,7 +605,7 @@ workflows:
605605
- op-conductor-mon
606606
- peer-mgmt-service
607607
- cci-stats
608-
- op-nat
608+
- op-acceptor
609609
name: <<matrix.docker_name>>-docker-tag
610610
filters:
611611
tags:
@@ -627,7 +627,7 @@ workflows:
627627
- op-conductor-mon
628628
- peer-mgmt-service
629629
- cci-stats
630-
- op-nat
630+
- op-acceptor
631631
name: <<matrix.module>>-go-release
632632
filters:
633633
tags:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
This repository is an extension of the [Optimism monorepo](https://github.com/ethereum-optimism/optimism) and contains the infrastructure that supports the Optimism ecosystem.
44

55
## Components
6+
- op-acceptor: Network Acceptance Tester: A tool that tests the network acceptance of devnets. (See [op-acceptor/README.md](./acceptor/README.md) or [devdocs/pm](https://devdocs.optimism.io/pm/acceptance-testing.html) for more information)
67
- op-conductor-mon: Monitors multiple op-conductor instances and provides a unified interface for reporting metrics.
7-
- op-nat: Network Acceptance Tester: A tool that tests the network acceptance of devnets. (See [op-nat/README.md](./op-nat/README.md) or [devdocs/pm](https://devdocs.optimism.io/pm/acceptance-testing.html) for more information)
88
- op-signer: Thin gateway that supports various RPC endpoints to sign payloads from op-stack components using private key stored in KMS.
99
- op-ufm: User facing monitoring creates transactions at regular intervals and observe transaction propagation across different RPC providers.
1010

File renamed without changes.
File renamed without changes.

op-nat/.goreleaser.yaml op-acceptor/.goreleaser.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
version: 2
55

6-
project_name: op-nat
6+
project_name: op-acceptor
77

88
before:
99
hooks:
@@ -13,7 +13,7 @@ before:
1313
builds:
1414
- id: main
1515
main: ./cmd/main
16-
binary: bin/op-nat
16+
binary: bin/op-acceptor
1717
env:
1818
- CGO_ENABLED=0
1919
goos:
@@ -54,5 +54,5 @@ release:
5454
make_latest: false
5555

5656
monorepo:
57-
tag_prefix: op-nat/
58-
dir: op-nat
57+
tag_prefix: op-acceptor/
58+
dir: op-acceptor

op-nat/Dockerfile op-acceptor/Dockerfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ WORKDIR /app
55
# Install dependencies first for better caching
66
RUN apk add --no-cache just
77

8-
COPY op-nat/ .
8+
COPY op-acceptor/ .
99

1010
RUN just build
1111

@@ -16,8 +16,9 @@ RUN addgroup -S app && adduser -S app -G app && \
1616
mkdir -p /devnets && \
1717
chown -R app:app /devnets
1818

19-
COPY --from=builder /app/bin/op-nat /app/
19+
COPY --from=builder /app/bin/op-acceptor /app/
20+
COPY op-acceptor/example-validators.yaml /app/
2021
USER app
2122

2223
VOLUME /devnets
23-
ENTRYPOINT ["/app/op-nat"]
24+
ENTRYPOINT ["/app/op-acceptor"]

op-nat/Makefile op-acceptor/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ LDFLAGS := -ldflags "$(LDFLAGSSTRING)"
1010
all: build
1111

1212
build:
13-
go build -v $(LDFLAGS) -o ./bin/op-nat ./cmd
13+
go build -v $(LDFLAGS) -o ./bin/op-acceptor ./cmd
1414

1515
clean:
16-
rm ./bin/op-nat
16+
rm ./bin/op-acceptor
1717

1818
test:
1919
go test -v ./...

op-acceptor/README.md

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Network Acceptance Tester (op-acceptor)
2+
op-acceptor is a tool to run checks against a network to determine if it is ready for production. It helps ensure your network meets all necessary requirements before deployment.
3+
The checks it runs are standard Go tests.
4+
5+
## Concepts
6+
7+
### Test Discovery
8+
op-acceptor discovers tests. You simply need to provide a path to a directory containing your tests. op-acceptor will discover all tests within that directory and also those within any subdirectories.
9+
10+
### Test Grouping
11+
1. **Test** - An individual check that validates a specific aspect of your network
12+
2. **Suite** - A logical grouping of related tests
13+
3. **Gate** - A high-level collection of suites and/or tests that represent a complete validation scenario
14+
15+
16+
## Contributing
17+
18+
Please note that this project is under active development and the API may evolve. We welcome all contributions and appreciate your interest in improving op-acceptor!
19+
20+
### Adding a new test/suite/gate
21+
All tests, suites, and gates are defined in a `validators.yaml` file. The filename is not important.
22+
For an example `validators.yaml`, see [example-validators.yaml](./example-validators.yaml).
23+
24+
**Gate**
25+
A gate is a collection of suites and/or tests that represent a complete validation scenario. A gate can inherit from one or more other gates.
26+
27+
```yaml
28+
# Example gate definition
29+
- id: alphanet
30+
description: "Alphanet validation gate"
31+
inherits: ["localnet"]
32+
suites:
33+
- id: interop
34+
description: "Interop suite"
35+
tests:
36+
- id: TestInteropSystem
37+
```
38+
39+
**Suite**
40+
A suite is a collection of tests that validate a specific aspect of your network. It's a convenience mechanism for grouping tests together.
41+
42+
```yaml
43+
# Example suite definition
44+
- id: interop
45+
description: "Interop suite"
46+
tests:
47+
- id: TestInteropSystem
48+
```
49+
50+
**Test**
51+
A test is a single check that validates a specific aspect of your network.
52+
A description is optional.
53+
A package is optional. If not provided, the test will be searched for. This lengthens the runtime, so we recommend providing the package.
54+
If a package is provided and no name is provided, op-acceptor runs all tests in the package.
55+
56+
```yaml
57+
# Run test 'TestInteropSystem' in package 'github.com/ethereum-optimism/optimism/kurtosis-devnet/tests/interop'
58+
- name: TestInteropSystem
59+
description: "Test the interop system"
60+
package: github.com/ethereum-optimism/optimism/kurtosis-devnet/tests/interop
61+
```
62+
63+
```yaml
64+
# Run all tests in package 'github.com/ethereum-optimism/optimism/kurtosis-devnet/tests/interop'
65+
- package: github.com/ethereum-optimism/optimism/kurtosis-devnet/tests/interop
66+
```
67+
68+
## Development
69+
70+
### Prerequisites
71+
* [Go](https://go.dev/dl/) 1.22+
72+
* [Just](https://just.systems/)
73+
74+
### Getting Started
75+
Build the binary:
76+
```bash
77+
just build
78+
```
79+
80+
Run tests:
81+
```bash
82+
just test
83+
```
84+
85+
Run op-acceptor:
86+
```bash
87+
DEVNET_ENV_URL=devnets/alpaca-devnet.json # path to the devnet manifest
88+
go run cmd/main.go \
89+
--gate betanet \ # The gate to run
90+
--testdir ../../optimism/ \ # Path to the directory containing your tests
91+
--validators validators.yaml \ # Path to the validator definitions
92+
```
93+
94+
Want to monitor your validation runs? Start our local monitoring stack:
95+
```bash
96+
just start-monitoring # Launches Prometheus and Grafana alongside op-acceptor
97+
```
98+
99+
### Future Development
100+
We track our public roadmap and issues on [Github](https://github.com/ethereum-optimism/infra/issues). Feel free to:
101+
* Submit bug reports
102+
* Propose new features
103+
* Contribute improvements
104+
* Join discussions
105+
106+
Your feedback and contributions help make op-acceptor better for everyone!

op-nat/cmd/main.go op-acceptor/cmd/main.go

+17-16
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,27 @@ import (
88
"github.com/ethereum/go-ethereum/log"
99
"github.com/urfave/cli/v2"
1010

11-
nat "github.com/ethereum-optimism/infra/op-nat"
12-
"github.com/ethereum-optimism/infra/op-nat/flags"
13-
"github.com/ethereum-optimism/infra/op-nat/service"
14-
"github.com/ethereum-optimism/infra/op-nat/validators/gates"
11+
nat "github.com/ethereum-optimism/infra/op-acceptor"
12+
"github.com/ethereum-optimism/infra/op-acceptor/flags"
13+
"github.com/ethereum-optimism/infra/op-acceptor/service"
1514
"github.com/ethereum-optimism/optimism/op-service/cliapp"
1615
"github.com/ethereum-optimism/optimism/op-service/ctxinterrupt"
1716
oplog "github.com/ethereum-optimism/optimism/op-service/log"
1817
)
1918

2019
var (
21-
Version = "v0.0.1"
20+
Version = "v0.1.0"
2221
GitCommit = ""
2322
GitDate = ""
2423
)
2524

2625
func main() {
2726
app := cli.NewApp()
28-
app.Flags = cliapp.ProtectFlags(flags.Flags)
2927
app.Version = fmt.Sprintf("%s-%s-%s", Version, GitCommit, GitDate)
30-
app.Name = "op-nat"
28+
app.Name = "op-acceptor"
3129
app.Usage = "Optimism Network Acceptance Tester Service"
32-
app.Description = "op-nat tests networks"
30+
app.Description = "op-acceptor tests networks"
31+
app.Flags = cliapp.ProtectFlags(flags.Flags)
3332
app.Action = cliapp.LifecycleCmd(run)
3433

3534
// Start server
@@ -51,22 +50,24 @@ func run(ctx *cli.Context, closeApp context.CancelCauseFunc) (cliapp.Lifecycle,
5150
oplog.SetGlobalLogHandler(log.Handler())
5251
oplog.SetupDefaults()
5352

54-
// TODO: map validators from flags
55-
var validators = []nat.Validator{
56-
gates.Alphanet,
57-
}
58-
59-
cfg, err := nat.NewConfig(ctx, log, validators)
53+
// Initialize the service with both paths
54+
cfg, err := nat.NewConfig(
55+
ctx,
56+
log,
57+
ctx.String(flags.TestDir.Name),
58+
ctx.String(flags.ValidatorConfig.Name),
59+
ctx.String(flags.Gate.Name),
60+
)
6061
if err != nil {
6162
return nil, fmt.Errorf("failed to create config: %w", err)
6263
}
6364

6465
cfg.Log.Debug("Config", "config", cfg)
6566

66-
c, err := nat.New(ctx.Context, cfg, Version)
67+
natService, err := nat.New(ctx.Context, cfg, Version)
6768
if err != nil {
6869
return nil, fmt.Errorf("failed to create nat: %w", err)
6970
}
7071

71-
return c, nil
72+
return natService, nil
7273
}

0 commit comments

Comments
 (0)