-
Notifications
You must be signed in to change notification settings - Fork 15
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
Conversation
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.
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> { |
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.
We probably should use SaturatingStep
here.
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; |
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 the implementation of CleanOld
chain-specific? It seems to me that it could be simply a method in the BlockProcessor
struct?
pub trait InnerEquality { | ||
fn inner_eq(&self, other: &Self) -> bool; | ||
} |
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.
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), ()>
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.
We probably want to rename this one back to state_machine
.
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.
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 { |
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.
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.
- generalize it, general logic the same for every chain - keep hook implementation dependant on the chain for custom behaviour
…counter for testing
TODO: write all the tests
073668c
to
5e67410
Compare
Pull Request
Closes: PRO-1985
Checklist
Please conduct a thorough self-review before opening the PR.
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.