Skip to content

Commit d386d6e

Browse files
authored
feat: versioning of FP allowlist (#97)
## Description This is how snapshotitem looks like internally ``` Storage Key: "allowed_finality_providers" ┌─────────────────────────────────────────────────┐ │ Height 100: HashSet{fp1, fp2, fp3} │ │ Height 105: HashSet{fp1, fp2, fp4} │ │ Height 110: HashSet{fp1, fp4} │ └─────────────────────────────────────────────────┘ // Query Examples: get_at_height(102) → returns HashSet from height 100 (nearest ≤ 102) get_at_height(107) → returns HashSet from height 105 (nearest ≤ 107) ``` A new query is added which will be used by finality gadget ``` QueryMsg::AllowedFinalityProvidersAtHeight { babylon_height } => Ok(to_json_binary( &get_allowed_finality_providers_at_height(deps.storage, babylon_height)?, )?), ``` <!-- Brief description of changes --> ## Checklist - [x] I have updated the [docs/SPEC.md](https://github.com/babylonlabs-io/rollup-bsn-contracts/blob/main/docs/SPEC.md) file if this change affects the specification - [x] I have updated the schema by running `cargo gen-schema`
1 parent 853ea8f commit d386d6e

File tree

11 files changed

+438
-40
lines changed

11 files changed

+438
-40
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
4141

4242
* [82](https://github.com/babylonlabs-io/rollup-bsn-contracts/pull/82) feat: add
4343
bsn_activation_height and finality_signature_interval for spam protection
44+
* [97](https://github.com/babylonlabs-io/rollup-bsn-contracts/pull/97) feat:
45+
versioning of FP allowlist
4446

4547
### Improvements
4648

contracts/finality/schema/finality.json

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"instantiate": {
66
"$schema": "http://json-schema.org/draft-07/schema#",
77
"title": "InstantiateMsg",
8+
"description": "Contract instantiation message containing all configuration parameters.",
89
"type": "object",
910
"required": [
1011
"admin",
@@ -17,6 +18,7 @@
1718
],
1819
"properties": {
1920
"admin": {
21+
"description": "Initial admin address for the contract who can update settings",
2022
"type": "string"
2123
},
2224
"allowed_finality_providers": {
@@ -30,29 +32,35 @@
3032
}
3133
},
3234
"bsn_activation_height": {
35+
"description": "Rollup block height at which the BSN system is activated (0 = immediate activation). Only affects `SubmitFinalitySignature` messages.",
3336
"type": "integer",
3437
"format": "uint64",
3538
"minimum": 0.0
3639
},
3740
"bsn_id": {
41+
"description": "Unique identifier for the BSN (Bitcoin Supercharged Network) this contract secures",
3842
"type": "string"
3943
},
4044
"finality_signature_interval": {
45+
"description": "Interval between allowed finality signature submissions. Signatures can only be submitted at rollup block heights where `(height - bsn_activation_height) % interval == 0`.",
4146
"type": "integer",
4247
"format": "uint64",
4348
"minimum": 1.0
4449
},
4550
"max_msgs_per_interval": {
51+
"description": "Maximum messages allowed per finality provider per interval",
4652
"type": "integer",
4753
"format": "uint32",
4854
"minimum": 0.0
4955
},
5056
"min_pub_rand": {
57+
"description": "Minimum number of public randomness values required in commitments",
5158
"type": "integer",
5259
"format": "uint64",
5360
"minimum": 0.0
5461
},
5562
"rate_limiting_interval": {
63+
"description": "Number of Babylon blocks in each interval",
5664
"type": "integer",
5765
"format": "uint64",
5866
"minimum": 0.0
@@ -516,6 +524,30 @@
516524
}
517525
},
518526
"additionalProperties": false
527+
},
528+
{
529+
"description": "Get the list of allowed finality providers at a specific Babylon height.\n\nReturns a list of BTC public keys (in hex format) that were allowed at the specified Babylon height or the most recent height before it.",
530+
"type": "object",
531+
"required": [
532+
"allowed_finality_providers_at_height"
533+
],
534+
"properties": {
535+
"allowed_finality_providers_at_height": {
536+
"type": "object",
537+
"required": [
538+
"babylon_height"
539+
],
540+
"properties": {
541+
"babylon_height": {
542+
"type": "integer",
543+
"format": "uint64",
544+
"minimum": 0.0
545+
}
546+
},
547+
"additionalProperties": false
548+
}
549+
},
550+
"additionalProperties": false
519551
}
520552
]
521553
},
@@ -551,6 +583,14 @@
551583
"type": "string"
552584
}
553585
},
586+
"allowed_finality_providers_at_height": {
587+
"$schema": "http://json-schema.org/draft-07/schema#",
588+
"title": "Array_of_String",
589+
"type": "array",
590+
"items": {
591+
"type": "string"
592+
}
593+
},
554594
"block_voters": {
555595
"$schema": "http://json-schema.org/draft-07/schema#",
556596
"title": "Array_of_BlockVoterInfo",
@@ -618,6 +658,7 @@
618658
"config": {
619659
"$schema": "http://json-schema.org/draft-07/schema#",
620660
"title": "Config",
661+
"description": "Contract configuration parameters set at instantiation.",
621662
"type": "object",
622663
"required": [
623664
"bsn_activation_height",
@@ -628,25 +669,34 @@
628669
],
629670
"properties": {
630671
"bsn_activation_height": {
672+
"description": "Rollup block height at which the BSN system is activated (0 = immediate activation). Only affects `SubmitFinalitySignature` messages.",
631673
"type": "integer",
632674
"format": "uint64",
633675
"minimum": 0.0
634676
},
635677
"bsn_id": {
678+
"description": "Unique identifier for the BSN (Bitcoin Supercharged Network) that this contract secures",
636679
"type": "string"
637680
},
638681
"finality_signature_interval": {
682+
"description": "Interval between allowed finality signature submissions. Signatures can only be submitted at rollup block heights where `(height - bsn_activation_height) % interval == 0`.",
639683
"type": "integer",
640684
"format": "uint64",
641685
"minimum": 1.0
642686
},
643687
"min_pub_rand": {
688+
"description": "Minimum number of public randomness values required in commitments",
644689
"type": "integer",
645690
"format": "uint64",
646691
"minimum": 0.0
647692
},
648693
"rate_limiting": {
649-
"$ref": "#/definitions/RateLimitingConfig"
694+
"description": "Rate limiting configuration to prevent spam",
695+
"allOf": [
696+
{
697+
"$ref": "#/definitions/RateLimitingConfig"
698+
}
699+
]
650700
}
651701
},
652702
"additionalProperties": false,

contracts/finality/schema/raw/instantiate.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "InstantiateMsg",
4+
"description": "Contract instantiation message containing all configuration parameters.",
45
"type": "object",
56
"required": [
67
"admin",
@@ -13,6 +14,7 @@
1314
],
1415
"properties": {
1516
"admin": {
17+
"description": "Initial admin address for the contract who can update settings",
1618
"type": "string"
1719
},
1820
"allowed_finality_providers": {
@@ -26,29 +28,35 @@
2628
}
2729
},
2830
"bsn_activation_height": {
31+
"description": "Rollup block height at which the BSN system is activated (0 = immediate activation). Only affects `SubmitFinalitySignature` messages.",
2932
"type": "integer",
3033
"format": "uint64",
3134
"minimum": 0.0
3235
},
3336
"bsn_id": {
37+
"description": "Unique identifier for the BSN (Bitcoin Supercharged Network) this contract secures",
3438
"type": "string"
3539
},
3640
"finality_signature_interval": {
41+
"description": "Interval between allowed finality signature submissions. Signatures can only be submitted at rollup block heights where `(height - bsn_activation_height) % interval == 0`.",
3742
"type": "integer",
3843
"format": "uint64",
3944
"minimum": 1.0
4045
},
4146
"max_msgs_per_interval": {
47+
"description": "Maximum messages allowed per finality provider per interval",
4248
"type": "integer",
4349
"format": "uint32",
4450
"minimum": 0.0
4551
},
4652
"min_pub_rand": {
53+
"description": "Minimum number of public randomness values required in commitments",
4754
"type": "integer",
4855
"format": "uint64",
4956
"minimum": 0.0
5057
},
5158
"rate_limiting_interval": {
59+
"description": "Number of Babylon blocks in each interval",
5260
"type": "integer",
5361
"format": "uint64",
5462
"minimum": 0.0

contracts/finality/schema/raw/query.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,30 @@
156156
}
157157
},
158158
"additionalProperties": false
159+
},
160+
{
161+
"description": "Get the list of allowed finality providers at a specific Babylon height.\n\nReturns a list of BTC public keys (in hex format) that were allowed at the specified Babylon height or the most recent height before it.",
162+
"type": "object",
163+
"required": [
164+
"allowed_finality_providers_at_height"
165+
],
166+
"properties": {
167+
"allowed_finality_providers_at_height": {
168+
"type": "object",
169+
"required": [
170+
"babylon_height"
171+
],
172+
"properties": {
173+
"babylon_height": {
174+
"type": "integer",
175+
"format": "uint64",
176+
"minimum": 0.0
177+
}
178+
},
179+
"additionalProperties": false
180+
}
181+
},
182+
"additionalProperties": false
159183
}
160184
]
161185
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Array_of_String",
4+
"type": "array",
5+
"items": {
6+
"type": "string"
7+
}
8+
}

