-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
contracts/babylon/src/contract.rs
Outdated
// Route to babylon over IBC | ||
let channel = IBC_CHANNEL.load(deps.storage)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I guess IBC_CHANNEL
is the channel that this contract involves, but not necessarily a channel for IBC transfer. Probably we need to confirm this in some e2e test.
Maybe as a part of the integration, one needs to establish an IBC channel for interchain transfer, and the contract side needs to remember this channel ID in the config, for facilitating the reward mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was my suspicion as well. Implemented it this way for simplicity. Perhaps we can configure a single channel to do / support both, custom messages and ICS20 transfers?
Will write an e2e test and confirm this in any case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was finally able to e2e test this.
Using a single channel doesn't work, as CosmWasm's IbcMsg::Transfer
requires an established channel against the ibctransfer
module, not the contract address under wasm
.
I think this is a design decision that makes sense, as in general you don't want to establish a channel for every contract that needs / wants to use ICS20 transfers.
Update: Ref.: https://github.com/CosmWasm/cosmwasm/blob/4da538debc73065f9aa8f489895cb54393db0f7c/packages/std/src/ibc.rs#L26-L54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a single channel doesn't work, as CosmWasm's IbcMsg::Transfer requires an established channel against the ibctransfer module, not the contract address under wasm.
Yes that's right, even though we can wire up a IBC transfer packet in the contract side, babylon side's zone concerige won't recognise it.
If we really, really want to let zone concerige handle IBC tansfer, then zone concierge has to invoke IBC transfer module (in particular this code snippet) to handle the IBC transfer packets. But I'm not sure if it's worth it
So I'd recommend we consider consolidating IBC channels as future work, and for now start with having 2 IBC channels. This also creates a clean separation between channels' functionalities following IBC channels' best practices
961ca90
to
da5dbc2
Compare
934aabc
to
5a3698e
Compare
da5dbc2
to
54e733f
Compare
da78c91
to
e528d44
Compare
9455a91
to
cb8e897
Compare
@@ -632,14 +632,20 @@ pub fn distribute_rewards(deps: &mut DepsMut, env: &Env) -> Result<(), ContractE | |||
}; | |||
// Get the voting power of the active FPS | |||
let total_voting_power = active_fps.iter().map(|fp| fp.power as u128).sum::<u128>(); | |||
// Get the rewards to distribute (bank balance of the finality contract) | |||
// Get the rewards to distribute (bank balance of the finality contract minus already distributed rewards) | |||
let distributed_rewards = TOTAL_REWARDS.load(deps.storage)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to get the total reward by querying the contract's balance, rather than tracking it in a Kv store?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this is, that TOTAL_REWARDS
are the rounded sum of the distributed rewards over finality providers. They are not necessarily the same. With this impl, we left the remainder in the balance, and it'll be distributed later eventually. Better than send an amount that doesn't match the sum of the distributed rewards, IMO.
…n op slashing msg
This reverts commit 878776c.
a8e320c
to
f42067d
Compare
Merging as approved. Please take a look at recent changes (IBC transfer channel info) and comment back in any case. TODOs (custom rewards distribution protocol) will be done in follow-up PRs. |
#97 follow-up. Sends the rewards along with the distribution table to Babylon using ICS-20 with a json payload in the Memo field.