Skip to content

Commit

Permalink
R/finality contract (#65)
Browse files Browse the repository at this point in the history
Part of #11. Closes #52.
  • Loading branch information
maurolacy authored Sep 25, 2024
1 parent 83b5096 commit 70b6af6
Show file tree
Hide file tree
Showing 72 changed files with 6,519 additions and 2,606 deletions.
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

0 comments on commit 70b6af6

Please sign in to comment.