Skip to content

Commit

Permalink
F/slashing propagation 2 (#45)
Browse files Browse the repository at this point in the history
Slashing propagation follow-up.

Sends the IBC slashing payload message in `protobuf` format
  • Loading branch information
maurolacy authored Aug 28, 2024
1 parent 7463460 commit 0bd3e09
Show file tree
Hide file tree
Showing 16 changed files with 310 additions and 173 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[submodule "babylon"]
[submodule "packages/proto/babylon"]
path = packages/proto/babylon
url = [email protected]:babylonlabs-io/babylon.git
branch = dev
[submodule "babylon-private"]
[submodule "packages/proto/babylon-private"]
path = packages/proto/babylon-private
url = [email protected]:babylonlabs-io/babylon-private.git
branch = base/consumer-chain-support
133 changes: 107 additions & 26 deletions contracts/babylon/schema/babylon-contract.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@
"format": "uint64",
"minimum": 0.0
},
"consumer_description": {
"description": "Description of the consumer",
"type": [
"string",
"null"
]
},
"consumer_name": {
"description": "Name of the consumer",
"type": [
"string",
"null"
]
},
"network": {
"$ref": "#/definitions/Network"
},
Expand Down Expand Up @@ -118,34 +132,11 @@
"slashing": {
"type": "object",
"required": [
"block_height",
"fp_btc_pk",
"secret_key"
"evidence"
],
"properties": {
"block_height": {
"description": "`block_height` is the Consumer blockchain slashing height",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"fp_btc_pk": {
"description": "`fp_btc_pk` is the BTC PK of the slashed finality provider",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"secret_key": {
"description": "`secret_key` is the secret key extracted from the slashing evidence",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
"evidence": {
"$ref": "#/definitions/Evidence"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -199,6 +190,82 @@
}
},
"additionalProperties": false
},
"Evidence": {
"description": "Evidence is the evidence that a finality provider has signed finality signatures with correct public randomness on two conflicting Babylon headers",
"type": "object",
"required": [
"block_height",
"canonical_app_hash",
"canonical_finality_sig",
"fork_app_hash",
"fork_finality_sig",
"fp_btc_pk",
"pub_rand"
],
"properties": {
"block_height": {
"description": "`block_height` is the height of the conflicting blocks",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"canonical_app_hash": {
"description": "`canonical_app_hash` is the AppHash of the canonical block",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"canonical_finality_sig": {
"description": "`canonical_finality_sig` is the finality signature to the canonical block, where finality signature is an EOTS signature, i.e., the `s` in a Schnorr signature `(r, s)`. `r` is the public randomness already committed by the finality provider. Deserializes to `SchnorrEOTSSig`",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"fork_app_hash": {
"description": "`fork_app_hash` is the AppHash of the fork block",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"fork_finality_sig": {
"description": "`fork_finality_sig` is the finality signature to the fork block, where finality signature is an EOTS signature. Deserializes to `SchnorrEOTSSig`",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"fp_btc_pk": {
"description": "`fp_btc_pk` is the BTC PK of the finality provider that casts this vote",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"pub_rand": {
"description": "`pub_rand is` the public randomness the finality provider has committed to. Deserializes to `SchnorrPubRand`",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
}
},
"additionalProperties": false
}
}
},
Expand Down Expand Up @@ -1230,6 +1297,20 @@
"format": "uint64",
"minimum": 0.0
},
"consumer_description": {
"description": "Consumer description",
"type": [
"string",
"null"
]
},
"consumer_name": {
"description": "Consumer name",
"type": [
"string",
"null"
]
},
"network": {
"$ref": "#/definitions/Network"
},
Expand Down
105 changes: 79 additions & 26 deletions contracts/babylon/schema/raw/execute.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,11 @@
"slashing": {
"type": "object",
"required": [
"block_height",
"fp_btc_pk",
"secret_key"
"evidence"
],
"properties": {
"block_height": {
"description": "`block_height` is the Consumer blockchain slashing height",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"fp_btc_pk": {
"description": "`fp_btc_pk` is the BTC PK of the slashed finality provider",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"secret_key": {
"description": "`secret_key` is the secret key extracted from the slashing evidence",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
"evidence": {
"$ref": "#/definitions/Evidence"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -118,6 +95,82 @@
}
},
"additionalProperties": false
},
"Evidence": {
"description": "Evidence is the evidence that a finality provider has signed finality signatures with correct public randomness on two conflicting Babylon headers",
"type": "object",
"required": [
"block_height",
"canonical_app_hash",
"canonical_finality_sig",
"fork_app_hash",
"fork_finality_sig",
"fp_btc_pk",
"pub_rand"
],
"properties": {
"block_height": {
"description": "`block_height` is the height of the conflicting blocks",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"canonical_app_hash": {
"description": "`canonical_app_hash` is the AppHash of the canonical block",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"canonical_finality_sig": {
"description": "`canonical_finality_sig` is the finality signature to the canonical block, where finality signature is an EOTS signature, i.e., the `s` in a Schnorr signature `(r, s)`. `r` is the public randomness already committed by the finality provider. Deserializes to `SchnorrEOTSSig`",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"fork_app_hash": {
"description": "`fork_app_hash` is the AppHash of the fork block",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"fork_finality_sig": {
"description": "`fork_finality_sig` is the finality signature to the fork block, where finality signature is an EOTS signature. Deserializes to `SchnorrEOTSSig`",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"fp_btc_pk": {
"description": "`fp_btc_pk` is the BTC PK of the finality provider that casts this vote",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
},
"pub_rand": {
"description": "`pub_rand is` the public randomness the finality provider has committed to. Deserializes to `SchnorrPubRand`",
"type": "array",
"items": {
"type": "integer",
"format": "uint8",
"minimum": 0.0
}
}
},
"additionalProperties": false
}
}
}
14 changes: 14 additions & 0 deletions contracts/babylon/schema/raw/instantiate.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@
"format": "uint64",
"minimum": 0.0
},
"consumer_description": {
"description": "Description of the consumer",
"type": [
"string",
"null"
]
},
"consumer_name": {
"description": "Name of the consumer",
"type": [
"string",
"null"
]
},
"network": {
"$ref": "#/definitions/Network"
},
Expand Down
14 changes: 14 additions & 0 deletions contracts/babylon/schema/raw/response_to_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@
"format": "uint64",
"minimum": 0.0
},
"consumer_description": {
"description": "Consumer description",
"type": [
"string",
"null"
]
},
"consumer_name": {
"description": "Consumer name",
"type": [
"string",
"null"
]
},
"network": {
"$ref": "#/definitions/Network"
},
Expand Down
9 changes: 2 additions & 7 deletions contracts/babylon/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,7 @@ pub fn execute(
// TODO: Add events
Ok(Response::new())
}
ExecuteMsg::Slashing {
fp_btc_pk,
block_height,
secret_key,
} => {
ExecuteMsg::Slashing { evidence } => {
// This is an internal routing message from the `btc-staking` contract
// Check sender
let btc_staking = CONFIG
Expand All @@ -186,8 +182,7 @@ pub fn execute(
}
// Send over IBC to the Provider (Babylon)
let channel = IBC_CHANNEL.load(deps.storage)?;
let msg =
ibc_packet::slashing_msg(&env, &channel, &fp_btc_pk, block_height, &secret_key)?;
let msg = ibc_packet::slashing_msg(&env, &channel, &evidence)?;
// TODO: Add events
Ok(Response::new().add_message(msg))
}
Expand Down
Loading

0 comments on commit 0bd3e09

Please sign in to comment.