Skip to content

Commit c69d0f1

Browse files
committed
Rename flags and rate limiters dedup
1 parent 9f1195b commit c69d0f1

File tree

11 files changed

+54
-42
lines changed

11 files changed

+54
-42
lines changed

cmd/tesseract/README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ This flag is on by default.
119119

120120
#### Antispam
121121

122-
The `pushback_max_antispam_lag`, `pushback_max_dedup_in_flight` and
122+
The `pushback_max_antispam_lag`, `rate_limit_dedup` and
123123
`inmemory_antispam_cache_size` flags control how [TesseraCT's Antispam feature](/docs/architecture.md#antispam)
124124
works, which itself is built on top of [Tessera's Antispam](https://github.com/transparency-dev/tessera?tab=readme-ov-file#antispam)
125125
capabilities. It is composed of three main steps:
@@ -146,14 +146,13 @@ calls faster, and provides optimistic coverage for entries submitted _very_
146146
recently and which have not yet been processed by the asynchronous process in
147147
`(1)`.
148148

149-
The `pushback_max_dedup_in_flight` flag rate limits how many concurrent `add-*`
150-
requests identified as duplicates will be processed by the
151-
**synchronous** process in `(3)` wich fetches entries and extracts information
152-
required to build SCTs. When this value is exceeded, TesseraCT returns
153-
`429 -Too Many Requests` to subsequent **duplicate** `add-*` requests only.
154-
Non-duplicate `add-*` requests are not impacted, and can still be processed.
155-
This limits the amount of resources TesseraCT spends on servicing duplicate
156-
requests.
149+
The `rate_limit_dedup` flag rate limits how many concurrent `add-*` requests
150+
identified as duplicates will be processed by the **synchronous** process in
151+
`(3)` wich fetches entries and extracts information required to build SCTs.
152+
When this value is exceeded, TesseraCT returns `429 -Too Many Requests` to
153+
subsequent **duplicate** `add-*` requests only. Non-duplicate `add-*` requests
154+
are not impacted, and can still be processed. This limits the amount of
155+
resources TesseraCT spends on servicing duplicate requests.
157156

158157
### Setup
159158

cmd/tesseract/aws/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ import (
4747
func init() {
4848
flag.Var(&notAfterStart, "not_after_start", "Start of the range of acceptable NotAfter values, inclusive. Leaving this unset or empty implies no lower bound to the range. RFC3339 UTC format, e.g: 2024-01-02T15:04:05Z.")
4949
flag.Var(&notAfterLimit, "not_after_limit", "Cut off point of notAfter dates - only notAfter dates strictly *before* notAfterLimit will be accepted. Leaving this unset or empty means no upper bound on the accepted range. RFC3339 UTC format, e.g: 2024-01-02T15:04:05Z.")
50-
flag.Float64Var(&limitDedupInFlight, "limit_dedup_in_flight", -1, "Optionally rate limits the number of number of in-flight duplicate add requests - i.e. the number of requests matching entries that have already been integrated, but need to be fetched by the client to retrieve their timestamp. When 0, duplicate entries are always rate limited. When negative, no rate limits apply.")
50+
flag.Float64Var(&dedupRL, "rate_limit_dedup", -1, "Optionally rate limits the number of number of in-flight duplicate add requests - i.e. the number of requests matching entries that have already been integrated, but need to be fetched by the client to retrieve their timestamp. When 0, duplicate entries are always rate limited. When negative, no rate limits apply.")
5151
// DEPRECATED: will be removed shortly
52-
flag.Float64Var(&limitDedupInFlight, "pushback_max_dedupe_in_flight", 100, "DEPRECATED: use pushback_max_dedup_in_flight. Maximum number of number of in-flight duplicate add requests - i.e. the number of requests matching entries that have already been integrated, but need to be fetched by the client to retrieve their timestamp. When 0, duplicate entries are always pushed back.")
52+
flag.Float64Var(&dedupRL, "pushback_max_dedupe_in_flight", 100, "DEPRECATED: use rate_limit_dedup. Maximum number of number of in-flight duplicate add requests - i.e. the number of requests matching entries that have already been integrated, but need to be fetched by the client to retrieve their timestamp. When 0, duplicate entries are always pushed back.")
5353
}
5454

5555
// Global flags that affect all log instances.
5656
var (
57-
notAfterStart timestampFlag
58-
notAfterLimit timestampFlag
59-
limitDedupInFlight float64
57+
notAfterStart timestampFlag
58+
notAfterLimit timestampFlag
59+
dedupRL float64
6060

6161
// Functionality flags
6262
httpEndpoint = flag.String("http_endpoint", "localhost:6962", "Endpoint for HTTP (host:port).")
@@ -141,7 +141,7 @@ eventually go away. See /internal/lax509/README.md for more information.`)
141141

142142
hOpts := tesseract.LogHandlerOpts{
143143
OldSubmissionLimit: rateLimitFromFlags(),
144-
DedupInFlightLimit: limitDedupInFlight,
144+
DedupRL: dedupRL,
145145
}
146146
logHandler, err := tesseract.NewLogHandler(ctx, *origin, signer, chainValidationConfig, newAWSStorage, *httpDeadline, *maskInternalErrors, *pathPrefix, hOpts)
147147
if err != nil {

cmd/tesseract/gcp/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ func init() {
4646
flag.Var(&notAfterStart, "not_after_start", "Start of the range of acceptable NotAfter values, inclusive. Leaving this unset or empty implies no lower bound to the range. RFC3339 UTC format, e.g: 2024-01-02T15:04:05Z.")
4747
flag.Var(&notAfterLimit, "not_after_limit", "Cut off point of notAfter dates - only notAfter dates strictly *before* notAfterLimit will be accepted. Leaving this unset or empty means no upper bound on the accepted range. RFC3339 UTC format, e.g: 2024-01-02T15:04:05Z.")
4848
flag.Var(&additionalSigners, "additional_signer_private_key_secret_name", "Private key secret name for additional Ed25519 checkpoint signatures, may be supplied multiple times. Format: projects/{projectId}/secrets/{secretName}/versions/{secretVersion}.")
49-
flag.Float64Var(&limitDedupInFlight, "limit_dedup_in_flight", -1, "Optionally rate limits the number of number of in-flight duplicate add requests - i.e. the number of requests matching entries that have already been integrated, but need to be fetched by the client to retrieve their timestamp. When 0, duplicate entries are always rate limited. When negative, no rate limits apply.")
49+
flag.Float64Var(&dedupRL, "rate_limit_dedup", -1, "Optionally rate limits the number of number of in-flight duplicate add requests - i.e. the number of requests matching entries that have already been integrated, but need to be fetched by the client to retrieve their timestamp. When 0, duplicate entries are always rate limited. When negative, no rate limits apply.")
5050
// DEPRECATED: will be removed shortly
51-
flag.Float64Var(&limitDedupInFlight, "pushback_max_dedupe_in_flight", 100, "DEPRECATED: use limit_dedup_in_flight. Maximum number of number of in-flight duplicate add requests - i.e. the number of requests matching entries that have already been integrated, but need to be fetched by the client to retrieve their timestamp. When 0, duplicate entries are always pushed back.")
51+
flag.Float64Var(&dedupRL, "pushback_max_dedupe_in_flight", 100, "DEPRECATED: use rate_limit_dedup. Maximum number of number of in-flight duplicate add requests - i.e. the number of requests matching entries that have already been integrated, but need to be fetched by the client to retrieve their timestamp. When 0, duplicate entries are always pushed back.")
5252
}
5353

5454
// Global flags that affect all log instances.
5555
var (
56-
notAfterStart timestampFlag
57-
notAfterLimit timestampFlag
58-
additionalSigners multiStringFlag
59-
limitDedupInFlight float64
56+
notAfterStart timestampFlag
57+
notAfterLimit timestampFlag
58+
additionalSigners multiStringFlag
59+
dedupRL float64
6060

6161
// Functionality flags
6262
httpEndpoint = flag.String("http_endpoint", "localhost:6962", "Endpoint for HTTP (host:port).")
@@ -128,7 +128,7 @@ eventually go away. See /internal/lax509/README.md for more information.`)
128128

129129
hOpts := tesseract.LogHandlerOpts{
130130
OldSubmissionLimit: rateLimitFromFlags(),
131-
DedupInFlightLimit: limitDedupInFlight,
131+
DedupRL: dedupRL,
132132
}
133133
logHandler, err := tesseract.NewLogHandler(ctx, *origin, signer, chainValidationConfig, newGCPStorage, *httpDeadline, *maskInternalErrors, *pathPrefix, hOpts)
134134
if err != nil {

cmd/tesseract/posix/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ func init() {
4949
flag.Var(&notAfterStart, "not_after_start", "Start of the range of acceptable NotAfter values, inclusive. Leaving this unset implies no lower bound to the range. RFC3339 UTC format, e.g: 2024-01-02T15:04:05Z.")
5050
flag.Var(&notAfterLimit, "not_after_limit", "Cut off point of notAfter dates - only notAfter dates strictly *before* notAfterLimit will be accepted. Leaving this unset means no upper bound on the accepted range. RFC3339 UTC format, e.g: 2024-01-02T15:04:05Z.")
5151
flag.Var(&additionalSigners, "additional_signer", "Path to a file containing an additional note Signer formatted keys for checkpoints. May be specified multiple times.")
52-
flag.Float64Var(&pushbackMaxDedupInFlight, "pushback_max_dedup_in_flight", 100, "Maximum number of number of in-flight duplicate add requests per second - i.e. the number of requests matching entries that have already been integrated, but need to be fetched by the client to retrieve their timestamp. When 0, duplicate entries are always pushed back.")
52+
flag.Float64Var(&dedupRL, "rate_limit_dedup", 100, "Maximum number of number of in-flight duplicate add requests per second - i.e. the number of requests matching entries that have already been integrated, but need to be fetched by the client to retrieve their timestamp. When 0, duplicate entries are always pushed back.")
5353
// DEPRECATED: will be removed shortly
54-
flag.Float64Var(&pushbackMaxDedupInFlight, "pushback_max_dedupe_in_flight", 100, "DEPRECATED: use pushback_max_dedup_in_flight. Maximum number of number of in-flight duplicate add requests - i.e. the number of requests matching entries that have already been integrated, but need to be fetched by the client to retrieve their timestamp. When 0, duplicate entries are always pushed back.")
54+
flag.Float64Var(&dedupRL, "pushback_max_dedupe_in_flight", 100, "DEPRECATED: use rate_limit_dedup. Maximum number of number of in-flight duplicate add requests - i.e. the number of requests matching entries that have already been integrated, but need to be fetched by the client to retrieve their timestamp. When 0, duplicate entries are always pushed back.")
5555
}
5656

5757
// Global flags that affect all log instances.
5858
var (
59-
notAfterStart timestampFlag
60-
notAfterLimit timestampFlag
61-
additionalSigners multiStringFlag
62-
pushbackMaxDedupInFlight float64
59+
notAfterStart timestampFlag
60+
notAfterLimit timestampFlag
61+
additionalSigners multiStringFlag
62+
dedupRL float64
6363

6464
// Functionality flags
6565
httpEndpoint = flag.String("http_endpoint", "localhost:6962", "Endpoint for HTTP (host:port).")

ctlog.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ type OldSubmissionLimit struct {
131131

132132
type LogHandlerOpts struct {
133133
OldSubmissionLimit *OldSubmissionLimit
134-
DedupInFlightLimit float64
134+
DedupRL float64
135135
}
136136

137137
// NewLogHandler creates a Tessera based CT log pluged into HTTP handlers.
@@ -163,8 +163,8 @@ func NewLogHandler(ctx context.Context, origin string, signer crypto.Signer, cfg
163163
if opts.OldSubmissionLimit != nil {
164164
ctOpts.RateLimits.OldSubmission(opts.OldSubmissionLimit.AgeThreshold, opts.OldSubmissionLimit.RateLimit)
165165
}
166-
if opts.DedupInFlightLimit >= 0 {
167-
ctOpts.RateLimits.DedupInFlight(opts.DedupInFlightLimit)
166+
if opts.DedupRL >= 0 {
167+
ctOpts.RateLimits.Dedup(opts.DedupRL)
168168
}
169169

170170
handlers := ct.NewPathHandlers(ctx, ctOpts, log)

deployment/modules/gcp/gce/tesseract/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ module "gce_container_tesseract" {
4040
"--batch_max_age=${var.batch_max_age}",
4141
"--enable_publication_awaiter=${var.enable_publication_awaiter}",
4242
"--accept_sha1_signing_algorithms=true",
43-
"--limit_old_submissions=${var.limit_old_submissions}"
43+
"--limit_old_submissions=${var.limit_old_submissions}",
44+
"--rate_limit_dedup=${var.rate_limit_dedup}"
4445
]
4546
tty : true # maybe remove this
4647
}

deployment/modules/gcp/gce/tesseract/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,8 @@ variable "limit_old_submissions" {
106106
default = ""
107107
}
108108

109+
variable "rate_limit_dedup" {
110+
description = "Set to rate limit duplicate submissions per second."
111+
type = number
112+
default = -1
113+
}

deployment/modules/gcp/tesseract/gce/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module "gce" {
4242
batch_max_size = var.batch_max_size
4343
enable_publication_awaiter = var.enable_publication_awaiter
4444
limit_old_submissions = var.limit_old_submissions
45+
rate_limit_dedup = var.rate_limit_dedup
4546

4647
depends_on = [
4748
module.secretmanager,

deployment/modules/gcp/tesseract/gce/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,9 @@ variable "limit_old_submissions" {
104104
type = string
105105
default = ""
106106
}
107+
108+
variable "rate_limit_dedup" {
109+
description = "Set to rate limit duplicate submissions per second."
110+
type = number
111+
default = -1
112+
}

internal/ct/handlers.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ func (a appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
192192

193193
// RateLimits knows how to apply configurable rate limits to submissions.
194194
type RateLimits struct {
195-
oldAge time.Duration
196-
oldLimiter *rate.Limiter
197-
dedupLimiter *rate.Limiter
195+
oldAge time.Duration
196+
oldLimiter *rate.Limiter
197+
dedup *rate.Limiter
198198
}
199199

200-
// OldSubmission configures a rate limit on old certs.
200+
// NotBefore configures a rate limit on old certs.
201201
//
202202
// Submissions whose notBefore date is at least as old as age will be subject to the specified number of entries per second.
203203
func (r *RateLimits) OldSubmission(age time.Duration, limit float64) {
@@ -206,11 +206,11 @@ func (r *RateLimits) OldSubmission(age time.Duration, limit float64) {
206206
klog.Infof("Configured OldSubmission limiter with %0.2f qps for certs aged >= %s", limit, age)
207207
}
208208

209-
// DedupInFlight configures a rate limit on entries being deduplicated.
209+
// Dedup configures a rate limit on entries being deduplicated.
210210
//
211211
// Submissions will be subject to the specified number of entries per second.
212-
func (r *RateLimits) DedupInFlight(limit float64) {
213-
r.dedupLimiter = rate.NewLimiter(rate.Limit(limit), int(math.Ceil(limit)))
212+
func (r *RateLimits) Dedup(limit float64) {
213+
r.dedup = rate.NewLimiter(rate.Limit(limit), int(math.Ceil(limit)))
214214
klog.Infof("Configured DedupInFlight limiter with %0.2f qps", limit)
215215
}
216216

@@ -233,8 +233,8 @@ func (r *RateLimits) Accept(ctx context.Context, chain []*x509.Certificate) bool
233233

234234
// AcceptDedup returns true if a duplicate entry is permitted to be resolved.
235235
func (r *RateLimits) AcceptDedup(ctx context.Context) bool {
236-
if r.dedupLimiter != nil {
237-
if r.dedupLimiter.Allow() {
236+
if r.dedup != nil {
237+
if r.dedup.Allow() {
238238
return true
239239
}
240240
rateLimitedRequests.Add(ctx, 1, metric.WithAttributes(rateLimitReasonKey.String("dedup")))

0 commit comments

Comments
 (0)