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

Disable recovered_fp_btc_sk validation in SlashedBtcDelegation #63

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

gusin13
Copy link
Collaborator

@gusin13 gusin13 commented Sep 13, 2024

The Slashed Delegation IBC packet from Babylon -> Consumer expects to have FP SK, imo this is not needed in the contract side as it has nothing to do with the extracted key.

For now i have disabled the validation which happens on packet receive, in later pr i'll need to fix the proto files both in babylon side and contract side.

Ref https://github.com/babylonlabs-io/babylon/blob/7942dae93db7f61539e4f84ecc3ff67f32299f44/proto/babylon/btcstaking/v1/packet.proto#L136

@SebastianElvis
Copy link
Member

Isn't this needed for the consumer chain to verify the corresponding FP is indeed slashed?

@maurolacy
Copy link
Collaborator

Isn't this needed for the consumer chain to verify the corresponding FP is indeed slashed?

No if we trust Babylon.

Copy link
Collaborator

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove this, which I'm OK with, let's just remove the commented code, and the field from the struct as well.

Comment on lines +188 to +190
// if self.recovered_fp_btc_sk.is_empty() {
// return Err(StakingApiError::EmptyBtcSk);
// }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove commented code.

@SebastianElvis
Copy link
Member

SebastianElvis commented Sep 16, 2024

Then how about we make this field optional, and then only deal with it when full-validation feature is enabled?

Asking because by default, Babylon cannot make assumption on whether the consumer side trusts itself, so Babylon has to send over the extracted secret key in any case

@gusin13
Copy link
Collaborator Author

gusin13 commented Sep 16, 2024

@SebastianElvis you are right, just found this is used here

#[cfg(feature = "full-validation")]
{
/*
check if the SK corresponds to a FP PK that the delegation restakes to
*/
// get the slashed FP's SK
let slashed_fp_sk = hex::decode(&slashed_fp_sk_hex)
.map_err(|e| ContractError::SecP256K1Error(e.to_string()))?;
let slashed_fp_sk = SigningKey::from_bytes(&slashed_fp_sk)
.map_err(|e| ContractError::SecP256K1Error(e.to_string()))?;
// calculate the corresponding VerifyingKey
let slashed_fp_pk = slashed_fp_sk.verifying_key();
let slashed_fp_pk_hex = hex::encode(slashed_fp_pk.to_bytes());
// check if the PK corresponds to a FP PK that the delegation restakes to
if !active_delegation
.fp_btc_pk_list
.contains(&slashed_fp_pk_hex)
{
return Err(ContractError::FinalityProviderNotFound(
slashed_fp_pk_hex.to_string(),
));
}
}

now qq - I was thinking keeping this field optional on the contract side still wouldn't help much as we can't turn on/off this field from Babylon side based on feature flag. Babylon would always need to send this field.

Why don't we simply send slashing evidence from Babylon, if the full-validation ff is turned on contract is responsible to extract the SK from evidence, this would avoid the extraction logic in Babylon (which in my understanding is bit slow)?

@SebastianElvis
Copy link
Member

Why don't we simply send slashing evidence from Babylon, if the full-validation ff is turned on contract is responsible to extract the SK from evidence, this would avoid the extraction logic in Babylon (which in my understanding is bit slow)?

Yup this works as well, and it seems better as Babylon does less work 👍

@maurolacy
Copy link
Collaborator

maurolacy commented Sep 17, 2024

Why don't we simply send slashing evidence from Babylon, if the full-validation ff is turned on contract is responsible to extract the SK from evidence, this would avoid the extraction logic in Babylon (which in my understanding is bit slow)?

This is a good idea in principle. The only problem is, that at that point the evidence might not be available anymore, as this slashing messages comes from Babylon, after slashing propagation / cascading.

Ah, you mean, sending the evidence along with the extracted SK, so that the Consumer can verify it. That makes sense.
And then, we put the verification under the full-validation feature flag.

@gusin13
Copy link
Collaborator Author

gusin13 commented Sep 17, 2024

Hi guys as per today's (17 Sept) integration meeting
https://babylonlabs.atlassian.net/wiki/spaces/BABYLON/pages/32670523/2024-09-17+PoS+integration+meeting

it was discussed Babylon will send SK in the IBC packet. I will request to merge this PR as it is b/c in my cascading slashing PR I am not sending SK in IBC packet and I need the contract to disable this validation so e2e tests pass.

I'll prefer to do the discussed change in a separate PR, have made a ticket for this.
babylonlabs-io/babylon#76

@gusin13 gusin13 merged commit 83b5096 into main Sep 17, 2024
1 check passed
@gusin13 gusin13 deleted the gusin13/cascaded-slashing-us1 branch September 17, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants