fix: stop using buggy account_creations for creation tagging. (#201)

the `call.account_creations` field had been deprecated by Substreams because of some edge cases where a new account wasn't detected.
This commit removes the usage of this field in our sdk contract extraction logic and some others specific places. We decided to rely on the call type instead. This approach should be much more robust.

Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
This commit is contained in:
Zizou
2025-05-13 12:25:14 +02:00
committed by GitHub
parent ee41e63775
commit 52d502198e
7 changed files with 49 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "ethereum-sfrax"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
[lib]

View File

@@ -1,7 +1,7 @@
use crate::abi;
use anyhow::Result;
use itertools::Itertools;
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use substreams::{
hex,
pb::substreams::StoreDeltas,
@@ -87,7 +87,7 @@ pub fn map_relative_balances(
let address_bytes_be = vault_log.address();
let address_hex = format!("0x{}", hex::encode(address_bytes_be));
if store
.get_last(format!("pool:{}", address_hex))
.get_last(format!("pool:{address_hex}"))
.is_some()
{
deltas.extend_from_slice(&[
@@ -122,7 +122,7 @@ pub fn map_relative_balances(
let address_hex = format!("0x{}", hex::encode(address_bytes_be));
if store
.get_last(format!("pool:{}", address_hex))
.get_last(format!("pool:{address_hex}"))
.is_some()
{
deltas.extend_from_slice(&[
@@ -157,7 +157,7 @@ pub fn map_relative_balances(
let address_hex = format!("0x{}", hex::encode(address_bytes_be));
if store
.get_last(format!("pool:{}", address_hex))
.get_last(format!("pool:{address_hex}"))
.is_some()
{
deltas.extend_from_slice(&[BalanceDelta {
@@ -260,17 +260,11 @@ fn is_deployment_tx(tx: &eth::v2::TransactionTrace, vault_address: &[u8]) -> boo
let created_accounts = tx
.calls
.iter()
.flat_map(|call| {
call.account_creations
.iter()
.map(|ac| ac.account.to_owned())
})
.collect::<Vec<_>>();
.filter(|call| call.call_type() == eth::v2::CallType::Create)
.map(|call| call.address.clone())
.collect::<HashSet<_>>();
if let Some(deployed_address) = created_accounts.first() {
return deployed_address.as_slice() == vault_address;
}
false
created_accounts.contains(vault_address)
}
fn find_deployed_underlying_address(vault_address: &[u8]) -> Option<[u8; 20]> {