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

F/rewards distribution send #96

Merged
merged 29 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
863a5c3
Add send rewards distribution over FPs
Dec 5, 2024
a590c9a
Send rewards over IBC using ICS20 transfer
Dec 9, 2024
7054fc4
Update schema
Dec 11, 2024
7c7981a
Fix: don't fail if no rewards
Dec 17, 2024
fde567b
Point babylon to consumer-reward-distribution dev branch
Dec 17, 2024
454b9c2
Update / sync buf deps
Dec 17, 2024
7a99c6b
Update babylon consumer-reward-distribution dev branch reverted broke…
Dec 17, 2024
79587bd
Remove nort found / reverted MsgEquivocationEvidence
Dec 17, 2024
76eb939
Add extern path rewrite / mapping rule for ibc
Dec 17, 2024
15cec6a
Update genrated files
Dec 17, 2024
c462edb
Add error handler for IBC consumer fp distribution recv
Dec 17, 2024
4ab5e9d
Fix: Rewards distribution amount
Dec 18, 2024
7ecfb9c
Update babylon ref to latest base
Dec 18, 2024
6a0ab48
Revert "Remove nort found / reverted MsgEquivocationEvidence"
Dec 18, 2024
97d57d9
Update babylon to f/consumer-reward-distribution dev branch
Dec 18, 2024
d0a0711
Update generated protos
Dec 18, 2024
f20b71e
Add some staking and finality contract instantiation tests
Dec 19, 2024
166fb6b
Improve staking doc strings
Dec 19, 2024
a49f793
Increase max wasm size limit check
Dec 19, 2024
f8397f4
Hardcoded IBC ICS20 channel info for tests
Dec 22, 2024
1582220
Hard-code babylon module (zoneconcierge) address
Dec 23, 2024
7f4daac
Add module_address and to_bech32 helpers
Dec 24, 2024
b55f8df
Implement transfer info parameter / option / query
Jan 3, 2025
cef1f1b
Move addr utils / helpers to apis
Jan 3, 2025
3cb2647
cargo clippy fixes in passing
Jan 3, 2025
beab17c
Fix: babylon contract instantiation in mt
Jan 3, 2025
27bb35a
Refactor to use addr helpers from api
Jan 3, 2025
f509d7e
Update lock file
Jan 3, 2025
f42067d
Update schemas
Jan 3, 2025
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
2 changes: 2 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ babylon-btcstaking = { path = "./packages/btcstaking" }
babylon-contract = { path = "./contracts/babylon" }
eots = { path = "./packages/eots" }
anyhow = "1.0.82"
bech32 = "0.9.1"
bitcoin = "0.31.1"
bitvec = "1"
bech32 = "0.9.1"
blst = "0.3.11"
cosmos-sdk-proto = { version = "0.19.0", default-features = false, features = [
"cosmwasm",
Expand Down
1 change: 1 addition & 0 deletions contracts/babylon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ cosmos-sdk-proto = { workspace = true }
thiserror = { workspace = true }
prost = { workspace = true }
ics23 = { workspace = true }
sha2 = { workspace = true }

[dev-dependencies]
babylon-bindings-test = { path = "../../packages/bindings-test" }
Expand Down
1 change: 1 addition & 0 deletions contracts/babylon/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub fn setup_instance() -> Instance<MockApi, MockStorage, MockQuerier> {
btc_finality_code_id: None,
btc_finality_msg: None,
admin: None,
transfer_info: None,
};
let info = mock_info(CREATOR, &[]);
let res: Response = instantiate(&mut deps, mock_env(), info, msg).unwrap();
Expand Down
154 changes: 154 additions & 0 deletions contracts/babylon/schema/babylon-contract.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@
"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"
},
"transfer_info": {
"description": "IBC information for ICS-020 rewards transfer. If not set, distributed rewards will be native to the Consumer",
"anyOf": [
{
"$ref": "#/definitions/IbcTransferInfo"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false,
Expand All @@ -103,6 +114,22 @@
"description": "Binary is a wrapper around Vec<u8> to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec<u8>. See also <https://github.com/CosmWasm/cosmwasm/blob/main/docs/MESSAGE_TYPES.md>.",
"type": "string"
},
"IbcTransferInfo": {
"type": "object",
"required": [
"channel_id",
"recipient"
],
"properties": {
"channel_id": {
"type": "string"
},
"recipient": {
"$ref": "#/definitions/Recipient"
}
},
"additionalProperties": false
},
"Network": {
"type": "string",
"enum": [
Expand All @@ -111,6 +138,34 @@
"signet",
"regtest"
]
},
"Recipient": {
"oneOf": [
{
"type": "object",
"required": [
"contract_addr"
],
"properties": {
"contract_addr": {
"type": "string"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"module_addr"
],
"properties": {
"module_addr": {
"type": "string"
}
},
"additionalProperties": false
}
]
}
}
},
Expand Down Expand Up @@ -164,6 +219,32 @@
}
},
"additionalProperties": false
},
{
"description": "`SendRewards` is a message sent by the finality contract, to send rewards to Babylon",
"type": "object",
"required": [
"send_rewards"
],
"properties": {
"send_rewards": {
"type": "object",
"required": [
"fp_distribution"
],
"properties": {
"fp_distribution": {
"description": "`fp_distribution` is the list of finality providers and their rewards",
"type": "array",
"items": {
"$ref": "#/definitions/RewardsDistribution"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
],
"definitions": {
Expand Down Expand Up @@ -287,6 +368,26 @@
}
},
"additionalProperties": false
},
"RewardsDistribution": {
"type": "object",
"required": [
"fp_pubkey_hex",
"reward"
],
"properties": {
"fp_pubkey_hex": {
"type": "string"
},
"reward": {
"$ref": "#/definitions/Uint128"
}
},
"additionalProperties": false
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
}
}
},
Expand Down Expand Up @@ -533,6 +634,20 @@
}
},
"additionalProperties": false
},
{
"description": "TransferInfo returns the IBC transfer information stored in the contract for ICS-020 rewards transfer. If not set, distributed rewards are native to the Consumer",
"type": "object",
"required": [
"transfer_info"
],
"properties": {
"transfer_info": {
"type": "object",
"additionalProperties": false
}
},
"additionalProperties": false
}
]
},
Expand Down Expand Up @@ -1286,6 +1401,7 @@
"babylon_tag",
"btc_confirmation_depth",
"checkpoint_finalization_timeout",
"denom",
"network",
"notify_cosmos_zone"
],
Expand Down Expand Up @@ -1344,6 +1460,9 @@
"null"
]
},
"denom": {
"type": "string"
},
"network": {
"$ref": "#/definitions/Network"
},
Expand Down Expand Up @@ -1522,6 +1641,41 @@
"type": "string"
}
}
},
"transfer_info": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Nullable_TransferInfo",
"anyOf": [
{
"$ref": "#/definitions/TransferInfo"
},
{
"type": "null"
}
],
"definitions": {
"TransferInfo": {
"description": "IBC transfer (ICS-020) channel settings",
"type": "object",
"required": [
"address_type",
"channel_id",
"to_address"
],
"properties": {
"address_type": {
"type": "string"
},
"channel_id": {
"type": "string"
},
"to_address": {
"type": "string"
}
},
"additionalProperties": false
}
}
}
}
}
46 changes: 46 additions & 0 deletions contracts/babylon/schema/raw/execute.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@
}
},
"additionalProperties": false
},
{
"description": "`SendRewards` is a message sent by the finality contract, to send rewards to Babylon",
"type": "object",
"required": [
"send_rewards"
],
"properties": {
"send_rewards": {
"type": "object",
"required": [
"fp_distribution"
],
"properties": {
"fp_distribution": {
"description": "`fp_distribution` is the list of finality providers and their rewards",
"type": "array",
"items": {
"$ref": "#/definitions/RewardsDistribution"
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
],
"definitions": {
Expand Down Expand Up @@ -171,6 +197,26 @@
}
},
"additionalProperties": false
},
"RewardsDistribution": {
"type": "object",
"required": [
"fp_pubkey_hex",
"reward"
],
"properties": {
"fp_pubkey_hex": {
"type": "string"
},
"reward": {
"$ref": "#/definitions/Uint128"
}
},
"additionalProperties": false
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
}
}
}
55 changes: 55 additions & 0 deletions contracts/babylon/schema/raw/instantiate.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@
"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"
},
"transfer_info": {
"description": "IBC information for ICS-020 rewards transfer. If not set, distributed rewards will be native to the Consumer",
"anyOf": [
{
"$ref": "#/definitions/IbcTransferInfo"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false,
Expand All @@ -99,6 +110,22 @@
"description": "Binary is a wrapper around Vec<u8> to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec<u8>. See also <https://github.com/CosmWasm/cosmwasm/blob/main/docs/MESSAGE_TYPES.md>.",
"type": "string"
},
"IbcTransferInfo": {
"type": "object",
"required": [
"channel_id",
"recipient"
],
"properties": {
"channel_id": {
"type": "string"
},
"recipient": {
"$ref": "#/definitions/Recipient"
}
},
"additionalProperties": false
},
"Network": {
"type": "string",
"enum": [
Expand All @@ -107,6 +134,34 @@
"signet",
"regtest"
]
},
"Recipient": {
"oneOf": [
{
"type": "object",
"required": [
"contract_addr"
],
"properties": {
"contract_addr": {
"type": "string"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"module_addr"
],
"properties": {
"module_addr": {
"type": "string"
}
},
"additionalProperties": false
}
]
}
}
}
Loading