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

feat(adr-26): Separate inclusion proof from staking tx info #111

Merged

Conversation

gitferry
Copy link
Contributor

@gitferry gitferry commented Oct 1, 2024

ref.

This PR implements the separates the handling inclusion proof from btc delegation. In particular, this PR:

  1. introduces a new parameter delegation_creation_base_gas_fee_sat which will be used to consume more gas when the inclusion proof is not included in the delegation
  2. separated the handling of inclusion proof into a different method
  3. do not set start height and end height if the inclusion proof is not included
  4. do not emit voting power change even if the inclusion proof is not included

A subsequent PR will introduce a new message to handle the inclusion proof

@gitferry gitferry force-pushed the gai/adr-26-separate-inclusion-proof branch from 6615021 to ba5433e Compare October 1, 2024 06:18
@gitferry gitferry marked this pull request as ready for review October 1, 2024 06:27
@gitferry gitferry requested a review from a team as a code owner October 1, 2024 06:27
}
}

message InclusionProof {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Message needs doc comments as otherwise make proto-lint won't pass.

A bit tangent, I am not sure how make proto-lint got out of CI, most probably during migration to re-usable pipelines.

@@ -55,6 +55,8 @@ message Params {
];
// max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol
uint32 max_active_finality_providers = 13;
// base gas fee for delegation creation in Satoshi
int64 delegation_creation_base_gas_fee_sat = 14;
Copy link
Collaborator

Choose a reason for hiding this comment

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

imo this should be an uint64 as negative value do not make sense here and we also avoid type conversion in ConsumeGas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought we should keep consistent with other parameters e.g., min_slashing_tx_fee_sat and unbonding_fee_sat

Copy link
Collaborator

Choose a reason for hiding this comment

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

ahh I see confusion!

This should be delegation_creation_base_gas_fee , not delegation_creation_base_gas_fee_sat i.e the additional gas fee is not in satoshis but in cosmos gas unit.

min_slashing_tx_fee_sat and unbonding_fee_sat are used as int64 becouse thats what btcd library uses, so in those cases minimize amount of type conversions/

endHeight = startHeight + uint64(parsedMsg.StakingTime)
} else {
// consume base gas fee to compensate future submission of inclusion proof
ctx.GasMeter().ConsumeGas(uint64(ms.GetParams(ctx).DelegationCreationBaseGasFeeSat), "delegation creation fee")
Copy link
Collaborator

Choose a reason for hiding this comment

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

params are already retrieved in line:

// 5. Validate parsed message against parameters
vp := ms.GetParamsWithVersion(ctx)

so lets avoid making another roundtrip to database

) (*ParsedProofOfInclusion, error) {
if info == nil {
return nil, fmt.Errorf("cannot parse nil *btcckpttypes.TransactionInfo")
if ip == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to allow nil inclusion proof as now this proof is optional in MsgCreateDelegation

Also in the struct ParsedCreateDelegationMessage I would leave doc comment for StakingTxProofOfInclusion field that, so something along the lines:

// StakingTxInclusionProof is optional is and it is up to the caller to verify
// whether it is present or not
StakingTxProofOfInclusion  *ParsedProofOfInclusion

return err
}

inclusionProof, err := types.NewInclusionProofFromHex(args[3])
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't we call the types.NewInclusionProofFromHex( only if len(args[3]) > 0 i.e if user provides empty string as inclusion proof we create message where inclusion proof is nil ?

startHeight = inclusionHeight
endHeight = startHeight + uint64(parsedMsg.StakingTime)
} else {
// consume base gas fee to compensate future submission of inclusion proof
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm this is a bit misleading, I would say that we consume more gas to protect babylon chain and covenant members against spamming i.e creating delegation that will never reach btc chain

Copy link
Collaborator

@KonradStaniec KonradStaniec left a comment

Choose a reason for hiding this comment

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

LGTM!

@gitferry gitferry merged commit c6b08f4 into feat/adr-26-pre-approval Oct 1, 2024
19 checks passed
@gitferry gitferry deleted the gai/adr-26-separate-inclusion-proof branch October 1, 2024 10:16
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.

2 participants