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: BTC egress witnessing ES #5653

Merged
merged 2 commits into from
Feb 21, 2025

Conversation

marcellorigotti
Copy link
Contributor

Pull Request

Closes: PRO-2040

Checklist

Please conduct a thorough self-review before opening the PR.

  • I am confident that the code works.
  • I have written sufficient tests.
  • I have written and tested required migrations.
  • I have updated documentation where appropriate.

Summary

Egress witnessing ES for btc

@marcellorigotti marcellorigotti requested review from MxmUrw and removed request for dandanlen and martin-chainflip February 19, 2025 09:46
@marcellorigotti marcellorigotti marked this pull request as draft February 19, 2025 09:47
@marcellorigotti marcellorigotti force-pushed the feature/pro-2040 branch 2 times, most recently from f846c76 to 81c07a1 Compare February 19, 2025 15:26
@marcellorigotti marcellorigotti marked this pull request as ready for review February 19, 2025 17:19
@marcellorigotti marcellorigotti force-pushed the feature/pro-2040 branch 3 times, most recently from ed32c18 to 0ae6a73 Compare February 19, 2025 17:45
Copy link
Contributor

@MxmUrw MxmUrw Feb 20, 2025

Choose a reason for hiding this comment

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

Also I would hope that with our current approach we don't need these changes as well (referring to the whole chains/src/lib.rs file)? Correct me if I'm wrong though...

Copy link
Contributor Author

@marcellorigotti marcellorigotti Feb 20, 2025

Choose a reason for hiding this comment

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

I don't think we can get rid of these changes that easily.. as long as we have this in the ES trait:
type ElectoralUnsynchronisedState: Parameter + Member + MaybeSerializeDeserialize;
Then everything that goes into the BlockProcessor has to to impl Serialize/Deserialize

Copy link
Contributor

Choose a reason for hiding this comment

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

If we want, we can do it the same way we did for the Encode/Decode bounds, by adding annotations where we derive Serialize/Deserialize. Here: #5657

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah ofc that's the way to do it, was just having a look at the PR now!

Copy link
Contributor

Choose a reason for hiding this comment

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

OTOH it might be fine to simply add these new bounds, the PR above is more of an FYI...

events: Vec<(BlockNumber, BtcEvent<TransactionConfirmation<Runtime, BitcoinInstance>>)>,
) -> Vec<(BlockNumber, BtcEvent<TransactionConfirmation<Runtime, BitcoinInstance>>)> {
// Map: deposit_witness -> chosen BtcEvent
// todo! this is annoying, it require us to implement Ord down to the Chain type
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this todo isn't true anymore, right?

Comment on lines +202 to +205
// we don't care about this value for btc (we don't refund out aggkey)
// the correct value to put here should be the aggKey which signed the tx
// (either current or previous) I guess we can derive it from
// VerobseTransaction, if yes how?
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a TODO?

egress.transaction_ref,
)
.expect("REASON");
//todo! handle possible error, expect will cause panic! -> when can this error?
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an interesting case, the egress_success function returns an error if the tx_out_id is unknown to us. This certainly can happen if nodes start voting for wrong txs, but what should we do in that case? Punish them?

Also it feels like we might want to check this already during consensus, such that we don't count votes if they contain invalid txs? But votes are for full blocks, so we would discard the whole vote?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be impossible since in the voter impl we vote only if the hashes match one of our tx, meaning we can only vote for tx_out_id we know.
I'll log in case it errors, like we do for solana

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's worth thinking about the case where the engines don't behave as we expect them to do, to cover all possible cases. Anyways, logging should be fine since nothing of consequence would happen in such an error case.

@MxmUrw
Copy link
Contributor

MxmUrw commented Feb 20, 2025

Ok, after thinking a bit about this, I'm fine with introducing these new bounds, since we are gonna effectively require these types to implement Ser/De once we actually start implementing ESs for the other chains.

@marcellorigotti marcellorigotti merged commit ede8a4a into feat/block-witnesser-es Feb 21, 2025
1 check passed
@marcellorigotti marcellorigotti deleted the feature/pro-2040 branch February 21, 2025 09:06
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