Merge pull request #89 from propeller-heads/lp/uniswap-v2-be-encoding

feat: Convert uniswap v2 attributes to big endian encoding
This commit is contained in:
Louise Poole
2024-10-21 17:28:04 +02:00
committed by GitHub
7 changed files with 44 additions and 31 deletions

View File

@@ -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 }}

38
substreams/Cargo.lock generated
View File

@@ -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.2.1"
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"

View File

@@ -1,6 +1,6 @@
[package]
name = "substreams-ethereum-uniswap-v2"
version = "0.2.1"
name = "ethereum-uniswap-v2"
version = "0.3.0"
edition = "2021"
[lib]

View File

@@ -1,7 +1,7 @@
specVersion: v0.1.0
package:
name: "ethereum_uniswap_v2"
version: v0.2.1
version: v0.3.0
protobuf:
files:
@@ -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

View File

@@ -46,12 +46,12 @@ fn get_pools(block: &eth::Block, new_pools: &mut Vec<TransactionChanges>, 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: &eth::Block, new_pools: &mut Vec<TransactionChanges>, 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 {

View File

@@ -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(),
},
);

View File

@@ -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'"