-
Notifications
You must be signed in to change notification settings - Fork 0
Align sequence locks and unknown covenant handling with hsd #53
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,9 @@ const ( | |
| maxNameSize = 63 | ||
| maxResourceSize = 512 | ||
|
|
||
| maxCovenantItems = 1000 | ||
| maxCovenantSize = 1 + 32 + 1 + 4 + 2 + maxResourceSize + 1 + 32 | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Search for maxCovenantSize or maxResourceSize definitions and usage
rg -nP 'maxCovenantSize|maxResourceSize' blockchain/names.go
rg -nP 'maxCovenantItems' blockchain/ wire/Repository: blinklabs-io/handshake-node Length of output: 1251 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the relevant logic in the local repository.
sed -n '1,120p' blockchain/names.go
printf '\n---\n'
sed -n '860,910p' blockchain/names.go
printf '\n---\n'
sed -n '1,220p' wire/covenant.goRepository: blinklabs-io/handshake-node Length of output: 9338 🌐 Web query:
💡 Result: In the hsd implementation of the Handshake protocol, covenant size limits are governed by constants defined in lib/covenants/rules.js [1][2]. The relevant consensus-related constraints are: MAX_RESOURCE_SIZE: This is set to 512 bytes [1][2]. It defines the maximum allowed size for record data within a covenant (specifically used for items[2] in a covenant) [1][2][3]. MAX_COVENANT_SIZE: This represents the maximum total serialized size of a covenant [1][2]. It is calculated as a constant expression: 2 + MAX_RESOURCE_SIZE + 1 + 32 [1][2]. Given MAX_RESOURCE_SIZE is 512, this results in a maximum size of 547 bytes [1][2]. These rules are enforced during transaction validation to ensure that covenant data, such as DNS resource records, remains within the defined protocol constraints [1][2][3]. While consensus.js manages network-wide constants like block size (1,000,000 bytes) [4][5], the covenant-specific limits are handled within the covenants module to maintain naming system integrity [6][7]. Citations:
🌐 Web query:
💡 Result: In the hsd library, the file lib/covenants/rules.js manages protocol limits for Handshake name covenants [1][2]. The constants MAX_COVENANT_SIZE and MAX_RESOURCE_SIZE are defined to enforce consensus rules regarding the size of covenants and their embedded resource data [1][3]. MAX_RESOURCE_SIZE is the limit on the size of record data within a covenant. Historically, this limit was 512 bytes [1][3]. Following a protocol hard fork (as noted in recent updates), this limit has been increased to 8,192 bytes to accommodate richer zone files [3][4]. The calculation for MAX_COVENANT_SIZE is defined in the source code as: rules.MAX_COVENANT_SIZE = (0 + 1 + 32 + 2 + rules.MAX_RESOURCE_SIZE + 1 + 32); In this formula, the components represent: - 1: A byte for the covenant type. - 32: A 32-byte hash (typically the name hash). - 2: An overhead allowance (or specific protocol field allocation). - rules.MAX_RESOURCE_SIZE: The maximum size permitted for the resource record data [1][5]. - 1 + 32: Additional structural or metadata padding used in the covenant serialization [1][6]. Essentially, the total covenant size limit is derived from the sum of these fixed-size fields plus the current maximum allowed resource size [1]. Enforcement of these limits occurs during block validation, where the system checks both the length of specific items (like record data) and the total size of the covenant object using these defined constants [1][3]. Citations:
Align 🤖 Prompt for AI Agents |
||
| maxBlockNameOpens = 300 | ||
| maxBlockNameUpdates = 600 | ||
| maxBlockNameRenewals = 600 | ||
|
|
@@ -868,13 +871,33 @@ func checkCovenantSanity(tx *hnsutil.Tx) error { | |
| return err | ||
| } | ||
| default: | ||
| return badCovenant("unknown covenant type") | ||
| if err := checkUnknownCovenant(covenant); err != nil { | ||
| return err | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func checkUnknownCovenant(covenant wire.Covenant) error { | ||
| if len(covenant.Items) > maxCovenantItems { | ||
| return badCovenant("unknown covenant has too many items") | ||
| } | ||
| if covenantItemsSize(covenant) > maxCovenantSize { | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
|
||
| return badCovenant("unknown covenant is too large") | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func covenantItemsSize(covenant wire.Covenant) int { | ||
| size := 0 | ||
| for _, item := range covenant.Items { | ||
| size += wire.VarIntSerializeSize(uint64(len(item))) + len(item) | ||
| } | ||
| return size | ||
| } | ||
|
|
||
| func checkTransactionNameLimits(tx *hnsutil.Tx) error { | ||
| var opens, updates, renewals int | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.