Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Scraper stores input data from Ethereum transactions #4794

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rust/main/agents/scraper/migration/bin/generate_entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ impl Drop for PostgresDockerContainer {
async fn main() -> Result<(), DbErr> {
assert_eq!(
std::env::current_dir().unwrap().file_name().unwrap(),
"rust",
"Must run from the rust dir"
"main",
"Must run from the rust/main dir"
);
let postgres = PostgresDockerContainer::start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new_with_type(Transaction::Recipient, Address).borrow_mut())
.col(ColumnDef::new_with_type(Transaction::GasUsed, Wei).not_null())
.col(ColumnDef::new_with_type(Transaction::CumulativeGasUsed, Wei).not_null())
.col(
ColumnDef::new_with_type(
Transaction::RawInputData,
ColumnType::Binary(BlobSize::Blob(None)),
)
.borrow_mut(),
)
.foreign_key(
ForeignKey::create()
.from_col(Transaction::BlockId)
Expand Down Expand Up @@ -128,4 +135,6 @@ pub enum Transaction {
GasUsed,
/// Cumulative gas used within the block after this was executed
CumulativeGasUsed,
/// Raw input data from Ethereum transaction
RawInputData,
}
3 changes: 3 additions & 0 deletions rust/main/agents/scraper/src/db/generated/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct Model {
pub recipient: Option<Vec<u8>>,
pub gas_used: BigDecimal,
pub cumulative_gas_used: BigDecimal,
pub raw_input_data: Option<Vec<u8>>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
Expand All @@ -45,6 +46,7 @@ pub enum Column {
Recipient,
GasUsed,
CumulativeGasUsed,
RawInputData,
}

#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
Expand Down Expand Up @@ -85,6 +87,7 @@ impl ColumnTrait for Column {
Self::Recipient => ColumnType::Binary(BlobSize::Blob(None)).def().null(),
Self::GasUsed => ColumnType::Decimal(Some((78u32, 0u32))).def(),
Self::CumulativeGasUsed => ColumnType::Decimal(Some((78u32, 0u32))).def(),
Self::RawInputData => ColumnType::Binary(BlobSize::Blob(None)).def().null(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions rust/main/agents/scraper/src/db/txn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl ScraperDb {
recipient: Set(txn.recipient.as_ref().map(address_to_bytes)),
max_fee_per_gas: Set(txn.max_fee_per_gas.map(u256_to_decimal)),
cumulative_gas_used: Set(u256_to_decimal(receipt.cumulative_gas_used)),
raw_input_data: Set(txn.raw_input_data.clone()),
})
})
.collect::<Result<Vec<_>>>()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ impl HyperlaneProvider for CosmosProvider {
cumulative_gas_used: U256::from(response.tx_result.gas_used),
effective_gas_price: Some(gas_price),
}),
raw_input_data: None,
};

Ok(tx_info)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ where
})
.transpose()?;

Ok(TxnInfo {
let txn_info = TxnInfo {
hash: *hash,
max_fee_per_gas: txn.max_fee_per_gas.map(Into::into),
max_priority_fee_per_gas: txn.max_priority_fee_per_gas.map(Into::into),
Expand All @@ -116,7 +116,10 @@ where
sender: txn.from.into(),
recipient: txn.to.map(Into::into),
receipt,
})
raw_input_data: Some(txn.input.to_vec()),
};

Ok(txn_info)
}

#[instrument(err, skip(self))]
Expand Down
1 change: 1 addition & 0 deletions rust/main/chains/hyperlane-fuel/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ impl HyperlaneProvider for FuelProvider {
gas_price: Some(gas_price.into()),
recipient,
receipt: None,
raw_input_data: None,
})
}
None => Err(ChainCommunicationError::CustomError(format!(
Expand Down
1 change: 1 addition & 0 deletions rust/main/chains/hyperlane-sealevel/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl HyperlaneProvider for SealevelProvider {
sender: Default::default(),
recipient: None,
receipt: Some(receipt),
raw_input_data: None,
})
}

Expand Down
2 changes: 2 additions & 0 deletions rust/main/hyperlane-core/src/types/chain_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pub struct TxnInfo {
/// If the txn has been processed, we can also report some additional
/// information.
pub receipt: Option<TxnReceiptInfo>,
/// Raw input data of a transaction
pub raw_input_data: Option<Vec<u8>>,
}

/// Information about the execution of a transaction.
Expand Down