contracts/finality/schema/raw/response_to_config.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "Config",
4+
"description": "Contract configuration parameters set at instantiation.",
45
"type": "object",
56
"required": [
67
"bsn_activation_height",
@@ -11,25 +12,34 @@
1112
],
1213
"properties": {
1314
"bsn_activation_height": {
15+
"description": "Rollup block height at which the BSN system is activated (0 = immediate activation). Only affects `SubmitFinalitySignature` messages.",
1416
"type": "integer",
1517
"format": "uint64",
1618
"minimum": 0.0
1719
},
1820
"bsn_id": {
21+
"description": "Unique identifier for the BSN (Bitcoin Supercharged Network) that this contract secures",
1922
"type": "string"
2023
},
2124
"finality_signature_interval": {
25+
"description": "Interval between allowed finality signature submissions. Signatures can only be submitted at rollup block heights where `(height - bsn_activation_height) % interval == 0`.",
2226
"type": "integer",
2327
"format": "uint64",
2428
"minimum": 1.0
2529
},
2630
"min_pub_rand": {
31+
"description": "Minimum number of public randomness values required in commitments",
2732
"type": "integer",
2833
"format": "uint64",
2934
"minimum": 0.0
3035
},
3136
"rate_limiting": {
32-
"$ref": "#/definitions/RateLimitingConfig"
37+
"description": "Rate limiting configuration to prevent spam",
38+
"allOf": [
39+
{
40+
"$ref": "#/definitions/RateLimitingConfig"
41+
}
42+
]
3343
}
3444
},
3545
"additionalProperties": false,

0 commit comments

Comments
 (0)