-
Notifications
You must be signed in to change notification settings - Fork 0
Eth bridge indexer metrics + coinmarketcap API to fetch a price. #159
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: vmarkushin/test-succint
Are you sure you want to change the base?
Conversation
…packet-indexer fee collector indexer + send packet indexer
introduced DatabaseFeeCollector to save the fee collected/withdrawn
parse and use event of send packet to store into db
…-api Introduce coinmarketcap api to fetch a price and add metrics fee usd.
| input TEXT NOT NULL, | ||
| max_fee_per_gas TEXT, | ||
| max_priority_fee_per_gas TEXT, | ||
| method TEXT NOT NULL, |
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.
How do we store multiple method calls?
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.
introduced call_batch_methods column as a vec of method's selectors called by relayer to call_batch solidity fn.
|
|
||
| let fee_collector_address : ethabi::Address = "0x6f11fb4d4178c5d5e3ee4bc7820d8cfed0b59ce7".parse().unwrap(); | ||
| let fee_collector_address_vec = Box::new(vec![fee_collector_address]); | ||
| let f: &'static mut Vec<ethabi::Address> = Box::leak(fee_collector_address_vec); |
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.
Try to avoid using leak (use .clone() for example)
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.
clone does not work here.
|
|
||
| for i in transactions{ | ||
| all_txs.insert(i.hash.clone(), i.clone()); | ||
| if i.from_address.eq_ignore_ascii_case("0x6c57e54C379b5716999ae9AAE4917c9B35AC2CB9") && i.to_address.eq_ignore_ascii_case("0xd856f0f9efa054896fe3596e05978bbe686de131"){ |
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.
Parse the Address from string and 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.
done
| } | ||
|
|
||
| // relayer_txs.retain(|x| x.from_address.eq_ignore_ascii_case("0x6c57e54C379b5716999ae9AAE4917c9B35AC2CB9")); | ||
| relayer_txs.sort_by(|a, b| a.block_number.cmp(&b.block_number)); |
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.
Use .sort_by_key
| relayer_txs.sort_by(|a, b| a.block_number.cmp(&b.block_number)); | ||
| println!("Relayer txs len: {:?}", relayer_txs.len()); | ||
| if relayer_txs.len() > 0 { | ||
| println!("Relayer txs: {:?}", relayer_txs[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.
| println!("Relayer txs: {:?}", relayer_txs[0]); | |
| println!("Relayer txs: {:?}", relayer_txs); |
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.
too much logs. going to remove.
| // `from_tos` is `block_numbers` shrinked to pairs of `(from_block, to_block)` | ||
| // e.g. block numbers = [1, 2, 3, 5, 6, 7, 8, 10], from_tos = [(1,3), (5,8), (10, 10)] | ||
| let from_tos: Vec<(i64, i64)> = block_numbers.iter().fold(vec![], |mut acc, block_number| { | ||
| if acc.is_empty() { | ||
| acc.push((*block_number, *block_number)); | ||
| return acc | ||
| } | ||
|
|
||
| let last_from_to = acc.last_mut().unwrap(); | ||
|
|
||
| if last_from_to.1 + 1 == *block_number { | ||
| last_from_to.1 = *block_number; | ||
| } else { | ||
| acc.push((*block_number, *block_number)); | ||
| } | ||
|
|
||
| acc | ||
| }); |
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.
Extract this code to a separate function to avoid duplication
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.
done.
…thods parse call batch methods to store into db actions from relayer.
introduce args for metric indexer config instead of hardcoded variables
Add block number to fee collector, fix bug with decoding, extract to fn
| `TODO: programs and flags.` | ||
|
|
||
| 5. Usage | ||
| `DATABASE_URL="pg://postgres:password@localhost/postgres" REDIS_URL="redis://localhost:6379" cargo run --package evm-indexer --bin evm-indexer -- --chain=mainnet --start-block=19789739 --rpcs=https://geth-execution-0.ethereum-mainnet.sre-scratchpad-349209.composablenodes.tech:443 --contract-addresses=0xd856f0f9efa054896fe3596e05978bbe686de131 --ibc-core-address=0xd856f0f9efa054896fe3596e05978bbe686de131 --relayer-address=0x6c57e54C379b5716999ae9AAE4917c9B35AC2CB9 --fee-collector-address=0x6f11fb4d4178c5d5e3ee4bc7820d8cfed0b59ce7 --ics20-transfer-bank-address=0x148acd3cd4d6a17cd2abbecd0745b09b62c64f84 --coinmarketcap-api-key=449a42d7-b66f-4b85-b957-cc6599b8c1e6` |
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 it a real api-key ?
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.
real key. without any funds. 10k monthly credits calls.
example.
repo is private. you can substitute with your key if you wish
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.
ok
| //price-performance-stats is not allowed for free plan | ||
| // let mut url = Url::parse("https://pro-api.coinmarketcap.com/v2/cryptocurrency/price-performance-stats/latest").unwrap(); | ||
| //only quotes/latest is allowed for free plan | ||
| let mut url = Url::parse("https://pro-api.coinmarketcap.com/v2/cryptocurrency/quotes/latest").unwrap(); |
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.
maybe, this should be configurable? not hardcodeded, in case coinmarketcap changes endpoint
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.
there are so many params for this indexer to set as a dependency.
if endpoint will change then the code probably will not work at all and need to change the logic inside of source code.
Eth bridge indexer metrics + coinmarketcap API to fetch a price.
todo:
get latest pricetoget price on date