Create a workspace and make clippy happy.

This commit is contained in:
kayibal
2024-03-14 00:19:54 +00:00
parent e62cc13c0b
commit 425628ae97
11 changed files with 222 additions and 1345 deletions

View File

@@ -13,9 +13,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.80"
version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1"
checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247"
[[package]]
name = "arrayvec"
@@ -154,7 +154,24 @@ version = "17.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4966fba78396ff92db3b817ee71143eccd98acf0f876b8d600e585a670c5d1b"
dependencies = [
"ethereum-types",
"ethereum-types 0.13.1",
"hex",
"once_cell",
"regex",
"serde",
"serde_json",
"sha3",
"thiserror",
"uint",
]
[[package]]
name = "ethabi"
version = "18.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898"
dependencies = [
"ethereum-types 0.14.1",
"hex",
"once_cell",
"regex",
@@ -172,9 +189,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11da94e443c60508eb62cf256243a64da87304c2802ac2528847f79d750007ef"
dependencies = [
"crunchy",
"fixed-hash",
"fixed-hash 0.7.0",
"impl-rlp",
"impl-serde",
"impl-serde 0.3.2",
"tiny-keccak",
]
[[package]]
name = "ethbloom"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60"
dependencies = [
"crunchy",
"fixed-hash 0.8.0",
"impl-rlp",
"impl-serde 0.4.0",
"tiny-keccak",
]
@@ -184,11 +214,25 @@ version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2827b94c556145446fcce834ca86b7abf0c39a805883fe20e72c5bfdb5a0dc6"
dependencies = [
"ethbloom",
"fixed-hash",
"ethbloom 0.12.1",
"fixed-hash 0.7.0",
"impl-rlp",
"impl-serde",
"primitive-types",
"impl-serde 0.3.2",
"primitive-types 0.11.1",
"uint",
]
[[package]]
name = "ethereum-types"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee"
dependencies = [
"ethbloom 0.13.0",
"fixed-hash 0.8.0",
"impl-rlp",
"impl-serde 0.4.0",
"primitive-types 0.12.2",
"uint",
]
@@ -210,6 +254,18 @@ dependencies = [
"static_assertions",
]
[[package]]
name = "fixed-hash"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534"
dependencies = [
"byteorder",
"rand",
"rustc-hex",
"static_assertions",
]
[[package]]
name = "fixedbitset"
version = "0.4.2"
@@ -267,6 +323,12 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0"
[[package]]
name = "hex-literal"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46"
[[package]]
name = "home"
version = "0.5.9"
@@ -303,6 +365,15 @@ dependencies = [
"serde",
]
[[package]]
name = "impl-serde"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd"
dependencies = [
"serde",
]
[[package]]
name = "impl-trait-for-tuples"
version = "0.2.2"
@@ -495,10 +566,23 @@ version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a"
dependencies = [
"fixed-hash",
"fixed-hash 0.7.0",
"impl-codec",
"impl-rlp",
"impl-serde",
"impl-serde 0.3.2",
"uint",
]
[[package]]
name = "primitive-types"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2"
dependencies = [
"fixed-hash 0.8.0",
"impl-codec",
"impl-rlp",
"impl-serde 0.4.0",
"uint",
]
@@ -514,9 +598,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.78"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
dependencies = [
"unicode-ident",
]
@@ -528,7 +612,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd"
dependencies = [
"bytes",
"prost-derive",
"prost-derive 0.11.9",
]
[[package]]
name = "prost"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a"
dependencies = [
"bytes",
"prost-derive 0.12.3",
]
[[package]]
@@ -545,8 +639,8 @@ dependencies = [
"multimap",
"petgraph",
"prettyplease",
"prost",
"prost-types",
"prost 0.11.9",
"prost-types 0.11.9",
"regex",
"syn 1.0.109",
"tempfile",
@@ -566,13 +660,35 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "prost-derive"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e"
dependencies = [
"anyhow",
"itertools 0.10.5",
"proc-macro2",
"quote",
"syn 2.0.52",
]
[[package]]
name = "prost-types"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13"
dependencies = [
"prost",
"prost 0.11.9",
]
[[package]]
name = "prost-types"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e"
dependencies = [
"prost 0.12.3",
]
[[package]]
@@ -740,14 +856,14 @@ dependencies = [
"anyhow",
"bigdecimal",
"hex",
"hex-literal",
"hex-literal 0.3.4",
"num-bigint",
"num-integer",
"num-traits",
"pad",
"prost",
"prost 0.11.9",
"prost-build",
"prost-types",
"prost-types 0.11.9",
"substreams-macro",
"thiserror",
]
@@ -773,7 +889,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c04307913a355aaf2a1bb7186d4bc7e36875f3d4aff77b47e83f1b63b24da55"
dependencies = [
"anyhow",
"ethabi",
"ethabi 17.2.0",
"heck",
"hex",
"prettyplease",
@@ -783,6 +899,25 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "substreams-ethereum-balancer"
version = "0.1.0"
dependencies = [
"anyhow",
"bytes",
"ethabi 18.0.0",
"getrandom",
"hex",
"hex-literal 0.4.1",
"itertools 0.12.1",
"num-bigint",
"prost 0.11.9",
"prost-types 0.12.3",
"substreams",
"substreams-ethereum",
"tycho-substreams",
]
[[package]]
name = "substreams-ethereum-core"
version = "0.9.9"
@@ -790,12 +925,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db9048cc9a66873ab7069ef958c2684994e6ee323da49c186b19156fdb4ca131"
dependencies = [
"bigdecimal",
"ethabi",
"ethabi 17.2.0",
"getrandom",
"num-bigint",
"prost",
"prost 0.11.9",
"prost-build",
"prost-types",
"prost-types 0.11.9",
"substreams",
]
@@ -805,7 +940,7 @@ version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e862928bee8653f5c9291ac619c8dc0da14ca61d8cd8d89b3acdbbde4d0bf304"
dependencies = [
"ethabi",
"ethabi 17.2.0",
"heck",
"hex",
"num-bigint",
@@ -869,18 +1004,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.57"
version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b"
checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.57"
version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
dependencies = [
"proc-macro2",
"quote",
@@ -919,7 +1054,7 @@ version = "0.1.0"
dependencies = [
"hex",
"itertools 0.12.1",
"prost",
"prost 0.11.9",
"substreams",
"substreams-ethereum",
]

22
substreams/Cargo.toml Normal file
View File

@@ -0,0 +1,22 @@
[workspace]
members = [
"ethereum-balancer",
"crates/tycho-substreams",
]
resolver = "2"
[workspace.dependencies]
substreams-ethereum = "0.9.9"
substreams = "0.5"
prost = "0.11"
prost-types = "0.12.3"
hex-literal = "0.4.1"
hex = "0.4.3"
ethabi = "18.0.0"
tycho-substreams = {path ="crates/tycho-substreams"}
[profile.release]
lto = true
opt-level = 's'
strip = "debuginfo"

View File

@@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2021"
[dependencies]
substreams-ethereum = "0.9.9"
substreams = "0.5"
prost = "0.11"
hex = "0.4.3"
substreams-ethereum.workspace = true
substreams.workspace = true
prost.workspace = true
hex.workspace = true
itertools = "0.12.0"

View File

@@ -63,6 +63,8 @@ pub fn store_balance_changes(deltas: BlockBalanceDeltas, store: impl StoreAdd<Bi
});
}
type TxAggregatedBalances = HashMap<Vec<u8>, (Transaction, HashMap<Vec<u8>, BalanceChange>)>;
/// Aggregates absolute balances per transaction and token.
///
/// ## Arguments
@@ -82,7 +84,7 @@ pub fn store_balance_changes(deltas: BlockBalanceDeltas, store: impl StoreAdd<Bi
pub fn aggregate_balances_changes(
balance_store: StoreDeltas,
deltas: BlockBalanceDeltas,
) -> HashMap<Vec<u8>, (Transaction, HashMap<Vec<u8>, BalanceChange>)> {
) -> TxAggregatedBalances {
balance_store
.deltas
.into_iter()
@@ -207,9 +209,9 @@ mod tests {
let token_1 = hex::decode("babe00").unwrap();
let t0_key =
format!("{}:{}", String::from_utf8(comp_id.clone()).unwrap(), hex::encode(&token_0));
format!("{}:{}", String::from_utf8(comp_id.clone()).unwrap(), hex::encode(token_0));
let t1_key =
format!("{}:{}", String::from_utf8(comp_id.clone()).unwrap(), hex::encode(&token_1));
format!("{}:{}", String::from_utf8(comp_id.clone()).unwrap(), hex::encode(token_1));
StoreDeltas {
deltas: vec![
StoreDelta {
@@ -283,12 +285,12 @@ mod tests {
let res_0 = store.get_last(format!(
"{}:{}",
String::from_utf8(comp_id.clone()).unwrap(),
hex::encode(&token_0)
hex::encode(token_0)
));
let res_1 = store.get_last(format!(
"{}:{}",
String::from_utf8(comp_id.clone()).unwrap(),
hex::encode(&token_1)
hex::encode(token_1)
));
assert_eq!(res_0, Some(BigInt::from_str("+999").unwrap()));

View File

@@ -49,11 +49,7 @@ impl InterimContractChange {
balance: vec![],
code: vec![],
slots: Default::default(),
change: if creation {
tycho::ChangeType::Creation.into()
} else {
tycho::ChangeType::Update.into()
},
change: if creation { tycho::ChangeType::Creation } else { tycho::ChangeType::Update },
}
}
}

View File

@@ -7,9 +7,11 @@ use std::rc::Rc;
use substreams::prelude::{BigInt, StoreDelete, StoreGet, StoreNew};
use substreams::store::StoreAdd;
type BigIntStore = HashMap<String, Vec<(u64, BigInt)>>;
#[derive(Debug, Clone)]
pub struct MockStore {
data: Rc<RefCell<HashMap<String, Vec<(u64, BigInt)>>>>,
data: Rc<RefCell<BigIntStore>>,
}
impl StoreDelete for MockStore {

File diff suppressed because it is too large Load Diff

View File

@@ -8,18 +8,18 @@ name = "substreams_ethereum_balancer"
crate-type = ["cdylib"]
[dependencies]
substreams = "0.5"
substreams-ethereum = "0.9.9"
prost = "0.11"
hex-literal = "0.4.1"
ethabi = "18.0.0"
hex = "0.4.2"
substreams.workspace = true
substreams-ethereum.workspace = true
prost.workspace = true
prost-types.workspace = true
hex-literal.workspace = true
ethabi.workspace = true
hex.workspace = true
bytes = "1.5.0"
anyhow = "1.0.75"
prost-types = "0.12.3"
num-bigint = "0.4.4"
itertools = "0.12.0"
tycho-substreams = {path ="../crates/tycho-substreams"}
tycho-substreams.workspace = true
[build-dependencies]
anyhow = "1"

View File

@@ -172,7 +172,7 @@ pub fn map_changes(
let tx = tx_component.tx.as_ref().unwrap();
transaction_contract_changes
.entry(tx.index)
.or_insert_with(|| TransactionContractChanges::new(&tx))
.or_insert_with(|| TransactionContractChanges::new(tx))
.component_changes
.extend_from_slice(&tx_component.components);
});
@@ -188,7 +188,7 @@ pub fn map_changes(
.entry(tx.index)
.or_insert_with(|| TransactionContractChanges::new(&tx))
.balance_changes
.extend(balances.into_iter().map(|(_, change)| change));
.extend(balances.into_values());
});
// Extract and insert any storage changes that happened for any of the components.
@@ -196,7 +196,7 @@ pub fn map_changes(
&block,
|addr| {
components_store
.get_last(format!("pool:{0}", hex::encode(&addr)))
.get_last(format!("pool:{0}", hex::encode(addr)))
.is_some()
},
&mut transaction_contract_changes,

View File

@@ -53,7 +53,7 @@ pub fn address_map(
abi::weighted_pool_factory::events::PoolCreated::match_and_decode(log)?;
Some(
ProtocolComponent::at_contract(&pool_created.pool, &tx)
ProtocolComponent::at_contract(&pool_created.pool, tx)
.with_tokens(&create_call.tokens)
.with_attributes(&[
("pool_type", "WeightedPoolFactory".as_bytes()),
@@ -72,7 +72,7 @@ pub fn address_map(
abi::composable_stable_pool_factory::events::PoolCreated::match_and_decode(log)?;
Some(
ProtocolComponent::at_contract(&pool_created.pool, &tx)
ProtocolComponent::at_contract(&pool_created.pool, tx)
.with_tokens(&create_call.tokens)
.with_attributes(&[("pool_type", "ComposableStablePoolFactory".as_bytes())])
.as_swap_type("balancer_pool", ImplementationType::Vm),
@@ -85,7 +85,7 @@ pub fn address_map(
abi::erc_linear_pool_factory::events::PoolCreated::match_and_decode(log)?;
Some(
ProtocolComponent::at_contract(&pool_created.pool, &tx)
ProtocolComponent::at_contract(&pool_created.pool, tx)
.with_tokens(&[create_call.main_token, create_call.wrapped_token])
.with_attributes(&[
("pool_type", "ERC4626LinearPoolFactory".as_bytes()),
@@ -104,7 +104,7 @@ pub fn address_map(
abi::euler_linear_pool_factory::events::PoolCreated::match_and_decode(log)?;
Some(
ProtocolComponent::at_contract(&pool_created.pool, &tx)
ProtocolComponent::at_contract(&pool_created.pool, tx)
.with_tokens(&[create_call.main_token, create_call.wrapped_token])
.with_attributes(&[
("pool_type", "EulerLinearPoolFactory".as_bytes()),
@@ -170,7 +170,7 @@ pub fn address_map(
abi::silo_linear_pool_factory::events::PoolCreated::match_and_decode(log)?;
Some(
ProtocolComponent::at_contract(&pool_created.pool, &tx)
ProtocolComponent::at_contract(&pool_created.pool, tx)
.with_tokens(&[create_call.main_token, create_call.wrapped_token])
.with_attributes(&[
("pool_type", "SiloLinearPoolFactory".as_bytes()),
@@ -189,7 +189,7 @@ pub fn address_map(
abi::yearn_linear_pool_factory::events::PoolCreated::match_and_decode(log)?;
Some(
ProtocolComponent::at_contract(&pool_created.pool, &tx)
ProtocolComponent::at_contract(&pool_created.pool, tx)
.with_tokens(&[create_call.main_token, create_call.wrapped_token])
.with_attributes(&[
("pool_type", "YearnLinearPoolFactory".as_bytes()),
@@ -210,7 +210,7 @@ pub fn address_map(
abi::weighted_pool_tokens_factory::events::PoolCreated::match_and_decode(log)?;
Some(
ProtocolComponent::at_contract(&pool_created.pool, &tx)
ProtocolComponent::at_contract(&pool_created.pool, tx)
.with_tokens(&create_call.tokens)
.with_attributes(&[
("pool_type", "WeightedPool2TokensFactory".as_bytes()),

View File

@@ -9,5 +9,6 @@ trailing_semicolon = false
use_field_init_shorthand = true
chain_width = 40
ignore = [
"src/pb",
"*/pb",
"*/abi",
]