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

R/finality contract #65

Merged
merged 51 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
21760a8
Move active fps calca to finality mod
Sep 11, 2024
7892932
Fix: Non-zero fp voting power check
Sep 11, 2024
ab5e5ea
Move FP_SET to finality state where it belongs
Sep 12, 2024
12f826d
Split staking and finality execution handlers
Sep 12, 2024
5ee7987
Move finality stuff out of btc-staking and into babylon-finality
Sep 12, 2024
c56df77
Add babylon-finality contract (WIP)
Sep 13, 2024
806409e
Fix rebase errors
Sep 15, 2024
44f1919
Remove sudo handlers from the staking contract
Sep 15, 2024
3177ada
Add staking slash handler / msg
Sep 15, 2024
065e1ef
Refactor: use staking queries, and batched active FPs processing
Sep 16, 2024
b09b542
cargo fmt
Sep 16, 2024
262b4a4
Add babylon contract version to store in passing
Sep 17, 2024
63cdd1f
Add finality contract instantiation
Sep 17, 2024
4b6bd78
Remove finality dependendency
Sep 17, 2024
feed346
Rename to btc-finality for consistency
Sep 17, 2024
246ea4b
Refactor: route slashing through babylon only
Sep 17, 2024
a145f7e
Fix: proper routing / auth of slashing message
Sep 17, 2024
7d4c030
Update / Set staking address during finality contract instantiation
Sep 17, 2024
16e94f5
Fix / adapt benches
Sep 18, 2024
066ea79
Improve / adjust size checks
Sep 18, 2024
49b6ec8
Fix / adjust staking tests
Sep 18, 2024
3562f8b
Remove unused structs
Sep 18, 2024
95ff295
Make test helpers public
Sep 18, 2024
4e43626
Update schema
Sep 18, 2024
0938d3b
Fix: tests compilation / imports
Sep 18, 2024
00efde3
Ignore broken (no multi-test) tests
Sep 18, 2024
d3aece7
Fix / unify schema bin names
Sep 18, 2024
6124b93
Update btc-finality schemas
Sep 18, 2024
9af350c
Add btc-finality to CI releases
Sep 18, 2024
a7a03ad
Add btc-finality integration tests
Sep 18, 2024
21a72d9
Add btc finality to init tests
Sep 20, 2024
4646f1e
Add multitest to btc-finality
Sep 22, 2024
7a4c1e9
Add convenience contracts fields to suite
Sep 23, 2024
2f6583e
Remove unused funds
Sep 23, 2024
dfc0589
Add public randomness commitment mt
Sep 23, 2024
c6935e0
Fix: FP smart query results processing
Sep 23, 2024
8d7f357
Remove original test
Sep 23, 2024
6c34f64
Add TODO
Sep 23, 2024
14cdb0d
Move sudo msg from staking to finality
Sep 23, 2024
3380a9d
Add new at height app ctor
Sep 23, 2024
1f9f05c
Add finality sig happy path mt
Sep 23, 2024
af7c705
Add test modules for clarity
Sep 23, 2024
5c339e3
Add finality round works mt
Sep 23, 2024
bca20d1
Add slashing works mt
Sep 24, 2024
543e639
Remove original finality (no mt) tests
Sep 24, 2024
4bdc93a
Fix: slashing test
Sep 24, 2024
5380765
Feature gate / disable IBC messages for (multi-)tests
Sep 24, 2024
8b1ccf5
Fix: Avoid full-validation failure / bug in CI
Sep 24, 2024
be727ae
Remove (unused) denom from config
Sep 24, 2024
e0af2d9
Remove (unused / redundant) params from staking params
Sep 24, 2024
05438bb
Update schema
Sep 24, 2024
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
15 changes: 14 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
path: |-
artifacts/babylon_contract.wasm
artifacts/btc_staking.wasm
artifacts/btc_finality.wasm
artifacts/checksums.txt
- name: Show data
run: |-
Expand All @@ -35,6 +36,7 @@ jobs:
run: |-
zip artifacts/babylon_contract.wasm.zip artifacts/babylon_contract.wasm
zip artifacts/btc_staking.wasm.zip artifacts/btc_staking.wasm
zip artifacts/btc_finality.wasm.zip artifacts/btc_finality.wasm
zip artifacts/op_finality_gadget.wasm.zip artifacts/op_finality_gadget.wasm
- name: Create a Release
id: create-release
Expand Down Expand Up @@ -68,6 +70,16 @@ jobs:
asset_path: ./artifacts/btc_staking.wasm.zip
asset_name: btc_staking.wasm.zip
asset_content_type: application/zip
- name: Upload btc_finality
id: upload-btc_finality
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./artifacts/btc_finality.wasm.zip
asset_name: btc_finality.wasm.zip
asset_content_type: application/zip
- name: Upload op_finality_gadget
id: upload-op_finality_gadget
uses: actions/upload-release-asset@v1
Expand All @@ -91,7 +103,8 @@ jobs:
- name: Build and run schema generator
run: |-
(cd ./contracts/babylon && cargo run --bin schema)
(cd ./contracts/btc-staking && cargo run --bin btcstaking-schema)
(cd ./contracts/btc-staking && cargo run --bin btc-staking-schema)
(cd ./contracts/btc-finality && cargo run --bin btc-finality-schema)
- name: Consolidate schemas
run: |-
mkdir -p ./schemas
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/local-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,13 @@ jobs:
image: rust:1.78.0
steps:
- uses: actions/[email protected]
- name: Build contracts, check formats, and run unit tests (with full validation)
run: cargo test --lib --features full-validation
- name: Build contracts, check formats, and run unit tests
run: cargo test --lib
local-build-test-full-validation:
runs-on: ubuntu-latest
container:
image: rust:1.78.0
steps:
- uses: actions/[email protected]
- name: Build contracts, check formats, and run unit tests (full validation)
run: cargo test --package btc-staking --lib --features full-validation
1 change: 1 addition & 0 deletions .github/workflows/wasm-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ jobs:
path: |-
artifacts/babylon_contract.wasm
artifacts/btc_staking.wasm
artifacts/btc_finality.wasm
37 changes: 37 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions contracts/babylon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ babylon-bitcoin = { path = "../../packages/bitcoin" }
blst = { workspace = true }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw2 = { workspace = true }
cw-storage-plus = { workspace = true }
cw-utils = { workspace = true }
hex = { workspace = true }
Expand All @@ -49,6 +50,7 @@ ics23 = { workspace = true }
[dev-dependencies]
babylon-bindings-test = { path = "../../packages/bindings-test" }
btc-staking = { path = "../btc-staking", features = [ "library" ] }
btc-finality = { path = "../btc-finality", features = [ "library" ] }
test-utils = { path = "../../packages/test-utils" }

