Skip to content

Commit a231182

Browse files
authored
Bump tessera to ae724376e1ace4046767511c72c6006bde3ec87e (#203)
1 parent 3481261 commit a231182

File tree

7 files changed

+28
-17
lines changed

7 files changed

+28
-17
lines changed

cmd/experimental/migrate/gcp/main.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ var (
4040
spanner = flag.String("spanner", "", "Spanner resource URI ('projects/.../...')")
4141

4242
sourceURL = flag.String("source_url", "", "Base URL for the source log.")
43-
numWorkers = flag.Int("num_workers", 30, "Number of migration worker goroutines.")
44-
persistentAntispam = flag.Bool("antispam", false, "EXPERIMENTAL: Set to true to enable GCP-based persistent antispam storage")
43+
numWorkers = flag.Uint("num_workers", 30, "Number of migration worker goroutines.")
44+
persistentAntispam = flag.Bool("antispam", false, "EXPERIMENTAL: Set to true to enable GCP-based persistent antispam storage.")
45+
antispamBatchSize = flag.Uint("antispam_batch_size", 1500, "EXPERIMENTAL: maximum number of antispam rows to insert in a batch (1500 gives good performance with 300 Spanner PU and above, smaller values may be required for smaller allocs).")
4546
)
4647

4748
func main() {
@@ -88,7 +89,13 @@ func main() {
8889
var antispam tessera.Antispam
8990
// Persistent antispam is currently experimental, so there's no terraform or documentation yet!
9091
if *persistentAntispam {
91-
antispam, err = gcp_as.NewAntispam(ctx, fmt.Sprintf("%s-antispam", *spanner))
92+
as_opts := gcp_as.AntispamOpts{
93+
// 1500 appears to be give good performance for migrating logs, but you may need to lower it if you have
94+
// less than 300 Spanner PU available. (Consider temporarily raising your Spanner CPU quota to be at least
95+
// this amount for the duration of the migration.)
96+
MaxBatchSize: *antispamBatchSize,
97+
}
98+
antispam, err = gcp_as.NewAntispam(ctx, fmt.Sprintf("%s-antispam", *spanner), as_opts)
9299
if err != nil {
93100
klog.Exitf("Failed to create new GCP antispam storage: %v", err)
94101
}
@@ -101,7 +108,7 @@ func main() {
101108
}
102109

103110
readEntryBundle := readCTEntryBundle(*sourceURL)
104-
if err := tessera.Migrate(context.Background(), *numWorkers, sourceSize, sourceRoot, readEntryBundle, m); err != nil {
111+
if err := m.Migrate(context.Background(), *numWorkers, sourceSize, sourceRoot, readEntryBundle); err != nil {
105112
klog.Exitf("Migrate failed: %v", err)
106113
}
107114

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/rivo/tview v0.0.0-20240625185742-b0a7293b8130
1616
github.com/transparency-dev/formats v0.0.0-20250127084410-134797944be6
1717
github.com/transparency-dev/merkle v0.0.2
18-
github.com/transparency-dev/trillian-tessera v0.1.1-0.20250317151915-e61e2d86f685
18+
github.com/transparency-dev/trillian-tessera v0.1.2-0.20250320160837-ae724376e1ac
1919
go.etcd.io/bbolt v1.4.0
2020
golang.org/x/crypto v0.36.0
2121
golang.org/x/mod v0.24.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,8 +974,8 @@ github.com/transparency-dev/formats v0.0.0-20250127084410-134797944be6 h1:TVUG0R
974974
github.com/transparency-dev/formats v0.0.0-20250127084410-134797944be6/go.mod h1:tSjZBSQ1ZMxgaOMppnyw48SbTDL947PD/8KYbvrx+lE=
975975
github.com/transparency-dev/merkle v0.0.2 h1:Q9nBoQcZcgPamMkGn7ghV8XiTZ/kRxn1yCG81+twTK4=
976976
github.com/transparency-dev/merkle v0.0.2/go.mod h1:pqSy+OXefQ1EDUVmAJ8MUhHB9TXGuzVAT58PqBoHz1A=
977-
github.com/transparency-dev/trillian-tessera v0.1.1-0.20250317151915-e61e2d86f685 h1:Cu1sKlj37BnhBybTQ5V1/zgqPQHlBEXIyLiAK+rVlvA=
978-
github.com/transparency-dev/trillian-tessera v0.1.1-0.20250317151915-e61e2d86f685/go.mod h1:uvyZ7WGpaRDPY+4Lme+s1vEUOluYevTYzrDg9j05cYU=
977+
github.com/transparency-dev/trillian-tessera v0.1.2-0.20250320160837-ae724376e1ac h1:LwnfCnox2ZHW3TgMCdL60C4xp8oR3lDew13MZeHDhPA=
978+
github.com/transparency-dev/trillian-tessera v0.1.2-0.20250320160837-ae724376e1ac/go.mod h1:fARQE1UN2Z0wv/02J0uAsTIli/+flEJGCMWlBs9Ps9E=
979979
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
980980
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
981981
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

internal/scti/handlers.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,17 @@ func addChainInternal(ctx context.Context, opts *HandlerOptions, log *log, w htt
301301
}
302302

303303
klog.V(2).Infof("%s: %s => storage.Add", log.origin, method)
304-
idx, err = log.storage.Add(ctx, entry)()
304+
index, err := log.storage.Add(ctx, entry)()
305305
if err != nil {
306306
if errors.Is(err, tessera.ErrPushback) {
307307
w.Header().Add("Retry-After", "1")
308308
return http.StatusServiceUnavailable, fmt.Errorf("Tessera sequencer pushed back: %v", err)
309309
}
310310
return http.StatusInternalServerError, fmt.Errorf("couldn't store the leaf: %v", err)
311311
}
312+
// TODO(phbnf): figure out whether to use Tessera's index.IsDup() or a separate "external" antispam impl.
313+
idx = index.Index
314+
312315
// We store the index for this certificate in the deduplication storage immediately.
313316
// It might be stored again later, if a local deduplication storage is synced, potentially
314317
// with a smaller value.

internal/scti/handlers_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"github.com/transparency-dev/static-ct/internal/x509util"
3939
"github.com/transparency-dev/static-ct/mockstorage"
4040
"github.com/transparency-dev/static-ct/modules/dedup"
41+
tessera "github.com/transparency-dev/trillian-tessera"
4142
"github.com/transparency-dev/trillian-tessera/ctonly"
4243
"google.golang.org/grpc/codes"
4344
"google.golang.org/grpc/status"
@@ -293,7 +294,7 @@ func TestAddChainWhitespace(t *testing.T) {
293294
epilog := "]}\n"
294295

295296
req, leafChain := parseChain(t, false, pemChain, info.roots.RawCertificates()[0])
296-
rsp := uint64(0)
297+
rsp := tessera.Index{Index: 0}
297298

298299
var tests = []struct {
299300
descr string
@@ -332,7 +333,7 @@ func TestAddChainWhitespace(t *testing.T) {
332333
if test.want == http.StatusOK {
333334
info.storage.EXPECT().GetCertDedupInfo(deadlineMatcher(), cmpMatcher{leafChain[0]}).Return(dedup.SCTDedupInfo{Idx: uint64(0), Timestamp: fakeTimeMillis}, false, nil)
334335
info.storage.EXPECT().AddIssuerChain(deadlineMatcher(), cmpMatcher{leafChain[1:]}).Return(nil)
335-
info.storage.EXPECT().Add(deadlineMatcher(), cmpMatcher{req}).Return(func() (uint64, error) { return rsp, nil })
336+
info.storage.EXPECT().Add(deadlineMatcher(), cmpMatcher{req}).Return(func() (tessera.Index, error) { return rsp, nil })
336337
info.storage.EXPECT().AddCertDedupInfo(deadlineMatcher(), cmpMatcher{leafChain[0]}, dedup.SCTDedupInfo{Idx: uint64(0), Timestamp: fakeTimeMillis}).Return(nil)
337338
}
338339

@@ -408,10 +409,10 @@ func TestAddChain(t *testing.T) {
408409
chain := createJSONChain(t, *pool)
409410
if len(test.toSign) > 0 {
410411
req, leafChain := parseChain(t, false, test.chain, info.roots.RawCertificates()[0])
411-
rsp := uint64(0)
412+
rsp := tessera.Index{Index: 0}
412413
info.storage.EXPECT().GetCertDedupInfo(deadlineMatcher(), cmpMatcher{leafChain[0]}).Return(dedup.SCTDedupInfo{Idx: uint64(0), Timestamp: fakeTimeMillis}, false, nil)
413414
info.storage.EXPECT().AddIssuerChain(deadlineMatcher(), cmpMatcher{leafChain[1:]}).Return(nil)
414-
info.storage.EXPECT().Add(deadlineMatcher(), cmpMatcher{req}).Return(func() (uint64, error) { return rsp, test.err })
415+
info.storage.EXPECT().Add(deadlineMatcher(), cmpMatcher{req}).Return(func() (tessera.Index, error) { return rsp, test.err })
415416
if test.want == http.StatusOK {
416417
info.storage.EXPECT().AddCertDedupInfo(deadlineMatcher(), cmpMatcher{leafChain[0]}, dedup.SCTDedupInfo{Idx: uint64(0), Timestamp: fakeTimeMillis}).Return(nil)
417418
}
@@ -505,10 +506,10 @@ func TestAddPrechain(t *testing.T) {
505506
chain := createJSONChain(t, *pool)
506507
if len(test.toSign) > 0 {
507508
req, leafChain := parseChain(t, true, test.chain, info.roots.RawCertificates()[0])
508-
rsp := uint64(0)
509+
rsp := tessera.Index{Index: 0}
509510
info.storage.EXPECT().GetCertDedupInfo(deadlineMatcher(), cmpMatcher{leafChain[0]}).Return(dedup.SCTDedupInfo{Idx: uint64(0), Timestamp: fakeTimeMillis}, false, nil)
510511
info.storage.EXPECT().AddIssuerChain(deadlineMatcher(), cmpMatcher{leafChain[1:]}).Return(nil)
511-
info.storage.EXPECT().Add(deadlineMatcher(), cmpMatcher{req}).Return(func() (uint64, error) { return rsp, test.err })
512+
info.storage.EXPECT().Add(deadlineMatcher(), cmpMatcher{req}).Return(func() (tessera.Index, error) { return rsp, test.err })
512513
if test.want == http.StatusOK {
513514
info.storage.EXPECT().AddCertDedupInfo(deadlineMatcher(), cmpMatcher{leafChain[0]}, dedup.SCTDedupInfo{Idx: uint64(0), Timestamp: fakeTimeMillis}).Return(nil)
514515
}

mockstorage/gen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
// Package mockclient provides a mockable version of the Trillian log client API.
1616
package mockstorage
1717

18-
//go:generate mockgen -package mockstorage -destination mock_ct_storage.go github.com/transparency-dev/static-ct Storage
18+
//go:generate mockgen -package mockstorage -destination mock_ct_storage.go github.com/transparency-dev/static-ct/internal/scti Storage

mockstorage/mock_ct_storage.go

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

0 commit comments

Comments
 (0)