-
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
feat: Expose vault swaps from ingress-egress-tracker #5463
base: main
Are you sure you want to change the base?
Conversation
7c874b8
to
753fb2d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5463 +/- ##
======================================
- Coverage 72% 71% -0%
======================================
Files 495 500 +5
Lines 88168 88263 +95
Branches 88168 88263 +95
======================================
- Hits 63149 62889 -260
- Misses 22450 22796 +346
- Partials 2569 2578 +9 ☔ View full report in Codecov by Sentry. |
b6f28c0
to
bc331f7
Compare
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.
looks good to me from a product perspective otherwise!
deposit_metadata: Option<CcmDepositMetadata>, | ||
deposit_details: Option<DepositDetails>, | ||
broker_fee: Beneficiary<AccountId32>, | ||
affiliate_fees: Affiliates<AffiliateShortId>, |
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.
would be great to have the account ids instead of the short ids here
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.
This is turning out to be a non-trivial change. Can we leave this for a later update?
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.
unfortunately we will need to do a separate rpc call to handle the short ids on our side, so i would really prefer to have them in redis
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.
its fine for me to do that in a follow up pr obv, but that follow up should land before we start using it 🙂
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 managed to get it working. Not the nicest, but it will do. At least we are one step closer to storing all swap data in redis. Shouldn't be too hard now to fetch the deposit channel data and get it in the db.
expression: "store.storage.get(\"vault_deposit:Ethereum:b5c8bd9430b6cc87a0e2fe110ece6bf527fa4f170a4bc8cd032f768fc5219838\").unwrap()" | ||
snapshot_kind: text | ||
--- | ||
{"affiliate_fees":[],"amount":"0x64","boost_fee":0,"broker_fee":{"account":"5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM","bps":0},"dca_params":null,"deposit_chain_block_height":1,"deposit_details":null,"deposit_metadata":null,"destination_address":{"Eth":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"input_asset":{"asset":"ETH","chain":"Ethereum"},"output_asset":{"asset":"FLIP","chain":"Ethereum"},"refund_params":{"min_price":"0x0","refund_address":{"Eth":"0x541f563237a309b3a61e33bdf07a8930bdba8d99"},"retry_duration":0}} |
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.
it looks like the destination_address is formatted differently than the refund_adress here. think it would make sense to have them both exposed as string
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.
would be cool to have some affiliates, dca params, ccm params in here to see the encoding
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.
and the account id uses the substrate ss58 prefix instead of the cf prefix
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.
Looks fixed now
api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs
Outdated
Show resolved
Hide resolved
9a868fe
to
0443269
Compare
5a92f35
to
536a354
Compare
bed8ed2
to
c3da775
Compare
TransactionInIdForAnyChain::Bitcoin(hash) => hex::encode(hash.as_bytes()), | ||
TransactionInIdForAnyChain::Evm(hash) => hex::encode(hash.as_bytes()), | ||
TransactionInIdForAnyChain::Polkadot(transaction_id) => format!( | ||
"{}-{}", | ||
transaction_id.block_number, transaction_id.extrinsic_index | ||
), | ||
TransactionInIdForAnyChain::Solana((address, id)) => format!("{address}-{id}",), | ||
TransactionInIdForAnyChain::MockEthereum(_) | | ||
TransactionInIdForAnyChain::None => { | ||
return Err(anyhow!("Invalid transaction id: {tx_id:?}")); |
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 should just impl Display for TransactionInIdForAnyChain ?
#[async_trait] | ||
trait DepositIntoWitnessInformation<C: Chain> { | ||
async fn into_witness_information<StateChainClient>( | ||
self, | ||
height: <C as Chain>::ChainBlockNumber, | ||
network: NetworkEnvironment, | ||
state_chain_client: Arc<StateChainClient>, | ||
) -> anyhow::Result<WitnessInformation> | ||
where | ||
StateChainClient: StorageApi + ChainApi + TrackerApi + 'static + Send + Sync; | ||
} |
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.
This looks like it can be simplified - no need for async or sc client? (Or result??)
#[async_trait] | |
trait DepositIntoWitnessInformation<C: Chain> { | |
async fn into_witness_information<StateChainClient>( | |
self, | |
height: <C as Chain>::ChainBlockNumber, | |
network: NetworkEnvironment, | |
state_chain_client: Arc<StateChainClient>, | |
) -> anyhow::Result<WitnessInformation> | |
where | |
StateChainClient: StorageApi + ChainApi + TrackerApi + 'static + Send + Sync; | |
} | |
trait DepositIntoWitnessInformation<C: Chain> { | |
async fn into_witness_information<StateChainClient>( | |
self, | |
height: <C as Chain>::ChainBlockNumber, | |
network: NetworkEnvironment, | |
) -> WitnessInformation; | |
} |
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.
(Also, not sure we really need a macro)
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.
Actually - this is pretty confusing - we have two macros for implementing the same trait 😅
impl_vault_deposit_into_witness_information!(Polkadot); | ||
impl_vault_deposit_into_witness_information!(Arbitrum); | ||
|
||
impl BroadcastIntoWitnessInformation for BroadcastDetails<Ethereum> { |
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.
... but no macro for this?
} | ||
} | ||
|
||
async fn save_deposit_witnesses< |
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 feel like we could simplify a lot if we query for a map of affiliate IDs in this method, and then pass that through, rather than threading the sc client (and attendant type constraints and async-ness) down through the whole call stack.
if let Some(broadcast_details) = | ||
get_broadcast_id::<I, StateChainClient>(state_chain_client, &tx_out_id) | ||
.await | ||
.map(|broadcast_id| BroadcastDetails::<I> { broadcast_id, tx_out_id, tx_ref }) |
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.
(...A bit like this approach)
Pull Request
Closes: PRO-1825
Checklist
Please conduct a thorough self-review before opening the PR.
Summary
VaultDeposit
that gets stored in the database. It is stored using the keyvault_deposit:{chain}:{tx_id}
.TrackerStateChainClient
to assist with mocking RPC calls.