From 7ccbe1d6ab7d8350fe4d2a855b2ffdecc4fc5b2a Mon Sep 17 00:00:00 2001 From: cce <51567+cce@users.noreply.github.com> Date: Tue, 12 Nov 2024 10:45:02 -0500 Subject: [PATCH 1/2] example of ARL counting ERL drops --- config/localTemplate.go | 2 ++ data/txHandler.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/config/localTemplate.go b/config/localTemplate.go index 413d48a05a..6e3a7c87ca 100644 --- a/config/localTemplate.go +++ b/config/localTemplate.go @@ -255,6 +255,8 @@ type Local struct { // EnableTxBacklogAppRateLimiting controls if an app rate limiter should be attached to the tx backlog enqueue process EnableTxBacklogAppRateLimiting bool `version[32]:"true"` + TxBacklogAppRateLimitingCountERLDrops bool `version[34]:"false"` + // EnableTxBacklogRateLimiting controls if a rate limiter and congestion manager should be attached to the tx backlog enqueue process // if enabled, the over-all TXBacklog Size will be larger by MAX_PEERS*TxBacklogReservedCapacityPerPeer EnableTxBacklogRateLimiting bool `version[27]:"false" version[30]:"true"` diff --git a/data/txHandler.go b/data/txHandler.go index 3b1cbe5e08..11f2a7fe5a 100644 --- a/data/txHandler.go +++ b/data/txHandler.go @@ -132,6 +132,7 @@ type TxHandler struct { erl *util.ElasticRateLimiter appLimiter *appRateLimiter appLimiterBacklogThreshold int + appLimiterCountERLDrops bool // batchVerifier provides synchronous verification of transaction groups, used only by pubsub validation in validateIncomingTxMessage. batchVerifier verify.TxnGroupBatchSigVerifier @@ -209,6 +210,7 @@ func MakeTxHandler(opts TxHandlerOpts) (*TxHandler, error) { ) // set appLimiter triggering threshold at 50% of the base backlog size handler.appLimiterBacklogThreshold = int(float64(opts.Config.TxBacklogSize) * float64(opts.Config.TxBacklogRateLimitingCongestionPct) / 100) + handler.appLimiterCountERLDrops = opts.Config.TxBacklogAppRateLimitingCountERLDrops } } @@ -743,6 +745,12 @@ func (handler *TxHandler) processIncomingTxn(rawmsg network.IncomingMessage) net }() if shouldDrop { + if handler.appLimiterCountERLDrops { + // decode and let ARL count this txgroup, even though ERL is dropping it + if unverifiedTxGroup, _, invalid := decodeMsg(rawmsg.Data); !invalid { + handler.incomingTxGroupAppRateLimit(unverifiedTxGroup, rawmsg.Sender) + } + } // this TX message was rate-limited by ERL return network.OutgoingMessage{Action: network.Ignore} } From 86e51f0ce57c08b9373ca958c10afab93e20d4c3 Mon Sep 17 00:00:00 2001 From: cce <51567+cce@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:41:44 -0500 Subject: [PATCH 2/2] comment and update config --- config/localTemplate.go | 6 +++++- config/local_defaults.go | 1 + installer/config.json.example | 1 + test/testdata/configs/config-v35.json | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config/localTemplate.go b/config/localTemplate.go index 6e3a7c87ca..5975e5fd37 100644 --- a/config/localTemplate.go +++ b/config/localTemplate.go @@ -255,7 +255,11 @@ type Local struct { // EnableTxBacklogAppRateLimiting controls if an app rate limiter should be attached to the tx backlog enqueue process EnableTxBacklogAppRateLimiting bool `version[32]:"true"` - TxBacklogAppRateLimitingCountERLDrops bool `version[34]:"false"` + // TxBacklogAppRateLimitingCountERLDrops feeds messages dropped by the ERL congestion manager & rate limiter (enabled by + // EnableTxBacklogRateLimiting) to the app rate limiter (enabled by EnableTxBacklogAppRateLimiting), so that all TX messages + // are counted. This provides more accurate rate limiting for the app rate limiter, at the potential expense of additional + // deserialization overhead. + TxBacklogAppRateLimitingCountERLDrops bool `version[35]:"false"` // EnableTxBacklogRateLimiting controls if a rate limiter and congestion manager should be attached to the tx backlog enqueue process // if enabled, the over-all TXBacklog Size will be larger by MAX_PEERS*TxBacklogReservedCapacityPerPeer diff --git a/config/local_defaults.go b/config/local_defaults.go index 7464853bb4..a58d86f681 100644 --- a/config/local_defaults.go +++ b/config/local_defaults.go @@ -148,6 +148,7 @@ var defaultLocal = Local{ TrackerDBDir: "", TransactionSyncDataExchangeRate: 0, TransactionSyncSignificantMessageThreshold: 0, + TxBacklogAppRateLimitingCountERLDrops: false, TxBacklogAppTxPerSecondRate: 100, TxBacklogAppTxRateLimiterMaxSize: 1048576, TxBacklogRateLimitingCongestionPct: 50, diff --git a/installer/config.json.example b/installer/config.json.example index 9d3146b6cb..ea63e89903 100644 --- a/installer/config.json.example +++ b/installer/config.json.example @@ -127,6 +127,7 @@ "TrackerDBDir": "", "TransactionSyncDataExchangeRate": 0, "TransactionSyncSignificantMessageThreshold": 0, + "TxBacklogAppRateLimitingCountERLDrops": false, "TxBacklogAppTxPerSecondRate": 100, "TxBacklogAppTxRateLimiterMaxSize": 1048576, "TxBacklogRateLimitingCongestionPct": 50, diff --git a/test/testdata/configs/config-v35.json b/test/testdata/configs/config-v35.json index 9d3146b6cb..ea63e89903 100644 --- a/test/testdata/configs/config-v35.json +++ b/test/testdata/configs/config-v35.json @@ -127,6 +127,7 @@ "TrackerDBDir": "", "TransactionSyncDataExchangeRate": 0, "TransactionSyncSignificantMessageThreshold": 0, + "TxBacklogAppRateLimitingCountERLDrops": false, "TxBacklogAppTxPerSecondRate": 100, "TxBacklogAppTxRateLimiterMaxSize": 1048576, "TxBacklogRateLimitingCongestionPct": 50,