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

test: bitcoin block processor #5603

Merged
merged 11 commits into from
Feb 11, 2025
Merged

Conversation

marcellorigotti
Copy link
Contributor

Pull Request

Closes: PRO-1985

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

Please include a succinct description of the purpose and content of the PR. What problem does it solve, and how? Link issues, discussions, other PRs, and anything else that will help the reviewer.

@marcellorigotti marcellorigotti requested review from MxmUrw and removed request for dandanlen and kylezs February 3, 2025 16:53
@marcellorigotti marcellorigotti changed the title Feature/pro 1985 feat: Feature/pro 1985 Feb 4, 2025
@kylezs kylezs changed the title feat: Feature/pro 1985 test: bitcoin block processor Feb 5, 2025
Copy link
Contributor

@MxmUrw MxmUrw left a comment

Choose a reason for hiding this comment

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

Very nice work! Added some last comments we could discuss.

@@ -141,7 +140,7 @@ fn generate_new_reorg_id<'a, N: BlockZero + SaturatingStep + Ord + 'static>(
}

#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode, TypeInfo, Deserialize, Serialize)]
pub enum ChainProgressInner<ChainBlockNumber> {
pub enum ChainProgressInner<ChainBlockNumber: Step> {
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably should use SaturatingStep here.

Comment on lines 68 to 72
type CleanOld: for<'a> Hook<
(
&'a mut BTreeMap<Self::ChainBlockNumber, (Self::BlockData, Self::ChainBlockNumber)>,
&'a mut BTreeMap<Self::ChainBlockNumber, Vec<Self::Event>>,
Self::ChainBlockNumber,
),
(),
> + Default
+ Serde
+ Debug
+ Clone
+ Eq;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the implementation of CleanOld chain-specific? It seems to me that it could be simply a method in the BlockProcessor struct?

Comment on lines 17 to 19
pub trait InnerEquality {
fn inner_eq(&self, other: &Self) -> bool;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I've been thinking about this, and maybe there is a way to do this without this trait. If we split the event into two parts of "blockdata" and "deposit data", then we could compare the deposit data independently of the blockheight/hash to check which events we already emitted. The Execute hook would then take two parameters, i.e.

Hook<(Self::ChainBlockNumber, Self::Event), ()>

Copy link
Contributor

Choose a reason for hiding this comment

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

We probably want to rename this one back to state_machine.

Copy link
Contributor

@MxmUrw MxmUrw left a comment

Choose a reason for hiding this comment

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

Nice! I added one comment. Apart from that, thanks for the good work, and let's merge this!

type DedupEvents = DedupEventsHook;

fn get_safety_margin() -> Self::ChainBlockNumber {
Copy link
Contributor

@MxmUrw MxmUrw Feb 10, 2025

Choose a reason for hiding this comment

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

I think this should be a hook, then we can give it a random value in prop tests. Which would allow us to check more possible edge cases.

@marcellorigotti marcellorigotti merged commit 2c8ab19 into feat/block-witnesser-es Feb 11, 2025
1 check passed
@marcellorigotti marcellorigotti deleted the feature/pro-1985 branch February 11, 2025 11:07
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