Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance: do not report extra details for failed app txns #6171

Merged
merged 7 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions config/localTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type Local struct {
// Version tracks the current version of the defaults so we can migrate old -> new
// This is specifically important whenever we decide to change the default value
// for an existing parameter. This field tag must be updated any time we add a new version.
Version uint32 `version[0]:"0" version[1]:"1" version[2]:"2" version[3]:"3" version[4]:"4" version[5]:"5" version[6]:"6" version[7]:"7" version[8]:"8" version[9]:"9" version[10]:"10" version[11]:"11" version[12]:"12" version[13]:"13" version[14]:"14" version[15]:"15" version[16]:"16" version[17]:"17" version[18]:"18" version[19]:"19" version[20]:"20" version[21]:"21" version[22]:"22" version[23]:"23" version[24]:"24" version[25]:"25" version[26]:"26" version[27]:"27" version[28]:"28" version[29]:"29" version[30]:"30" version[31]:"31" version[32]:"32" version[33]:"33" version[34]:"34"`
Version uint32 `version[0]:"0" version[1]:"1" version[2]:"2" version[3]:"3" version[4]:"4" version[5]:"5" version[6]:"6" version[7]:"7" version[8]:"8" version[9]:"9" version[10]:"10" version[11]:"11" version[12]:"12" version[13]:"13" version[14]:"14" version[15]:"15" version[16]:"16" version[17]:"17" version[18]:"18" version[19]:"19" version[20]:"20" version[21]:"21" version[22]:"22" version[23]:"23" version[24]:"24" version[25]:"25" version[26]:"26" version[27]:"27" version[28]:"28" version[29]:"29" version[30]:"30" version[31]:"31" version[32]:"32" version[33]:"33" version[34]:"34" version[35]:"35"`

// Archival nodes retain a full copy of the block history. Non-Archival nodes will delete old blocks and only retain what's need to properly validate blockchain messages (the precise number of recent blocks depends on the consensus parameters. Currently the last 1321 blocks are required). This means that non-Archival nodes require significantly less storage than Archival nodes. If setting this to true for the first time, the existing ledger may need to be deleted to get the historical values stored as the setting only affects current blocks forward. To do this, shutdown the node and delete all .sqlite files within the data/testnet-version directory, except the crash.sqlite file. Restart the node and wait for the node to sync.
Archival bool `version[0]:"false"`
Expand All @@ -66,7 +66,7 @@ type Local struct {
PublicAddress string `version[0]:""`

// MaxConnectionsPerIP is the maximum number of connections allowed per IP address.
MaxConnectionsPerIP int `version[3]:"30" version[27]:"15"`
MaxConnectionsPerIP int `version[3]:"30" version[27]:"15" version[35]:"8"`

// PeerPingPeriodSeconds is deprecated and unused.
PeerPingPeriodSeconds int `version[0]:"0"`
Expand Down Expand Up @@ -171,7 +171,7 @@ type Local struct {
EndpointAddress string `version[0]:"127.0.0.1:0"`

// Respond to Private Network Access preflight requests sent to the node. Useful when a public website is trying to access a node that's hosted on a local network.
EnablePrivateNetworkAccessHeader bool `version[34]:"false"`
EnablePrivateNetworkAccessHeader bool `version[35]:"false"`

// RestReadTimeoutSeconds is passed to the API servers rest http.Server implementation.
RestReadTimeoutSeconds int `version[4]:"15"`
Expand Down Expand Up @@ -255,6 +255,12 @@ 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 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"`
gmalouf marked this conversation as resolved.
Show resolved Hide resolved

// 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"`
Expand Down
5 changes: 3 additions & 2 deletions config/local_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package config

var defaultLocal = Local{
Version: 34,
Version: 35,
AccountUpdatesStatsInterval: 5000000000,
AccountsRebuildSynchronousMode: 1,
AgreementIncomingBundlesQueueLength: 15,
Expand Down Expand Up @@ -111,7 +111,7 @@ var defaultLocal = Local{
MaxAcctLookback: 4,
MaxBlockHistoryLookback: 0,
MaxCatchpointDownloadDuration: 43200000000000,
MaxConnectionsPerIP: 15,
MaxConnectionsPerIP: 8,
MinCatchpointFileDownloadBytesPerSecond: 20480,
NetAddress: "",
NetworkMessageTraceServer: "",
Expand Down Expand Up @@ -148,6 +148,7 @@ var defaultLocal = Local{
TrackerDBDir: "",
TransactionSyncDataExchangeRate: 0,
TransactionSyncSignificantMessageThreshold: 0,
TxBacklogAppRateLimitingCountERLDrops: false,
TxBacklogAppTxPerSecondRate: 100,
TxBacklogAppTxRateLimiterMaxSize: 1048576,
TxBacklogRateLimitingCongestionPct: 50,
Expand Down
4 changes: 2 additions & 2 deletions data/transactions/logic/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1027,8 +1027,8 @@ func (err EvalError) Unwrap() error {
}

func (cx *EvalContext) evalError(err error) error {
pc, det := cx.pcDetails()
details := fmt.Sprintf("pc=%d, opcodes=%s", pc, det)
pc := cx.pc
details := fmt.Sprintf("pc=%d", pc)

err = basics.Annotate(err,
"pc", pc,
Expand Down
2 changes: 1 addition & 1 deletion data/transactions/logic/evalStateful_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ itxn_submit
Stack: []any{uint64(777)},
},
},
"inner-msg": "logic eval error: cannot compare (uint64 to []byte). Details: app=5000, pc=26, opcodes=pushint 100; pushbytes 0x0201 // 0x0201; ==",
"inner-msg": "logic eval error: cannot compare (uint64 to []byte). Details: app=5000, pc=26",
"inner-attrs": map[string]any{
"pc": 26,
"group-index": 0,
Expand Down
14 changes: 12 additions & 2 deletions data/txHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
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
Expand Down Expand Up @@ -209,6 +210,7 @@
)
// 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
}
}

Expand Down Expand Up @@ -622,15 +624,17 @@
// - a boolean indicating if the sender is rate limited
func (handler *TxHandler) incomingMsgErlCheck(sender network.DisconnectablePeer) (*util.ErlCapacityGuard, bool) {
var capguard *util.ErlCapacityGuard
var isCMEnabled bool
var err error
if handler.erl != nil {
congestedERL := float64(cap(handler.backlogQueue))*handler.backlogCongestionThreshold < float64(len(handler.backlogQueue))
// consume a capacity unit
// if the elastic rate limiter cannot vend a capacity, the error it returns
// is sufficient to indicate that we should enable Congestion Control, because
// an issue in vending capacity indicates the underlying resource (TXBacklog) is full
capguard, err = handler.erl.ConsumeCapacity(sender.(util.ErlClient))
if err != nil {
capguard, isCMEnabled, err = handler.erl.ConsumeCapacity(sender.(util.ErlClient))
if err != nil || // did ERL ask to enable congestion control?
(!isCMEnabled && congestedERL) { // is CM not currently enabled, but queue is congested?
handler.erl.EnableCongestionControl()
// if there is no capacity, it is the same as if we failed to put the item onto the backlog, so report such
transactionMessagesDroppedFromBacklog.Inc(nil)
Expand Down Expand Up @@ -741,6 +745,12 @@
}()

if shouldDrop {
if handler.appLimiterCountERLDrops {

Check warning on line 748 in data/txHandler.go

View check run for this annotation

Codecov / codecov/patch

data/txHandler.go#L748

Added line #L748 was not covered by tests
// 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)

Check warning on line 751 in data/txHandler.go

View check run for this annotation

Codecov / codecov/patch

data/txHandler.go#L750-L751

Added lines #L750 - L751 were not covered by tests
}
}
// this TX message was rate-limited by ERL
return network.OutgoingMessage{Action: network.Ignore}
}
Expand Down
5 changes: 3 additions & 2 deletions installer/config.json.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Version": 34,
"Version": 35,
"AccountUpdatesStatsInterval": 5000000000,
"AccountsRebuildSynchronousMode": 1,
"AgreementIncomingBundlesQueueLength": 15,
Expand Down Expand Up @@ -90,7 +90,7 @@
"MaxAcctLookback": 4,
"MaxBlockHistoryLookback": 0,
"MaxCatchpointDownloadDuration": 43200000000000,
"MaxConnectionsPerIP": 15,
"MaxConnectionsPerIP": 8,
"MinCatchpointFileDownloadBytesPerSecond": 20480,
"NetAddress": "",
"NetworkMessageTraceServer": "",
Expand Down Expand Up @@ -127,6 +127,7 @@
"TrackerDBDir": "",
"TransactionSyncDataExchangeRate": 0,
"TransactionSyncSignificantMessageThreshold": 0,
"TxBacklogAppRateLimitingCountERLDrops": false,
"TxBacklogAppTxPerSecondRate": 100,
"TxBacklogAppTxRateLimiterMaxSize": 1048576,
"TxBacklogRateLimitingCongestionPct": 50,
Expand Down
2 changes: 1 addition & 1 deletion ledger/apptxn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ func TestRekeyActionCloseAccount(t *testing.T) {
// do it again, to ensure the lack of authorization is in the right
// place, by matching on the opcode that comes before the itxn_submit we
// want to know failed (it'll be in the error).
dl.txn(&useacct, "itxn_field Receiver")
dl.txn(&useacct, "logic eval error")
})
}

Expand Down
12 changes: 6 additions & 6 deletions ledger/boxtxn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,28 +169,28 @@ func TestBoxCreate(t *testing.T) {
}

dl.txn(adam.Args("check", "adam", "\x00\x00"))
dl.txgroup("box_create; assert", adam.Noted("one"), adam.Noted("two"))
dl.txgroup("logic eval error: assert failed", adam.Noted("one"), adam.Noted("two"))

bobo := call.Args("create", "bobo")
dl.txn(bobo, fmt.Sprintf("invalid Box reference %#x", "bobo"))
bobo.Boxes = []transactions.BoxRef{{Index: 0, Name: []byte("bobo")}}
dl.txn(bobo)
dl.txgroup("box_create; assert", bobo.Noted("one"), bobo.Noted("two"))
dl.txgroup("logic eval error: assert failed", bobo.Noted("one"), bobo.Noted("two"))
algorandskiy marked this conversation as resolved.
Show resolved Hide resolved

dl.beginBlock()
chaz := call.Args("create", "chaz")
chaz.Boxes = []transactions.BoxRef{{Index: 0, Name: []byte("chaz")}}
dl.txn(chaz)
dl.txn(chaz.Noted("again"), "box_create; assert")
dl.txn(chaz.Noted("again"), "logic eval error: assert failed")
dl.endBlock()

// new block
dl.txn(chaz.Noted("again"), "box_create; assert")
dl.txn(chaz.Noted("again"), "logic eval error: assert failed")
dogg := call.Args("create", "dogg")
dogg.Boxes = []transactions.BoxRef{{Index: 0, Name: []byte("dogg")}}
dl.txn(dogg, "below min")
dl.txn(chaz.Args("delete", "chaz"))
dl.txn(chaz.Args("delete", "chaz").Noted("again"), "box_del; assert")
dl.txn(chaz.Args("delete", "chaz").Noted("again"), "logic eval error: assert failed")
dl.txn(dogg)
dl.txn(bobo.Args("delete", "bobo"))

Expand Down Expand Up @@ -229,7 +229,7 @@ func TestBoxRecreate(t *testing.T) {
create := call.Args("create", "adam", "\x04") // box value size is 4 bytes
recreate := call.Args("recreate", "adam", "\x04")

dl.txn(recreate, "box_create; !; assert")
dl.txn(recreate, "logic eval error: assert failed")
dl.txn(create)
dl.txn(recreate)
dl.txn(call.Args("set", "adam", "\x01\x02\x03\x04"))
Expand Down
1 change: 0 additions & 1 deletion test/testdata/configs/config-v34.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"EnableP2P": false,
"EnableP2PHybridMode": false,
"EnablePingHandler": true,
"EnablePrivateNetworkAccessHeader": false,
"EnableProcessBlockStats": false,
"EnableProfiler": false,
"EnableRequestLogger": false,
Expand Down
146 changes: 146 additions & 0 deletions test/testdata/configs/config-v35.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{
"Version": 35,
"AccountUpdatesStatsInterval": 5000000000,
"AccountsRebuildSynchronousMode": 1,
"AgreementIncomingBundlesQueueLength": 15,
"AgreementIncomingProposalsQueueLength": 50,
"AgreementIncomingVotesQueueLength": 20000,
"AnnounceParticipationKey": true,
"Archival": false,
"BaseLoggerDebugLevel": 4,
"BlockDBDir": "",
"BlockServiceCustomFallbackEndpoints": "",
"BlockServiceMemCap": 500000000,
"BroadcastConnectionsLimit": -1,
"CadaverDirectory": "",
"CadaverSizeTarget": 0,
"CatchpointDir": "",
"CatchpointFileHistoryLength": 365,
"CatchpointInterval": 10000,
"CatchpointTracking": 0,
"CatchupBlockDownloadRetryAttempts": 1000,
"CatchupBlockValidateMode": 0,
"CatchupFailurePeerRefreshRate": 10,
"CatchupGossipBlockFetchTimeoutSec": 4,
"CatchupHTTPBlockFetchTimeoutSec": 4,
"CatchupLedgerDownloadRetryAttempts": 50,
"CatchupParallelBlocks": 16,
"ColdDataDir": "",
"ConnectionsRateLimitingCount": 60,
"ConnectionsRateLimitingWindowSeconds": 1,
"CrashDBDir": "",
"DNSBootstrapID": "<network>.algorand.network?backup=<network>.algorand.net&dedup=<name>.algorand-<network>.(network|net)",
"DNSSecurityFlags": 9,
"DeadlockDetection": 0,
"DeadlockDetectionThreshold": 30,
"DisableAPIAuth": false,
"DisableLedgerLRUCache": false,
"DisableLocalhostConnectionRateLimit": true,
"DisableNetworking": false,
"DisableOutgoingConnectionThrottling": false,
"EnableAccountUpdatesStats": false,
"EnableAgreementReporting": false,
"EnableAgreementTimeMetrics": false,
"EnableAssembleStats": false,
"EnableBlockService": false,
"EnableDHTProviders": false,
"EnableDeveloperAPI": false,
"EnableExperimentalAPI": false,
"EnableFollowMode": false,
"EnableGossipBlockService": true,
"EnableGossipService": true,
"EnableIncomingMessageFilter": false,
"EnableLedgerService": false,
"EnableMetricReporting": false,
"EnableNetDevMetrics": false,
"EnableOutgoingNetworkMessageFiltering": true,
"EnableP2P": false,
"EnableP2PHybridMode": false,
"EnablePingHandler": true,
"EnablePrivateNetworkAccessHeader": false,
"EnableProcessBlockStats": false,
"EnableProfiler": false,
"EnableRequestLogger": false,
"EnableRuntimeMetrics": false,
"EnableTopAccountsReporting": false,
"EnableTxBacklogAppRateLimiting": true,
"EnableTxBacklogRateLimiting": true,
"EnableTxnEvalTracer": false,
"EnableUsageLog": false,
"EnableVerbosedTransactionSyncLogging": false,
"EndpointAddress": "127.0.0.1:0",
"FallbackDNSResolverAddress": "",
"ForceFetchTransactions": false,
"ForceRelayMessages": false,
"GoMemLimit": 0,
"GossipFanout": 4,
"HeartbeatUpdateInterval": 600,
"HotDataDir": "",
"IncomingConnectionsLimit": 2400,
"IncomingMessageFilterBucketCount": 5,
"IncomingMessageFilterBucketSize": 512,
"LedgerSynchronousMode": 2,
"LogArchiveDir": "",
"LogArchiveMaxAge": "",
"LogArchiveName": "node.archive.log",
"LogFileDir": "",
"LogSizeLimit": 1073741824,
"MaxAPIBoxPerApplication": 100000,
"MaxAPIResourcesPerAccount": 100000,
"MaxAcctLookback": 4,
"MaxBlockHistoryLookback": 0,
"MaxCatchpointDownloadDuration": 43200000000000,
"MaxConnectionsPerIP": 8,
"MinCatchpointFileDownloadBytesPerSecond": 20480,
"NetAddress": "",
"NetworkMessageTraceServer": "",
"NetworkProtocolVersion": "",
"NodeExporterListenAddress": ":9100",
"NodeExporterPath": "./node_exporter",
"OptimizeAccountsDatabaseOnStartup": false,
"OutgoingMessageFilterBucketCount": 3,
"OutgoingMessageFilterBucketSize": 128,
"P2PHybridIncomingConnectionsLimit": 1200,
"P2PHybridNetAddress": "",
"P2PPersistPeerID": false,
"P2PPrivateKeyLocation": "",
"ParticipationKeysRefreshInterval": 60000000000,
"PeerConnectionsUpdateInterval": 3600,
"PeerPingPeriodSeconds": 0,
"PriorityPeers": {},
"ProposalAssemblyTime": 500000000,
"PublicAddress": "",
"ReconnectTime": 60000000000,
"ReservedFDs": 256,
"RestConnectionsHardLimit": 2048,
"RestConnectionsSoftLimit": 1024,
"RestReadTimeoutSeconds": 15,
"RestWriteTimeoutSeconds": 120,
"RunHosted": false,
"StateproofDir": "",
"StorageEngine": "sqlite",
"SuggestedFeeBlockHistory": 3,
"SuggestedFeeSlidingWindowSize": 50,
"TLSCertFile": "",
"TLSKeyFile": "",
"TelemetryToLog": true,
"TrackerDBDir": "",
"TransactionSyncDataExchangeRate": 0,
"TransactionSyncSignificantMessageThreshold": 0,
"TxBacklogAppRateLimitingCountERLDrops": false,
"TxBacklogAppTxPerSecondRate": 100,
"TxBacklogAppTxRateLimiterMaxSize": 1048576,
"TxBacklogRateLimitingCongestionPct": 50,
"TxBacklogReservedCapacityPerPeer": 20,
"TxBacklogServiceRateWindowSeconds": 10,
"TxBacklogSize": 26000,
"TxIncomingFilterMaxSize": 500000,
"TxIncomingFilteringFlags": 1,
"TxPoolExponentialIncreaseFactor": 2,
"TxPoolSize": 75000,
"TxSyncIntervalSeconds": 60,
"TxSyncServeResponseSize": 1000000,
"TxSyncTimeoutSeconds": 30,
"UseXForwardedForAddressField": "",
"VerifiedTranscationsCacheSize": 150000
}
Loading
Loading