-
Notifications
You must be signed in to change notification settings - Fork 14
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
refactor: Re-arrange Chains traits for better composability #3912
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3912 +/- ##
=====================================
- Coverage 71% 71% -0%
=====================================
Files 366 370 +4
Lines 56798 56837 +39
Branches 56798 56837 +39
=====================================
+ Hits 40545 40555 +10
- Misses 14240 14252 +12
- Partials 2013 2030 +17
... and 4 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
traits are fun 😄
meta comment: given this is a refactor... it should be |
I agree. Also, could we require (if we don't already) that each (non-trivial) PR should have a short summary with context/motivation? I try to make my PRs accessible to everyone, but I find it hard to keep up with changes coming from Berlin if they don't provide context. |
+1 @ramizhasan111 the PR template is there for a reason ;) I've added some Linear issues to track this, am aware there were none. |
Sorry, thought about writing it but got a bit lazy haha |
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.
Looking good 👍
payload: &<Abi as ChainCrypto>::Payload, | ||
current_key: &<Abi as ChainCrypto>::AggKey, | ||
signature: &<Abi as ChainCrypto>::ThresholdSignature, | ||
payload: &<<C as Chain>::ChainCrypto as ChainCrypto>::Payload, |
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.
Similar to the XFor<T, I>
type aliases in the pallets, we could create:
type AggKeyFor<C> = <<C as Chain>::ChainCrypto as ChainCrypto>::AggKey;
etc.
Might remove some of the noise from these declarations? For example this would become:
payload: &PayloadFor<C>,
Thanks! 🙂 |
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.
One minor suggestion, apart from that LGTM.
Please let's update from main and make sure there are no hidden conflicts. |
* origin/main: Fix: Correct Select Median Implementation (#3934) fix: independent witnessing startup (#3913) 🍒 cherry-pick: changes in release for CI and chainspec (#3933) refactor: Re-arrange Chains traits for better composability (#3912) fix: log error when we try to transfer *more* than we have fetched (#3930) chore: add checks and increase timeout (#3928) Add `bind_redeem_address` to CLI (#3908) 🍒 cherry-pick: add missing prod dockerfiles (#3926) chore: skip localnet specific tests in devnet 🤫 (#3919) fix: broadcast success should be witnessable after a rotation (#3921) # Conflicts: # state-chain/chains/src/eth/api.rs # state-chain/runtime/src/chainflip.rs
…on-integration * origin/main: Added CFE setting for logging span lifecycles (#3936) fix: only burn flip if non zero (#3932) Fix: Correct Select Median Implementation (#3934) fix: independent witnessing startup (#3913) 🍒 cherry-pick: changes in release for CI and chainspec (#3933) refactor: Re-arrange Chains traits for better composability (#3912) fix: log error when we try to transfer *more* than we have fetched (#3930) chore: add checks and increase timeout (#3928) Add `bind_redeem_address` to CLI (#3908) 🍒 cherry-pick: add missing prod dockerfiles (#3926) chore: skip localnet specific tests in devnet 🤫 (#3919) fix: broadcast success should be witnessable after a rotation (#3921) # Conflicts: # state-chain/cf-integration-tests/src/network.rs
Co-authored-by: dandanlen <3168260+dandanlen@users.noreply.github.com>
Co-authored-by: dandanlen <3168260+dandanlen@users.noreply.github.com>
Pull Request
Closes: PRO-803
Checklist
Please conduct a thorough self-review before opening the PR.
Summary
This PR re-arranges the Chain traits so that we can have a subset of associated types of the chain trait that can be re-used for multiple chains. Specifically, the ChainCrypto types that are shared across chains with the same crypto scheme (EVM chains for example). We can have one implementation of
ChainCrypto
trait for EVM chains that can then be re-used for all EVM chains. This then enables us to use a single key and a single threshold signature pallet that coordinates the signing for that ChainCrypto that can be shared across multiple chains. This would mean that in CFE we would have a single key and multisig client for all EVM chains .Moreover, this also merges the
ChainAbi
trait into the mainChain
trait since it didn't make too much sense to have a separate trait for abi types since it was already needed to be implemented for all chains alongside theChain
trait.So, instead of having:
we have