diff --git a/.github/workflows/test.yml b/.github/workflows/evm.yml similarity index 92% rename from .github/workflows/test.yml rename to .github/workflows/evm.yml index c64c94f..c75f40d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/evm.yml @@ -1,6 +1,9 @@ -name: test +name: test evm -on: workflow_dispatch +on: + push: + paths: + - "evm/**" env: FOUNDRY_PROFILE: ci diff --git a/.github/workflows/substream.cd.yaml b/.github/workflows/substream.cd.yaml new file mode 100644 index 0000000..8e99d96 --- /dev/null +++ b/.github/workflows/substream.cd.yaml @@ -0,0 +1,45 @@ +name: Substreams CD + +on: + push: + tags: + - "ethereum-*" + workflow_dispatch: + inputs: + package: + required: true + description: "Package to build" + +jobs: + Release: + name: Release ${{ inputs.package }} + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Setup toolchain + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: stable + targets: wasm32-unknown-unknown + + - name: Setup Rust Cache + uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + + - name: Install Substreams CLI + run: | + # Use correct binary for your platform + LINK=$(curl -s https://api.github.com/repos/streamingfast/substreams/releases/latest | awk "/download.url.*linux_$(uname -m)/ {print \$2}" | sed 's/"//g') + curl -L "$LINK" | tar zxf - -C /usr/local/bin + chmod +x /usr/local/bin/substreams + substreams --version + + - name: Run checks + run: | + cd substreams + ./release.sh ${{ inputs.package }} diff --git a/.github/workflows/substream.ci.yaml b/.github/workflows/substream.ci.yaml new file mode 100644 index 0000000..32c2aee --- /dev/null +++ b/.github/workflows/substream.ci.yaml @@ -0,0 +1,59 @@ +name: Substreams CI + +on: + push: + paths: + - "substreams/**" + +jobs: + lint: + name: Substreams Lint + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Setup toolchain + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: nightly + components: clippy, rustfmt + + - name: Setup Rust Cache + uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + + - name: Run checks + run: | + cd substreams + cargo +nightly fmt -- --check + cargo +nightly clippy --all --all-features --all-targets -- -D warnings + + test: + name: Substreams Test + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Setup toolchain + uses: dtolnay/rust-toolchain@v1 + with: + toolchain: stable + targets: wasm32-unknown-unknown + + - name: Setup Rust Cache + uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + + - name: Run checks + run: | + cd substreams + cargo build --target wasm32-unknown-unknown --all-targets --all-features + cargo test --workspace --all-targets --all-features diff --git a/crates/tycho-substreams/Cargo.toml b/crates/tycho-substreams/Cargo.toml deleted file mode 100644 index cc0f7bc..0000000 --- a/crates/tycho-substreams/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "tycho-substreams" -version = "0.1.0" -edition = "2021" - -[dependencies] -substreams-ethereum = "0.9.9" -substreams = "0.5" -prost = "0.11" -hex = "0.4.3" -itertools = "0.12.0" \ No newline at end of file diff --git a/crates/tycho-substreams/Cargo.lock b/substreams/Cargo.lock similarity index 87% rename from crates/tycho-substreams/Cargo.lock rename to substreams/Cargo.lock index cd827d8..f89bb92 100644 --- a/crates/tycho-substreams/Cargo.lock +++ b/substreams/Cargo.lock @@ -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,23 +189,69 @@ 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", +] + +[[package]] +name = "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 = "ethereum-types" 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 +273,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 +342,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 +384,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 +585,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 +617,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 +631,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 +658,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 +679,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 +875,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 +908,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c04307913a355aaf2a1bb7186d4bc7e36875f3d4aff77b47e83f1b63b24da55" dependencies = [ "anyhow", - "ethabi", + "ethabi 17.2.0", "heck", "hex", "prettyplease", @@ -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", ] diff --git a/substreams/Cargo.toml b/substreams/Cargo.toml new file mode 100644 index 0000000..8bcd85d --- /dev/null +++ b/substreams/Cargo.toml @@ -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" \ No newline at end of file diff --git a/substreams/check.sh b/substreams/check.sh new file mode 100755 index 0000000..1821d18 --- /dev/null +++ b/substreams/check.sh @@ -0,0 +1,6 @@ +set -e + +cargo +nightly fmt -- --check +cargo +nightly clippy --all --all-features --all-targets -- -D warnings +cargo build --target wasm32-unknown-unknown --all-targets --all-features +cargo test --workspace --all-targets --all-features diff --git a/substreams/crates/tycho-substreams/Cargo.toml b/substreams/crates/tycho-substreams/Cargo.toml new file mode 100644 index 0000000..3908f81 --- /dev/null +++ b/substreams/crates/tycho-substreams/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "tycho-substreams" +version = "0.1.0" +edition = "2021" + +[dependencies] +substreams-ethereum.workspace = true +substreams.workspace = true +prost.workspace = true +hex.workspace = true +itertools = "0.12.0" \ No newline at end of file diff --git a/crates/tycho-substreams/Readme.md b/substreams/crates/tycho-substreams/Readme.md similarity index 75% rename from crates/tycho-substreams/Readme.md rename to substreams/crates/tycho-substreams/Readme.md index 56b374b..20f868b 100644 --- a/crates/tycho-substreams/Readme.md +++ b/substreams/crates/tycho-substreams/Readme.md @@ -13,6 +13,6 @@ directory: ```bash buf generate \ --path tycho \ - --template ../crates/tycho-substreams/buf.gen.yaml \ - --output ../crates/tycho-substreams/ + --template ../substreams/crates/tycho-substreams/buf.gen.yaml \ + --output ../substreams/crates/tycho-substreams/ ``` \ No newline at end of file diff --git a/crates/tycho-substreams/buf.gen.yaml b/substreams/crates/tycho-substreams/buf.gen.yaml similarity index 100% rename from crates/tycho-substreams/buf.gen.yaml rename to substreams/crates/tycho-substreams/buf.gen.yaml diff --git a/crates/tycho-substreams/src/balances.rs b/substreams/crates/tycho-substreams/src/balances.rs similarity index 91% rename from crates/tycho-substreams/src/balances.rs rename to substreams/crates/tycho-substreams/src/balances.rs index 8046fe1..862e1a2 100644 --- a/crates/tycho-substreams/src/balances.rs +++ b/substreams/crates/tycho-substreams/src/balances.rs @@ -3,21 +3,21 @@ //! //! To aggregate relative balances changes to absolute balances the general approach is: //! -//! 1. Use a map function that will extract a `BlockBalanceDeltas` message. BalanceDeltas -//! within this message are required to have increasing ordinals so that -//! the order of relative balance changes is unambiguous. -//! 2. Store the balances changes with a store handler. You can use the -//! `store_balance_changes` library method directly for this. -//! 3. In the output module, use aggregate_balance_changes to receive an -//! aggregated map of absolute balances. -//! +//! 1. Use a map function that will extract a `BlockBalanceDeltas` message. BalanceDeltas within +//! this message are required to have increasing ordinals so that the order of relative balance +//! changes is unambiguous. +//! 2. Store the balances changes with a store handler. You can use the `store_balance_changes` +//! library method directly for this. +//! 3. In the output module, use aggregate_balance_changes to receive an aggregated map of absolute +//! balances. use crate::pb::tycho::evm::v1::{BalanceChange, BlockBalanceDeltas, Transaction}; use itertools::Itertools; -use std::collections::HashMap; -use std::str::FromStr; -use substreams::key; -use substreams::pb::substreams::StoreDeltas; -use substreams::prelude::{BigInt, StoreAdd}; +use std::{collections::HashMap, str::FromStr}; +use substreams::{ + key, + pb::substreams::StoreDeltas, + prelude::{BigInt, StoreAdd}, +}; /// Store relative balances changes in a additive manner. /// @@ -25,9 +25,9 @@ use substreams::prelude::{BigInt, StoreAdd}; /// /// ## Arguments /// -/// * `deltas` - A `BlockBalanceDeltas` message containing the relative balances changes. -/// Note: relative balance deltas must have strictly increasing ordinals per token -/// address, will panic otherwise. +/// * `deltas` - A `BlockBalanceDeltas` message containing the relative balances changes. Note: +/// relative balance deltas must have strictly increasing ordinals per token address, will panic +/// otherwise. /// * `store` - An AddStore that will add relative balance changes. /// /// This method is meant to be used in combination with `aggregate_balances_changes` @@ -63,11 +63,12 @@ pub fn store_balance_changes(deltas: BlockBalanceDeltas, store: impl StoreAdd, (Transaction, HashMap, BalanceChange>)>; + /// Aggregates absolute balances per transaction and token. /// /// ## Arguments -/// * `balance_store` - A `StoreDeltas` with all changes that occured in the source -/// store module. +/// * `balance_store` - A `StoreDeltas` with all changes that occured in the source store module. /// * `deltas` - A `BlockBalanceDeltas` message containing the relative balances changes. /// /// Reads absolute balance values from the additive store (see `store_balance_changes` @@ -82,7 +83,7 @@ pub fn store_balance_changes(deltas: BlockBalanceDeltas, store: impl StoreAdd HashMap, (Transaction, HashMap, BalanceChange>)> { +) -> TxAggregatedBalances { balance_store .deltas .into_iter() @@ -125,10 +126,11 @@ pub fn aggregate_balances_changes( #[cfg(test)] mod tests { use super::*; - use crate::mock_store::MockStore; - use crate::pb::tycho::evm::v1::{BalanceDelta, Transaction}; - use substreams::pb::substreams::StoreDelta; - use substreams::prelude::{StoreGet, StoreNew}; + use crate::{mock_store::MockStore, pb::tycho::evm::v1::BalanceDelta}; + use substreams::{ + pb::substreams::StoreDelta, + prelude::{StoreGet, StoreNew}, + }; fn block_balance_deltas() -> BlockBalanceDeltas { let comp_id = "0x42c0ffee" @@ -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())); diff --git a/crates/tycho-substreams/src/contract.rs b/substreams/crates/tycho-substreams/src/contract.rs similarity index 93% rename from crates/tycho-substreams/src/contract.rs rename to substreams/crates/tycho-substreams/src/contract.rs index f054380..a99fd60 100644 --- a/crates/tycho-substreams/src/contract.rs +++ b/substreams/crates/tycho-substreams/src/contract.rs @@ -10,9 +10,10 @@ /// more [here](https://streamingfastio.medium.com/new-block-model-to-accelerate-chain-integration-9f65126e5425) use std::collections::HashMap; -use substreams_ethereum::pb::eth; -use substreams_ethereum::pb::eth::v2::block::DetailLevel; -use substreams_ethereum::pb::eth::v2::StorageChange; +use substreams_ethereum::pb::{ + eth, + eth::v2::{block::DetailLevel, StorageChange}, +}; use crate::pb::tycho::evm::v1::{self as tycho}; @@ -49,11 +50,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 }, } } } @@ -82,7 +79,8 @@ impl From for tycho::ContractChange { /// ## Arguments /// /// * `block` - The block to extract changes from. Must be the extended block model. -/// * `inclusion_predicate` - A predicate function that determines if a contract address is relevant. +/// * `inclusion_predicate` - A predicate function that determines if a contract address is +/// relevant. /// * `transaction_contract_changes` - A mutable map to store the contract changes in. /// /// ## Panics @@ -193,9 +191,9 @@ pub fn extract_contract_changes bool>( .extend_from_slice(&code_change.new_code); }); - if !storage_changes.is_empty() - || !balance_changes.is_empty() - || !code_changes.is_empty() + if !storage_changes.is_empty() || + !balance_changes.is_empty() || + !code_changes.is_empty() { transaction_contract_changes .entry(block_tx.index.into()) diff --git a/crates/tycho-substreams/src/lib.rs b/substreams/crates/tycho-substreams/src/lib.rs similarity index 100% rename from crates/tycho-substreams/src/lib.rs rename to substreams/crates/tycho-substreams/src/lib.rs diff --git a/crates/tycho-substreams/src/mock_store.rs b/substreams/crates/tycho-substreams/src/mock_store.rs similarity index 90% rename from crates/tycho-substreams/src/mock_store.rs rename to substreams/crates/tycho-substreams/src/mock_store.rs index a1c0cd2..70b252b 100644 --- a/crates/tycho-substreams/src/mock_store.rs +++ b/substreams/crates/tycho-substreams/src/mock_store.rs @@ -1,15 +1,17 @@ //! Contains a mock store for internal testing. //! //! Might make this public alter to users can test their store handlers. -use std::cell::RefCell; -use std::collections::HashMap; -use std::rc::Rc; -use substreams::prelude::{BigInt, StoreDelete, StoreGet, StoreNew}; -use substreams::store::StoreAdd; +use std::{cell::RefCell, collections::HashMap, rc::Rc}; +use substreams::{ + prelude::{BigInt, StoreDelete, StoreGet, StoreNew}, + store::StoreAdd, +}; + +type BigIntStore = HashMap>; #[derive(Debug, Clone)] pub struct MockStore { - data: Rc>>>, + data: Rc>, } impl StoreDelete for MockStore { diff --git a/crates/tycho-substreams/src/models.rs b/substreams/crates/tycho-substreams/src/models.rs similarity index 100% rename from crates/tycho-substreams/src/models.rs rename to substreams/crates/tycho-substreams/src/models.rs diff --git a/crates/tycho-substreams/src/pb/mod.rs b/substreams/crates/tycho-substreams/src/pb/mod.rs similarity index 100% rename from crates/tycho-substreams/src/pb/mod.rs rename to substreams/crates/tycho-substreams/src/pb/mod.rs diff --git a/crates/tycho-substreams/src/pb/tycho.evm.v1.rs b/substreams/crates/tycho-substreams/src/pb/tycho.evm.v1.rs similarity index 100% rename from crates/tycho-substreams/src/pb/tycho.evm.v1.rs rename to substreams/crates/tycho-substreams/src/pb/tycho.evm.v1.rs diff --git a/substreams/ethereum-balancer/Cargo.lock b/substreams/ethereum-balancer/Cargo.lock deleted file mode 100644 index e2d81a0..0000000 --- a/substreams/ethereum-balancer/Cargo.lock +++ /dev/null @@ -1,1281 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - -[[package]] -name = "anyhow" -version = "1.0.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bigdecimal" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "bytes" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "cpufeatures" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" -dependencies = [ - "libc", -] - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] - -[[package]] -name = "either" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "ethabi" -version = "17.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4966fba78396ff92db3b817ee71143eccd98acf0f876b8d600e585a670c5d1b" -dependencies = [ - "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", - "serde", - "serde_json", - "sha3", - "thiserror", - "uint", -] - -[[package]] -name = "ethbloom" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11da94e443c60508eb62cf256243a64da87304c2802ac2528847f79d750007ef" -dependencies = [ - "crunchy", - "fixed-hash 0.7.0", - "impl-rlp", - "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", -] - -[[package]] -name = "ethereum-types" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2827b94c556145446fcce834ca86b7abf0c39a805883fe20e72c5bfdb5a0dc6" -dependencies = [ - "ethbloom 0.12.1", - "fixed-hash 0.7.0", - "impl-rlp", - "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", -] - -[[package]] -name = "fastrand" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" - -[[package]] -name = "fixed-hash" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" -dependencies = [ - "byteorder", - "rand", - "rustc-hex", - "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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hex-literal" -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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - -[[package]] -name = "impl-codec" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" -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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itertools" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" - -[[package]] -name = "keccak" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.151" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" - -[[package]] -name = "linux-raw-sys" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "multimap" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" - -[[package]] -name = "num-bigint" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "pad" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ad9b889f1b12e0b9ee24db044b5129150d5eada288edc800f789928dc8c0e3" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "parity-scale-codec" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" -dependencies = [ - "arrayvec", - "bitvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "petgraph" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" -dependencies = [ - "fixedbitset", - "indexmap", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "prettyplease" -version = "0.1.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" -dependencies = [ - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "primitive-types" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a" -dependencies = [ - "fixed-hash 0.7.0", - "impl-codec", - "impl-rlp", - "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", -] - -[[package]] -name = "proc-macro-crate" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" -dependencies = [ - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "prost" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" -dependencies = [ - "bytes", - "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]] -name = "prost-build" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" -dependencies = [ - "bytes", - "heck", - "itertools 0.10.5", - "lazy_static", - "log", - "multimap", - "petgraph", - "prettyplease", - "prost 0.11.9", - "prost-types 0.11.9", - "regex", - "syn 1.0.109", - "tempfile", - "which", -] - -[[package]] -name = "prost-derive" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" -dependencies = [ - "anyhow", - "itertools 0.10.5", - "proc-macro2", - "quote", - "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.41", -] - -[[package]] -name = "prost-types" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" -dependencies = [ - "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]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - -[[package]] -name = "rlp" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" -dependencies = [ - "bytes", - "rustc-hex", -] - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustix" -version = "0.38.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" -dependencies = [ - "bitflags 2.4.1", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - -[[package]] -name = "ryu" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" - -[[package]] -name = "serde" -version = "1.0.193" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.193" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.41", -] - -[[package]] -name = "serde_json" -version = "1.0.108" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest", - "keccak", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "substreams" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e3524a4e2931ff6cd58783e62adbd7e44f461752eca0c423793cfb462351f24" -dependencies = [ - "anyhow", - "bigdecimal", - "hex", - "hex-literal 0.3.4", - "num-bigint", - "num-integer", - "num-traits", - "pad", - "prost 0.11.9", - "prost-build", - "prost-types 0.11.9", - "substreams-macro", - "thiserror", -] - -[[package]] -name = "substreams-ethereum" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48f45dc04be50b7ca08d6d5c4560ee3eeba16ccaa1c124d0361bb30b5b84e28b" -dependencies = [ - "getrandom", - "num-bigint", - "substreams", - "substreams-ethereum-abigen", - "substreams-ethereum-core", - "substreams-ethereum-derive", -] - -[[package]] -name = "substreams-ethereum-abigen" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c04307913a355aaf2a1bb7186d4bc7e36875f3d4aff77b47e83f1b63b24da55" -dependencies = [ - "anyhow", - "ethabi 17.2.0", - "heck", - "hex", - "prettyplease", - "proc-macro2", - "quote", - "substreams-ethereum-core", - "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.0", - "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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db9048cc9a66873ab7069ef958c2684994e6ee323da49c186b19156fdb4ca131" -dependencies = [ - "bigdecimal", - "ethabi 17.2.0", - "getrandom", - "num-bigint", - "prost 0.11.9", - "prost-build", - "prost-types 0.11.9", - "substreams", -] - -[[package]] -name = "substreams-ethereum-derive" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e862928bee8653f5c9291ac619c8dc0da14ca61d8cd8d89b3acdbbde4d0bf304" -dependencies = [ - "ethabi 17.2.0", - "heck", - "hex", - "num-bigint", - "proc-macro2", - "quote", - "substreams-ethereum-abigen", - "syn 1.0.109", -] - -[[package]] -name = "substreams-macro" -version = "0.5.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63c2b15adf5b4d7a6d1a73c73df951a6b2df6fbb4f0b41304dc28c5550ce0ed0" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "thiserror", -] - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "tempfile" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" -dependencies = [ - "cfg-if", - "fastrand", - "redox_syscall", - "rustix", - "windows-sys 0.48.0", -] - -[[package]] -name = "thiserror" -version = "1.0.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.41", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - -[[package]] -name = "tycho-substreams" -version = "0.1.0" -dependencies = [ - "hex", - "itertools 0.12.0", - "prost 0.11.9", - "substreams", - "substreams-ethereum", -] - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unicode-width" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.0", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows-targets" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" -dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" - -[[package]] -name = "winnow" -version = "0.5.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b5c3db89721d50d0e2a673f5043fc4722f76dcc352d7b1ab8b8288bed4ed2c5" -dependencies = [ - "memchr", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] diff --git a/substreams/ethereum-balancer/Cargo.toml b/substreams/ethereum-balancer/Cargo.toml index 0a964e5..2aca957 100644 --- a/substreams/ethereum-balancer/Cargo.toml +++ b/substreams/ethereum-balancer/Cargo.toml @@ -1,25 +1,25 @@ [package] -name = "substreams-ethereum-balancer" +name = "ethereum-balancer" version = "0.1.0" edition = "2021" [lib] -name = "substreams_ethereum_balancer" +name = "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" diff --git a/substreams/ethereum-balancer/src/modules.rs b/substreams/ethereum-balancer/src/modules.rs index 728a53e..b1747b1 100644 --- a/substreams/ethereum-balancer/src/modules.rs +++ b/substreams/ethereum-balancer/src/modules.rs @@ -2,16 +2,15 @@ use crate::{abi, pool_factories}; use anyhow::Result; use itertools::Itertools; use std::collections::HashMap; -use substreams::hex; -use substreams::pb::substreams::StoreDeltas; -use substreams::store::{ - StoreAdd, StoreAddBigInt, StoreAddInt64, StoreGet, StoreGetInt64, StoreNew, +use substreams::{ + hex, + pb::substreams::StoreDeltas, + store::{StoreAdd, StoreAddBigInt, StoreAddInt64, StoreGet, StoreGetInt64, StoreNew}, +}; +use substreams_ethereum::{pb::eth, Event}; +use tycho_substreams::{ + balances::aggregate_balances_changes, contract::extract_contract_changes, prelude::*, }; -use substreams_ethereum::pb::eth; -use substreams_ethereum::Event; -use tycho_substreams::balances::aggregate_balances_changes; -use tycho_substreams::contract::extract_contract_changes; -use tycho_substreams::prelude::*; const VAULT_ADDRESS: &[u8] = &hex!("BA12222222228d8Ba445958a75a0704d566BF2C8"); @@ -37,10 +36,7 @@ pub fn map_pools_created(block: eth::v2::Block) -> Result>(); if !components.is_empty() { - Some(TransactionProtocolComponents { - tx: Some(tx.into()), - components, - }) + Some(TransactionProtocolComponents { tx: Some(tx.into()), components }) } else { None } @@ -63,8 +59,8 @@ pub fn store_pools_created(map: BlockTransactionProtocolComponents, store: Store ); } -/// Since the `PoolBalanceChanged` and `Swap` events administer only deltas, we need to leverage a map and a -/// store to be able to tally up final balances for tokens in a pool. +/// Since the `PoolBalanceChanged` and `Swap` events administer only deltas, we need to leverage a +/// map and a store to be able to tally up final balances for tokens in a pool. #[substreams::handlers::map] pub fn map_balance_deltas( block: eth::v2::Block, @@ -79,12 +75,10 @@ pub fn map_balance_deltas( if let Some(ev) = abi::vault::events::PoolBalanceChanged::match_and_decode(vault_log.log) { - let component_id = format!( - "0x{}", - String::from_utf8(ev.pool_id[..20].to_vec()).unwrap() - ) - .as_bytes() - .to_vec(); + let component_id = + format!("0x{}", String::from_utf8(ev.pool_id[..20].to_vec()).unwrap()) + .as_bytes() + .to_vec(); if store .get_last(format!("pool:{}", hex::encode(&component_id))) @@ -101,12 +95,10 @@ pub fn map_balance_deltas( } } } else if let Some(ev) = abi::vault::events::Swap::match_and_decode(vault_log.log) { - let component_id = format!( - "0x{}", - String::from_utf8(ev.pool_id[..20].to_vec()).unwrap() - ) - .as_bytes() - .to_vec(); + let component_id = + format!("0x{}", String::from_utf8(ev.pool_id[..20].to_vec()).unwrap()) + .as_bytes() + .to_vec(); if store .get_last(format!("pool:{}", hex::encode(&component_id))) @@ -149,8 +141,8 @@ pub fn store_balance_changes(deltas: BlockBalanceDeltas, store: StoreAddBigInt) /// Every contract change is grouped by transaction index via the `transaction_contract_changes` /// map. Each block of code will extend the `TransactionContractChanges` struct with the /// cooresponding changes (balance, component, contract), inserting a new one if it doesn't exist. -/// At the very end, the map can easily be sorted by index to ensure the final `BlockContractChanges` -/// is ordered by transactions properly. +/// At the very end, the map can easily be sorted by index to ensure the final +/// `BlockContractChanges` is ordered by transactions properly. #[substreams::handlers::map] pub fn map_changes( block: eth::v2::Block, @@ -172,15 +164,15 @@ 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); }); // Balance changes are gathered by the `StoreDelta` based on `PoolBalanceChanged` creating - // `BlockBalanceDeltas`. We essentially just process the changes that occurred to the `store` this - // block. Then, these balance changes are merged onto the existing map of tx contract changes, - // inserting a new one if it doesn't exist. + // `BlockBalanceDeltas`. We essentially just process the changes that occurred to the `store` + // this block. Then, these balance changes are merged onto the existing map of tx contract + // changes, inserting a new one if it doesn't exist. aggregate_balances_changes(balance_store, deltas) .into_iter() .for_each(|(_, (tx, balances))| { @@ -188,7 +180,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 +188,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, @@ -210,9 +202,9 @@ pub fn map_changes( .drain() .sorted_unstable_by_key(|(index, _)| *index) .filter_map(|(_, change)| { - if change.contract_changes.is_empty() - && change.component_changes.is_empty() - && change.balance_changes.is_empty() + if change.contract_changes.is_empty() && + change.component_changes.is_empty() && + change.balance_changes.is_empty() { None } else { diff --git a/substreams/ethereum-balancer/src/pool_factories.rs b/substreams/ethereum-balancer/src/pool_factories.rs index 16691c3..5c2cd59 100644 --- a/substreams/ethereum-balancer/src/pool_factories.rs +++ b/substreams/ethereum-balancer/src/pool_factories.rs @@ -1,8 +1,9 @@ use crate::abi; -use substreams::hex; -use substreams::scalar::BigInt; -use substreams_ethereum::pb::eth::v2::{Call, Log}; -use substreams_ethereum::{Event, Function}; +use substreams::{hex, scalar::BigInt}; +use substreams_ethereum::{ + pb::eth::v2::{Call, Log}, + Event, Function, +}; use tycho_substreams::prelude::*; /// This trait defines some helpers for serializing and deserializing `Vec { - // let create_call = abi::managed_pool_factory::functions::Create::match_and_decode(call)?; + // let create_call = + // abi::managed_pool_factory::functions::Create::match_and_decode(call)?; // let pool_created = // abi::managed_pool_factory::events::PoolCreated::match_and_decode(log)?; @@ -170,13 +178,15 @@ 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()), ( "upper_target", - &create_call.upper_target.to_signed_bytes_be(), + &create_call + .upper_target + .to_signed_bytes_be(), ), ]) .as_swap_type("balancer_pool", ImplementationType::Vm), @@ -189,13 +199,15 @@ 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()), ( "upper_target", - &create_call.upper_target.to_signed_bytes_be(), + &create_call + .upper_target + .to_signed_bytes_be(), ), ]) .as_swap_type("balancer_pool", ImplementationType::Vm), @@ -210,7 +222,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()), diff --git a/substreams/ethereum-balancer/substreams.yaml b/substreams/ethereum-balancer/substreams.yaml index 66da244..06f2ee7 100644 --- a/substreams/ethereum-balancer/substreams.yaml +++ b/substreams/ethereum-balancer/substreams.yaml @@ -1,20 +1,12 @@ specVersion: v0.1.0 package: - name: "substreams_ethereum_balancer" + name: "ethereum_balancer" version: v0.1.0 -protobuf: - files: - - tycho/evm/v1/vm.proto - - tycho/evm/v1/common.proto - - tycho/evm/v1/utils.proto - importPaths: - - ../../proto - binaries: default: type: wasm/rust-v1 - file: target/wasm32-unknown-unknown/release/substreams_ethereum_balancer.wasm + file: ../target/wasm32-unknown-unknown/release/ethereum_balancer.wasm modules: - name: map_pools_created diff --git a/substreams/release.sh b/substreams/release.sh new file mode 100755 index 0000000..e011e95 --- /dev/null +++ b/substreams/release.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# Allows releasing multiple substream packages within the same repo. +# To trigger a release simply create a tag with [package-name]-[semver]. +# The script will look for these tags, then infer which package needs to be built and +# released. + +# Try to get the tag name associated with the current HEAD commit +current_tag=$(git describe --tags --exact-match HEAD 2>/dev/null) + +if [ -n "$current_tag" ]; then + # If the HEAD is at a tag, extract the prefix and version + if [[ $current_tag =~ ^([a-zA-Z-]*-)?([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then + # Prefix without the trailing hyphen (if any) + package="${BASH_REMATCH[1]%?}" + # Semantic version + version="${BASH_REMATCH[2]}" + + cargo_version=$(cargo pkgid -p ethereum-balancer | cut -d# -f2 | cut -d: -f2) + if [[ "$cargo_version" != "$version" ]]; then + echo "Error: Cargo version: ${cargo_version} does not match tag version: ${version}!" + exit 1 + fi + # Check if the Git repository is dirty + if [ -n "$(git status --porcelain)" ]; then + echo "Error: The repository is dirty. Please commit or stash your changes." + exit 1 + fi + else + echo "Error: Current tag ($current_tag) does not match the expected format." + exit 1 + fi +else + # If the HEAD is not at a tag, construct the tag name with the pre-release postfix + if [ -z "$1" ]; then + echo "Error: package argument is required to create a pre release!" + exit 1 + fi + package=$1 + + version_prefix=$(git describe --tags --match "$package-*" --abbrev=0 2>/dev/null) + if [ -z "$version_prefix" ]; then + # If no tags are found in the history, default to version 0.0.1 + version_prefix="0.0.1" + fi + + # Get the short commit hash of the current HEAD + commit_hash=$(git rev-parse --short HEAD) + version="${version_prefix}-pre.${commit_hash}" +fi + +REPOSITORY=${REPOSITORY:-"s3://repo.propellerheads/substreams"} +repository_path="$REPOSITORY/$package/$package-$version.spkg" + +cargo build --target wasm32-unknown-unknown --release -p "$package" +mkdir -p ./target/spkg/ +substreams pack $package/substreams.yaml -o ./target/spkg/$package-$version.spkg +aws s3 cp ./target/spkg/$package-$version.spkg $repository_path + +echo "Released substreams package: '$repository_path'" \ No newline at end of file diff --git a/crates/tycho-substreams/rustfmt.toml b/substreams/rustfmt.toml similarity index 78% rename from crates/tycho-substreams/rustfmt.toml rename to substreams/rustfmt.toml index d0c0193..1f27a7b 100644 --- a/crates/tycho-substreams/rustfmt.toml +++ b/substreams/rustfmt.toml @@ -9,5 +9,6 @@ trailing_semicolon = false use_field_init_shorthand = true chain_width = 40 ignore = [ - "src/pb", + "crates/tycho-substreams/src/pb", + "ethereum-balancer/src/abi", ] \ No newline at end of file