-
Notifications
You must be signed in to change notification settings - Fork 39
feat: Validator trait + implementation for USV2 #430
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
base: main
Are you sure you want to change the base?
Conversation
We need this trait to help us find out when our delta transitioning causes our local state to diverge from on-chain. - I had to downcast in the end, since we didn't want to add the Validator trait to the ProtocolSim trait requirement (we would need to change tycho_common). We can't just change the integration test to require the Validator trait, since this would require this change in a few other places (such as the Update struct), and it's slightly unintuitive that it would return Validator here instead of ProtocolSim. The simplest, albeit slightly hacky solution is to try to downcast before validating, and return None if we aren't able to downcast to that specific pool state.
since it depends on EVM-specific types and the alloy crate
22fa6f7 to
8978571
Compare
dianacarvalho1
left a comment
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.
Thank you @tamaralipows ! 🙏🏼 I have some suggestions..
- Validating one component at a time will be way too slow. We must batch similar to how we do in execution_simulator.rs. The actual processing of the batch results can happen one-component-at-a-time since this is not the slowest part. - For this, we need `batch_validate_components` and `execute_batched_calls` helper methods. We also still need to downcast in main.rs (looking for another solution)
Similar to how TychoStreamDecoder::register_decoder() associates protocol names with types implementing TryFromWithBlock, get_validator() provides a centralized place to map protocol names to types implementing Validator. While the decoder uses a registry pattern with closures for more flexibility, get_validator() uses a simpler match statement since validation downcasting is more straightforward (doesn't require runtime registration).
This can be logged earlier.
The UniswapV2 reserves are only updated when swapping, so we should be checking the reserves, not the balances
for better readability
469928a to
d95fd37
Compare
dianacarvalho1
left a comment
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.
Thank you @tamaralipows 🙏🏼 This looks good to me! I have only tiny suggestions
| } | ||
| } | ||
| }; | ||
| components_to_process.push((id.clone(), component, state.clone_box())); |
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.
can we put all of this component selecting in one big method? I think it fits nicely together now!
| } else { | ||
| error!( | ||
| component_id = %component_id, | ||
| "State validation failed" |
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.
could we log here the delta message? 🤔
No description provided.