Skip to content

Commit eec4ed7

Browse files
committed
Merge branch 'feat/zkvm-v0.9.0-openvm2' into shadow-test-ai
OpenVM v2 / guest v0.9.0 upgrade (PR #1816): workspace v4.8.0, child_circuit_vks config, agg_vk.bin mandatory, dead feynman/galileo paths removed. # Conflicts: # AGENTS.md # common/types/message/message.go # coordinator/internal/logic/provertask/batch_prover_task.go # coordinator/internal/logic/provertask/bundle_prover_task.go # crates/libzkp/src/lib.rs # crates/libzkp/src/verifier/universal.rs # crates/prover-bin/src/deferral.rs # crates/prover-bin/src/prover.rs # crates/prover-bin/src/zk_circuits_handler/universal.rs # tests/prover-e2e/cloak-galileoV2/.make.env # tests/prover-e2e/docker-e2e/conf/prover.json # tests/prover-e2e/mainnet-galileoV2/.make.env # zkvm-prover/config.json.template
2 parents eb9c292 + 8cc4b0d commit eec4ed7

61 files changed

Lines changed: 1315 additions & 230 deletions

Some content is hidden

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

‎.github/workflows/common.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
steps:
3030
- uses: actions-rs/toolchain@v1
3131
with:
32-
toolchain: nightly-2025-08-18
32+
toolchain: nightly-2025-11-20
3333
override: true
3434
components: rustfmt, clippy
3535
- name: Install Go

‎.github/workflows/coordinator.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
steps:
3434
- uses: actions-rs/toolchain@v1
3535
with:
36-
toolchain: nightly-2025-08-18
36+
toolchain: nightly-2025-11-20
3737
override: true
3838
components: rustfmt, clippy
3939
- name: Install Go

‎AGENTS.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ All local-development secrets are in [`local-secrets.md`](local-secrets.md) (git
8282
|----------|--------|
8383
| [`docs/prover-coordinator-overview.md`](docs/prover-coordinator-overview.md) | Architecture, data flow, common operations |
8484
| [`docs/testing/openvm-upgrade-testing-guide.md`](docs/testing/openvm-upgrade-testing-guide.md) | Five-level upgrade verification ladder |
85+
| [`docs/testing/docker-compose-e2e-guide.md`](docs/testing/docker-compose-e2e-guide.md) | Production-like E2E testing with Docker Compose + Coordinator Proxy |
8586
| [`tests/shadow-testing/README.md`](tests/shadow-testing/README.md) | Mode chooser + documentation conventions |
8687
| [`tests/shadow-testing/docs/TROUBLESHOOTING.md`](tests/shadow-testing/docs/TROUBLESHOOTING.md) | **Trap index** (all 56 traps → per-file locations) |
8788
| [`tests/shadow-testing/docs/COMMON-TROUBLESHOOTING.md`](tests/shadow-testing/docs/COMMON-TROUBLESHOOTING.md) | Mode-independent traps, pre-flight ritual, checklists, symptom table |
@@ -90,4 +91,4 @@ All local-development secrets are in [`local-secrets.md`](local-secrets.md) (git
9091
| [`tests/shadow-testing/docs/rds-query-rules.md`](tests/shadow-testing/docs/rds-query-rules.md) | Production RDS query discipline |
9192
| [`docs/testing/single-chunk-reproving.md`](docs/testing/single-chunk-reproving.md) | Re-proving one mainnet chunk |
9293
| [`docs/openvm-v2-deployment-notes.md`](docs/openvm-v2-deployment-notes.md) | **v0.9.0 production deployment runbook**: repo/PR map, S3 layout facts, prover/coordinator config changes, image-build caveats, sequencing, rollback |
93-
| `docs/testing_reports/*.md` | Dated test reports: [canary 2026-09-11](docs/testing_reports/canary-parallel-upgrade-2026-09-11.md) · [canary docker 2026-08-31](docs/testing_reports/canary-parallel-upgrade-docker-2026-08-31.md) · [canary 2026-08-25](docs/testing_reports/canary-parallel-upgrade-2026-08-25.md) · [snapshot early experiments](docs/testing_reports/snapshot-early-dryrun-and-relayer-tests.md) · [OpenVM 1.6.0 / guest v0.8.0](docs/testing_reports/openvm-v1.6.0-guest-v0.8.0-May19.md) |
94+
| `docs/testing_reports/*.md` | Dated test reports: [canary 2026-09-11](docs/testing_reports/canary-parallel-upgrade-2026-09-11.md) · [canary docker 2026-08-31](docs/testing_reports/canary-parallel-upgrade-docker-2026-08-31.md) · [canary 2026-08-25](docs/testing_reports/canary-parallel-upgrade-2026-08-25.md) · [snapshot early experiments](docs/testing_reports/snapshot-early-dryrun-and-relayer-tests.md) · [OpenVM 1.6.0 / guest v0.8.0](docs/testing_reports/openvm-v1.6.0-guest-v0.8.0-May19.md) · [OpenVM v2.0 / guest v0.9.0](docs/testing_reports/openvm-v2.0.0-guest-v0.9.0-Sep15.md) |

‎Cargo.lock‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ edition = "2021"
1414
homepage = "https://scroll.io"
1515
readme = "README.md"
1616
repository = "https://github.com/scroll-tech/scroll"
17-
version = "4.7.12"
17+
version = "4.8.0"
1818

1919
[workspace.dependencies]
2020
scroll-zkvm-prover = { git = "https://github.com/scroll-tech/zkvm-prover", rev = "bf887150bb671af9b17dd53e92b7f2bbf01ec745" }

‎common/database/config.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@ type Config struct {
88

99
MaxOpenNum int `json:"maxOpenNum"`
1010
MaxIdleNum int `json:"maxIdleNum"`
11+
12+
// UseIAMAuth authenticates to AWS RDS/Aurora with short-lived IAM tokens
13+
// instead of a DSN password. The DSN should omit the password and enable TLS.
14+
UseIAMAuth bool `json:"useIAMAuth"`
15+
// AWSRegion signs the IAM tokens. Optional; falls back to the default AWS
16+
// config chain (e.g. AWS_REGION) when empty.
17+
AWSRegion string `json:"awsRegion"`
1118
}

‎common/database/db.go‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ func InitDB(config *Config) (*gorm.DB, error) {
5050
gethLogger: log.Root(),
5151
}
5252

53-
db, err := gorm.Open(postgres.Open(config.DSN), &gorm.Config{
53+
dialector, err := newDialector(config)
54+
if err != nil {
55+
return nil, err
56+
}
57+
58+
db, err := gorm.Open(dialector, &gorm.Config{
5459
CreateBatchSize: 1000,
5560
Logger: &tmpGormLogger,
5661
NowFunc: func() time.Time {
@@ -80,6 +85,22 @@ func InitDB(config *Config) (*gorm.DB, error) {
8085
return db, nil
8186
}
8287

88+
// newDialector builds the gorm postgres dialector. With IAM auth it wraps a
89+
// token-refreshing connector in a *sql.DB; otherwise it opens the DSN directly.
90+
func newDialector(config *Config) (gorm.Dialector, error) {
91+
if !config.UseIAMAuth {
92+
log.Info("connecting to database with password auth")
93+
return postgres.Open(config.DSN), nil
94+
}
95+
96+
log.Info("connecting to database with AWS RDS IAM auth", "region", config.AWSRegion)
97+
connector, err := NewRDSIAMConnector(context.Background(), config.DSN, config.AWSRegion)
98+
if err != nil {
99+
return nil, err
100+
}
101+
return postgres.New(postgres.Config{Conn: sql.OpenDB(connector)}), nil
102+
}
103+
83104
// CloseDB close the db handler. notice the db handler only can close when then program exit.
84105
func CloseDB(db *gorm.DB) error {
85106
sqlDB, err := db.DB()

‎common/database/iam.go‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package database
2+
3+
import (
4+
"context"
5+
"database/sql/driver"
6+
"fmt"
7+
"net"
8+
"strconv"
9+
"time"
10+
11+
"github.com/aws/aws-sdk-go-v2/aws"
12+
awsconfig "github.com/aws/aws-sdk-go-v2/config"
13+
"github.com/aws/aws-sdk-go-v2/feature/rds/auth"
14+
"github.com/jackc/pgx/v5"
15+
"github.com/jackc/pgx/v5/stdlib"
16+
)
17+
18+
// rdsIAMConnector is a driver.Connector that mints a fresh AWS RDS IAM auth
19+
// token for every new connection (tokens expire after 15 minutes; already-open
20+
// connections keep working since the token is only checked at connect time).
21+
type rdsIAMConnector struct {
22+
base *pgx.ConnConfig // parsed DSN; Password is set to the token per-connect
23+
endpoint string // host:port the token is signed for
24+
region string // AWS region the token is signed for
25+
creds aws.CredentialsProvider // refreshes credentials internally
26+
metrics *rdsIAMMetrics
27+
}
28+
29+
// NewRDSIAMConnector returns a connector that injects a fresh RDS IAM token as
30+
// the password on each new connection. region falls back to the default AWS
31+
// config chain (e.g. AWS_REGION) when empty.
32+
//
33+
// IAM auth requires TLS, so a DSN with sslmode=disable is rejected rather than
34+
// silently downgraded; sslmode=verify-full (+ sslrootcert) is recommended.
35+
func NewRDSIAMConnector(ctx context.Context, dsn, region string) (driver.Connector, error) {
36+
base, err := pgx.ParseConfig(dsn)
37+
if err != nil {
38+
return nil, fmt.Errorf("rds iam: parse dsn: %w", err)
39+
}
40+
if base.User == "" {
41+
return nil, fmt.Errorf("rds iam: dsn must specify a database user")
42+
}
43+
44+
var opts []func(*awsconfig.LoadOptions) error
45+
if region != "" {
46+
opts = append(opts, awsconfig.WithRegion(region))
47+
}
48+
awsCfg, err := awsconfig.LoadDefaultConfig(ctx, opts...)
49+
if err != nil {
50+
return nil, fmt.Errorf("rds iam: load aws config: %w", err)
51+
}
52+
if region == "" {
53+
region = awsCfg.Region
54+
}
55+
if region == "" {
56+
return nil, fmt.Errorf("rds iam: aws region is not set (configure awsRegion or AWS_REGION)")
57+
}
58+
59+
// Fail closed on any path that could send the token (which is the password)
60+
// in cleartext or to the wrong host. The token is scoped to a single
61+
// host:port, so reject:
62+
// - TLS-less DSNs: sslmode=disable/allow leave the primary TLSConfig nil;
63+
// - plaintext fallbacks: sslmode=prefer (the pgx default) keeps a non-TLS
64+
// entry in Fallbacks that pgx retries on if SSL negotiation fails;
65+
// - multi-host DSNs: a fallback host the single token is not signed for.
66+
if base.TLSConfig == nil {
67+
return nil, fmt.Errorf("rds iam: TLS is required, set sslmode=require or higher (verify-full recommended) in the dsn")
68+
}
69+
for _, fb := range base.Fallbacks {
70+
if fb.TLSConfig == nil {
71+
return nil, fmt.Errorf("rds iam: dsn allows a plaintext fallback (sslmode=prefer); set sslmode=require or higher")
72+
}
73+
if fb.Host != base.Host || fb.Port != base.Port {
74+
return nil, fmt.Errorf("rds iam: multi-host dsn is not supported; the IAM token is scoped to a single host:port")
75+
}
76+
}
77+
78+
return &rdsIAMConnector{
79+
base: base,
80+
endpoint: net.JoinHostPort(base.Host, strconv.Itoa(int(base.Port))),
81+
region: region,
82+
creds: awsCfg.Credentials,
83+
metrics: initRDSIAMMetrics(),
84+
}, nil
85+
}
86+
87+
// Connect generates a fresh IAM auth token and opens a new connection with it.
88+
func (c *rdsIAMConnector) Connect(ctx context.Context) (driver.Conn, error) {
89+
start := time.Now()
90+
token, err := auth.BuildAuthToken(ctx, c.endpoint, c.region, c.base.User, c.creds)
91+
c.metrics.tokenDuration.Observe(time.Since(start).Seconds())
92+
if err != nil {
93+
c.metrics.tokenFailureTotal.Inc()
94+
return nil, fmt.Errorf("rds iam: build auth token: %w", err)
95+
}
96+
c.metrics.tokenTotal.Inc()
97+
98+
cfg := c.base.Copy()
99+
cfg.Password = token
100+
return stdlib.GetConnector(*cfg).Connect(ctx)
101+
}
102+
103+
// Driver returns the underlying pgx stdlib driver.
104+
func (c *rdsIAMConnector) Driver() driver.Driver { return stdlib.GetDefaultDriver() }

‎common/database/iam_metrics.go‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package database
2+
3+
import (
4+
"sync"
5+
6+
"github.com/prometheus/client_golang/prometheus"
7+
"github.com/prometheus/client_golang/prometheus/promauto"
8+
)
9+
10+
type rdsIAMMetrics struct {
11+
tokenTotal prometheus.Counter
12+
tokenFailureTotal prometheus.Counter
13+
tokenDuration prometheus.Histogram
14+
}
15+
16+
var (
17+
initRDSIAMMetricsOnce sync.Once
18+
rdsIAMMetric *rdsIAMMetrics
19+
)
20+
21+
func initRDSIAMMetrics() *rdsIAMMetrics {
22+
initRDSIAMMetricsOnce.Do(func() {
23+
reg := prometheus.DefaultRegisterer
24+
rdsIAMMetric = &rdsIAMMetrics{
25+
tokenTotal: promauto.With(reg).NewCounter(prometheus.CounterOpts{
26+
Name: "database_rds_iam_token_total",
27+
Help: "Total number of AWS RDS IAM auth tokens generated (one per new connection).",
28+
}),
29+
tokenFailureTotal: promauto.With(reg).NewCounter(prometheus.CounterOpts{
30+
Name: "database_rds_iam_token_failure_total",
31+
Help: "Total number of AWS RDS IAM auth token generation failures.",
32+
}),
33+
tokenDuration: promauto.With(reg).NewHistogram(prometheus.HistogramOpts{
34+
Name: "database_rds_iam_token_duration_seconds",
35+
Help: "Latency of AWS RDS IAM auth token generation; spikes indicate a credential refresh.",
36+
Buckets: []float64{.0001, .001, .005, .01, .05, .1, .5, 1, 5},
37+
}),
38+
}
39+
})
40+
return rdsIAMMetric
41+
}

‎common/database/iam_test.go‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package database
2+
3+
import (
4+
"context"
5+
"path/filepath"
6+
"testing"
7+
8+
"github.com/stretchr/testify/assert"
9+
"github.com/stretchr/testify/require"
10+
)
11+
12+
func TestNewRDSIAMConnector(t *testing.T) {
13+
ctx := context.Background()
14+
15+
t.Run("parses endpoint, user and region", func(t *testing.T) {
16+
c, err := NewRDSIAMConnector(ctx,
17+
"postgres://svc_user@mydb.abc123.us-east-1.rds.amazonaws.com:5432/scroll?sslmode=verify-full",
18+
"us-east-1")
19+
require.NoError(t, err)
20+
21+
conn, ok := c.(*rdsIAMConnector)
22+
require.True(t, ok)
23+
assert.Equal(t, "mydb.abc123.us-east-1.rds.amazonaws.com:5432", conn.endpoint)
24+
assert.Equal(t, "svc_user", conn.base.User)
25+
assert.Equal(t, "us-east-1", conn.region)
26+
// TLS requested in the DSN must be preserved.
27+
require.NotNil(t, conn.base.TLSConfig)
28+
})
29+
30+
t.Run("defaults port to 5432", func(t *testing.T) {
31+
c, err := NewRDSIAMConnector(ctx,
32+
"postgres://svc_user@mydb.example.rds.amazonaws.com/scroll?sslmode=require",
33+
"eu-west-1")
34+
require.NoError(t, err)
35+
assert.Equal(t, "mydb.example.rds.amazonaws.com:5432", c.(*rdsIAMConnector).endpoint)
36+
})
37+
38+
t.Run("rejects sslmode=disable", func(t *testing.T) {
39+
// IAM auth requires TLS; a plaintext DSN must fail closed rather than
40+
// silently sending the token in cleartext.
41+
_, err := NewRDSIAMConnector(ctx,
42+
"postgres://svc_user@mydb.example.rds.amazonaws.com:5432/scroll?sslmode=disable",
43+
"us-east-1")
44+
assert.ErrorContains(t, err, "TLS")
45+
})
46+
47+
t.Run("rejects sslmode=prefer (plaintext fallback)", func(t *testing.T) {
48+
// prefer keeps a non-TLS entry in Fallbacks that pgx would retry on,
49+
// which would leak the token in cleartext.
50+
_, err := NewRDSIAMConnector(ctx,
51+
"postgres://svc_user@mydb.example.rds.amazonaws.com:5432/scroll?sslmode=prefer",
52+
"us-east-1")
53+
assert.ErrorContains(t, err, "plaintext")
54+
})
55+
56+
t.Run("rejects sslmode=allow (plaintext primary)", func(t *testing.T) {
57+
_, err := NewRDSIAMConnector(ctx,
58+
"postgres://svc_user@mydb.example.rds.amazonaws.com:5432/scroll?sslmode=allow",
59+
"us-east-1")
60+
assert.Error(t, err)
61+
})
62+
63+
t.Run("rejects multi-host dsn", func(t *testing.T) {
64+
// The token is signed for a single host:port, so failover would fail auth.
65+
_, err := NewRDSIAMConnector(ctx,
66+
"host=host1.rds.amazonaws.com,host2.rds.amazonaws.com port=5432 user=svc_user dbname=scroll sslmode=require",
67+
"us-east-1")
68+
assert.ErrorContains(t, err, "multi-host")
69+
})
70+
71+
t.Run("region falls back to explicit empty error when unresolved", func(t *testing.T) {
72+
// With no region argument, no AWS_REGION in the environment, and no
73+
// shared config file, region resolution must fail rather than silently
74+
// signing with an empty region.
75+
t.Setenv("AWS_REGION", "")
76+
t.Setenv("AWS_DEFAULT_REGION", "")
77+
// Isolate from any ~/.aws/config on the dev/CI machine, which would
78+
// otherwise resolve a default region and make this test nondeterministic.
79+
t.Setenv("AWS_CONFIG_FILE", filepath.Join(t.TempDir(), "no-config"))
80+
t.Setenv("AWS_SHARED_CREDENTIALS_FILE", filepath.Join(t.TempDir(), "no-creds"))
81+
_, err := NewRDSIAMConnector(ctx,
82+
"postgres://svc_user@mydb.example.rds.amazonaws.com:5432/scroll?sslmode=require",
83+
"")
84+
assert.ErrorContains(t, err, "region")
85+
})
86+
87+
t.Run("rejects invalid dsn", func(t *testing.T) {
88+
_, err := NewRDSIAMConnector(ctx, "::not a dsn::", "us-east-1")
89+
assert.Error(t, err)
90+
})
91+
}

0 commit comments

Comments
 (0)