From 3639d8d7479fe00b48331610a31174f3a507fe73 Mon Sep 17 00:00:00 2001 From: Louise Poole Date: Thu, 17 Oct 2024 15:58:26 +0200 Subject: [PATCH 1/3] feat(uniswap_v2): encode attribute values with big endian encoding --- substreams/Cargo.lock | 2 +- substreams/ethereum-uniswap-v2/Cargo.toml | 2 +- substreams/ethereum-uniswap-v2/ethereum-uniswap-v2.yaml | 2 +- .../ethereum-uniswap-v2/src/modules/1_map_pool_created.rs | 6 +++--- .../ethereum-uniswap-v2/src/modules/3_map_pool_events.rs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/substreams/Cargo.lock b/substreams/Cargo.lock index b65aee5..318a23e 100644 --- a/substreams/Cargo.lock +++ b/substreams/Cargo.lock @@ -1041,7 +1041,7 @@ dependencies = [ [[package]] name = "substreams-ethereum-uniswap-v2" -version = "0.2.1" +version = "0.3.0" dependencies = [ "anyhow", "ethabi 18.0.0", diff --git a/substreams/ethereum-uniswap-v2/Cargo.toml b/substreams/ethereum-uniswap-v2/Cargo.toml index 1979ddd..8cebfb1 100644 --- a/substreams/ethereum-uniswap-v2/Cargo.toml +++ b/substreams/ethereum-uniswap-v2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substreams-ethereum-uniswap-v2" -version = "0.2.1" +version = "0.3.0" edition = "2021" [lib] diff --git a/substreams/ethereum-uniswap-v2/ethereum-uniswap-v2.yaml b/substreams/ethereum-uniswap-v2/ethereum-uniswap-v2.yaml index 3c247a6..4749c6a 100644 --- a/substreams/ethereum-uniswap-v2/ethereum-uniswap-v2.yaml +++ b/substreams/ethereum-uniswap-v2/ethereum-uniswap-v2.yaml @@ -1,7 +1,7 @@ specVersion: v0.1.0 package: name: "ethereum_uniswap_v2" - version: v0.2.1 + version: v0.3.0 protobuf: files: diff --git a/substreams/ethereum-uniswap-v2/src/modules/1_map_pool_created.rs b/substreams/ethereum-uniswap-v2/src/modules/1_map_pool_created.rs index 236a427..fe11ffe 100644 --- a/substreams/ethereum-uniswap-v2/src/modules/1_map_pool_created.rs +++ b/substreams/ethereum-uniswap-v2/src/modules/1_map_pool_created.rs @@ -46,12 +46,12 @@ fn get_pools(block: ð::Block, new_pools: &mut Vec, params attributes: vec![ Attribute { name: "reserve0".to_string(), - value: BigInt::from(0).to_signed_bytes_le(), + value: BigInt::from(0).to_signed_bytes_be(), change: ChangeType::Creation.into(), }, Attribute { name: "reserve1".to_string(), - value: BigInt::from(0).to_signed_bytes_le(), + value: BigInt::from(0).to_signed_bytes_be(), change: ChangeType::Creation.into(), }, ], @@ -64,7 +64,7 @@ fn get_pools(block: ð::Block, new_pools: &mut Vec, params // Trading Fee is hardcoded to 0.3%, saved as int in bps (basis points) Attribute { name: "fee".to_string(), - value: BigInt::from(30).to_signed_bytes_le(), + value: BigInt::from(30).to_signed_bytes_be(), change: ChangeType::Creation.into(), }, Attribute { diff --git a/substreams/ethereum-uniswap-v2/src/modules/3_map_pool_events.rs b/substreams/ethereum-uniswap-v2/src/modules/3_map_pool_events.rs index 5c428fa..8584913 100644 --- a/substreams/ethereum-uniswap-v2/src/modules/3_map_pool_events.rs +++ b/substreams/ethereum-uniswap-v2/src/modules/3_map_pool_events.rs @@ -104,7 +104,7 @@ fn handle_sync( name: attribute_name, value: reserve_bytes .clone() - .to_signed_bytes_le(), //TODO: Unify bytes encoding (either be or le) + .to_signed_bytes_be(), change: ChangeType::Update.into(), }, ); From 3c3b5195f748515e93ef9eaea71bab95b425d4f5 Mon Sep 17 00:00:00 2001 From: Louise Poole Date: Thu, 17 Oct 2024 19:07:46 +0200 Subject: [PATCH 2/3] fix: update uniswap v2 configs and package name --- substreams/Cargo.lock | 38 +++++++++---------- substreams/ethereum-uniswap-v2/Cargo.toml | 2 +- .../ethereum-uniswap-v2.yaml | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/substreams/Cargo.lock b/substreams/Cargo.lock index 318a23e..d9ccb97 100644 --- a/substreams/Cargo.lock +++ b/substreams/Cargo.lock @@ -288,6 +288,25 @@ dependencies = [ "uint", ] +[[package]] +name = "ethereum-uniswap-v2" +version = "0.3.0" +dependencies = [ + "anyhow", + "ethabi 18.0.0", + "getrandom", + "hex-literal 0.4.1", + "itertools 0.12.1", + "num-bigint", + "prost 0.11.9", + "serde", + "serde_qs", + "substreams", + "substreams-ethereum", + "substreams-helper", + "tycho-substreams", +] + [[package]] name = "fastrand" version = "2.0.1" @@ -1039,25 +1058,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "substreams-ethereum-uniswap-v2" -version = "0.3.0" -dependencies = [ - "anyhow", - "ethabi 18.0.0", - "getrandom", - "hex-literal 0.4.1", - "itertools 0.12.1", - "num-bigint", - "prost 0.11.9", - "serde", - "serde_qs", - "substreams", - "substreams-ethereum", - "substreams-helper", - "tycho-substreams", -] - [[package]] name = "substreams-ethereum-uniswap-v3" version = "0.2.1" diff --git a/substreams/ethereum-uniswap-v2/Cargo.toml b/substreams/ethereum-uniswap-v2/Cargo.toml index 8cebfb1..3cd92be 100644 --- a/substreams/ethereum-uniswap-v2/Cargo.toml +++ b/substreams/ethereum-uniswap-v2/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substreams-ethereum-uniswap-v2" +name = "ethereum-uniswap-v2" version = "0.3.0" edition = "2021" diff --git a/substreams/ethereum-uniswap-v2/ethereum-uniswap-v2.yaml b/substreams/ethereum-uniswap-v2/ethereum-uniswap-v2.yaml index 4749c6a..47f5b6b 100644 --- a/substreams/ethereum-uniswap-v2/ethereum-uniswap-v2.yaml +++ b/substreams/ethereum-uniswap-v2/ethereum-uniswap-v2.yaml @@ -15,7 +15,7 @@ protobuf: binaries: default: type: wasm/rust-v1 - file: ../../target/wasm32-unknown-unknown/substreams/ethereum_uniswap_v2.wasm + file: ../target/wasm32-unknown-unknown/release/ethereum_uniswap_v2.wasm modules: - name: map_pools_created From 5c38cd6fb3268b03b1267bfe9dfef23a0a8b6d22 Mon Sep 17 00:00:00 2001 From: Louise Poole Date: Thu, 17 Oct 2024 19:27:06 +0200 Subject: [PATCH 3/3] feat: improve substream release script Improvements include: - exit the script if any non-recoverable step fails - fix bug where cargo version was hardcoded to be detected in balancer package - allow optional input of substream config file. This is necessary for protocols with forks as they will have multiple configs in one directory --- .github/workflows/substream.cd.yaml | 6 +++++- substreams/release.sh | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/substream.cd.yaml b/.github/workflows/substream.cd.yaml index 8e99d96..cafe987 100644 --- a/.github/workflows/substream.cd.yaml +++ b/.github/workflows/substream.cd.yaml @@ -9,6 +9,10 @@ on: package: required: true description: "Package to build" + config_file: + required: false + description: "Path to the substreams configuration file" + default: "substreams.yaml" jobs: Release: @@ -42,4 +46,4 @@ jobs: - name: Run checks run: | cd substreams - ./release.sh ${{ inputs.package }} + ./release.sh ${{ inputs.package }} ${{ inputs.config_file }} diff --git a/substreams/release.sh b/substreams/release.sh index e011e95..7c55b91 100755 --- a/substreams/release.sh +++ b/substreams/release.sh @@ -16,7 +16,7 @@ if [ -n "$current_tag" ]; then # Semantic version version="${BASH_REMATCH[2]}" - cargo_version=$(cargo pkgid -p ethereum-balancer | cut -d# -f2 | cut -d: -f2) + cargo_version=$(cargo pkgid -p "$package" | 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 @@ -52,9 +52,18 @@ fi REPOSITORY=${REPOSITORY:-"s3://repo.propellerheads/substreams"} repository_path="$REPOSITORY/$package/$package-$version.spkg" +# Optional input for yaml file; defaults to substreams.yaml if not provided +yaml_file=${2:-"substreams.yaml"} + +if [[ ! -f "$package/$yaml_file" ]]; then + echo "Error: manifest reader: unable to stat input file $yaml_file: file does not exist." + exit 1 +fi + +set -e # Exit the script if any command fails cargo build --target wasm32-unknown-unknown --release -p "$package" mkdir -p ./target/spkg/ -substreams pack $package/substreams.yaml -o ./target/spkg/$package-$version.spkg +substreams pack "$package/$yaml_file" -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 +echo "Released substreams package: '$repository_path'"