cosmwasm-vm = { workspace = true }
Expand Down
2 changes: 2 additions & 0 deletions contracts/babylon/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pub fn setup_instance() -> Instance<MockApi, MockStorage, MockQuerier> {
notify_cosmos_zone: false,
btc_staking_code_id: None,
btc_staking_msg: None,
btc_finality_code_id: None,
btc_finality_msg: None,
admin: None,
};
let info = mock_info(CREATOR, &[]);
Expand Down
37 changes: 35 additions & 2 deletions contracts/babylon/schema/babylon-contract.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"properties": {
"admin": {
"description": "If set, this will be the Wasm migration / upgrade admin of the BTC staking contract",
"description": "If set, this will be the Wasm migration / upgrade admin of the BTC staking contract and the BTC finality contract",
"type": [
"string",
"null"
Expand All @@ -30,6 +30,26 @@
"format": "uint64",
"minimum": 0.0
},
"btc_finality_code_id": {
"description": "If set, this will instantiate a BTC finality contract",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"btc_finality_msg": {
"description": "If set, this will define the instantiation message for the BTC finality contract. This message is opaque to the Babylon contract, and depends on the specific finality contract being instantiated",
"anyOf": [
{
"$ref": "#/definitions/Binary"
},
{
"type": "null"
}
]
},
"btc_staking_code_id": {
"description": "If set, this will instantiate a BTC staking contract for BTC re-staking",
"type": [
Expand All @@ -40,7 +60,7 @@
"minimum": 0.0
},
"btc_staking_msg": {
"description": "If set, this will define the instantiate message for the BTC staking contract. This message is opaque to the Babylon contract, and depends on the specific staking contract being instantiated",
"description": "If set, this will define the instantiation message for the BTC staking contract. This message is opaque to the Babylon contract, and depends on the specific staking contract being instantiated",
"anyOf": [
{
"$ref": "#/definitions/Binary"
Expand Down Expand Up @@ -73,6 +93,7 @@
"$ref": "#/definitions/Network"
},
"notify_cosmos_zone": {
"description": "notify_cosmos_zone indicates whether to send Cosmos zone messages notifying BTC-finalised headers. NOTE: If set to true, then the Cosmos zone needs to integrate the corresponding message handler as well",
"type": "boolean"
}
},
Expand Down Expand Up @@ -1281,6 +1302,17 @@
"format": "uint64",
"minimum": 0.0
},
"btc_finality": {
"description": "If set, this stores a BTC finality contract used for BTC finality on the Consumer",
"anyOf": [
{
"$ref": "#/definitions/Addr"
},
{
"type": "null"
}
]
},
"btc_staking": {
"description": "If set, this stores a BTC staking contract used for BTC re-staking",
"anyOf": [
Expand Down Expand Up @@ -1315,6 +1347,7 @@
"$ref": "#/definitions/Network"
},
"notify_cosmos_zone": {
"description": "notify_cosmos_zone indicates whether to send Cosmos zone messages notifying BTC-finalised headers. NOTE: if set to true, then the Cosmos zone needs to integrate the corresponding message handler as well",
"type": "boolean"
}
},
Expand Down
25 changes: 23 additions & 2 deletions contracts/babylon/schema/raw/instantiate.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"properties": {
"admin": {
"description": "If set, this will be the Wasm migration / upgrade admin of the BTC staking contract",
"description": "If set, this will be the Wasm migration / upgrade admin of the BTC staking contract and the BTC finality contract",
"type": [
"string",
"null"
Expand All @@ -26,6 +26,26 @@
"format": "uint64",
"minimum": 0.0
},
"btc_finality_code_id": {
"description": "If set, this will instantiate a BTC finality contract",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"btc_finality_msg": {
"description": "If set, this will define the instantiation message for the BTC finality contract. This message is opaque to the Babylon contract, and depends on the specific finality contract being instantiated",
"anyOf": [
{
"$ref": "#/definitions/Binary"
},
{
"type": "null"
}
]
},
"btc_staking_code_id": {
"description": "If set, this will instantiate a BTC staking contract for BTC re-staking",
"type": [
Expand All @@ -36,7 +56,7 @@
"minimum": 0.0
},
"btc_staking_msg": {
"description": "If set, this will define the instantiate message for the BTC staking contract. This message is opaque to the Babylon contract, and depends on the specific staking contract being instantiated",
"description": "If set, this will define the instantiation message for the BTC staking contract. This message is opaque to the Babylon contract, and depends on the specific staking contract being instantiated",
"anyOf": [
{
"$ref": "#/definitions/Binary"
Expand Down Expand Up @@ -69,6 +89,7 @@
"$ref": "#/definitions/Network"
},
"notify_cosmos_zone": {
"description": "notify_cosmos_zone indicates whether to send Cosmos zone messages notifying BTC-finalised headers. NOTE: If set to true, then the Cosmos zone needs to integrate the corresponding message handler as well",
"type": "boolean"
}
},
Expand Down
12 changes: 12 additions & 0 deletions contracts/babylon/schema/raw/response_to_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@
"format": "uint64",
"minimum": 0.0
},
"btc_finality": {
"description": "If set, this stores a BTC finality contract used for BTC finality on the Consumer",
"anyOf": [
{
"$ref": "#/definitions/Addr"
},
{
"type": "null"
}
]
},
"btc_staking": {
"description": "If set, this stores a BTC staking contract used for BTC re-staking",
"anyOf": [
Expand Down Expand Up @@ -57,6 +68,7 @@
"$ref": "#/definitions/Network"
},
"notify_cosmos_zone": {
"description": "notify_cosmos_zone indicates whether to send Cosmos zone messages notifying BTC-finalised headers. NOTE: if set to true, then the Cosmos zone needs to integrate the corresponding message handler as well",
"type": "boolean"
}
},
Expand Down
Loading