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

Implement searchTransactionsBefore and searchTransactionsAfter #13499

Open
mattsse opened this issue Dec 22, 2024 · 11 comments · May be fixed by #13621
Open

Implement searchTransactionsBefore and searchTransactionsAfter #13499

mattsse opened this issue Dec 22, 2024 · 11 comments · May be fixed by #13621
Assignees
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@mattsse
Copy link
Collaborator

mattsse commented Dec 22, 2024

Describe the feature

ref

/// Handler for `searchTransactionsBefore`
async fn search_transactions_before(
&self,
_address: Address,
_block_number: u64,
_page_size: usize,
) -> RpcResult<TransactionsWithReceipts> {
Err(internal_rpc_err("unimplemented"))
}
/// Handler for `searchTransactionsAfter`

this is likely similar to

/// Returns all transaction traces that match the given filter.
///
/// This is similar to [`Self::trace_block`] but only returns traces for transactions that match
/// the filter.
pub async fn trace_filter(

todo

  • implement this by looping over the range
  • should enforce a sensible page size, lets start with 100 blocks

Additional context

#3726

@mattsse mattsse added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Dec 22, 2024
@mattsse mattsse added D-good-first-issue Nice and easy! A great choice to get started A-rpc Related to the RPC implementation and removed S-needs-triage This issue needs to be labelled labels Dec 22, 2024
@caglaryucekaya
Copy link
Contributor

Hey, I'd like to work on this

@mattsse
Copy link
Collaborator Author

mattsse commented Dec 23, 2024

cool, assigned.

lmk if you need any pointers

@mattsse
Copy link
Collaborator Author

mattsse commented Dec 23, 2024

@caglaryucekaya I don't actually know for sure if the address argument is the sender or whether this should find any occurrences of the address

@ekumamatthew
Copy link

I'd like to take this issue.

@aidenwong812
Copy link

Could I be assigned to this?

@askwhyharsh
Copy link

hey @caglaryucekaya are you working on this one or should i attempt it?

@caglaryucekaya
Copy link
Contributor

@askwhyharsh I am working on it

@caglaryucekaya
Copy link
Contributor

@mattsse I checked the otterscan book and about the address argument it says:

"They return inbound (to), outbound (from) and "internal" transactions. By internal it means that if a transaction calls a contract and somewhere in the call stack it sends ETH to the address you are searching for or the address is a contract and it calls a method on it, the transaction is matched and returned in the search results."

So is the way to do this to iterate over all blocks one by one beginning from the block number and check the from and to fields of the transactions until the page size is reached? Or is there a more efficient way for this?

@mattsse
Copy link
Collaborator Author

mattsse commented Dec 28, 2024

@caglaryucekaya this also matches

"internal" transactions

which can happen during execution.

this is very similar to what trace_filter does:

// trace all blocks
let mut block_traces = Vec::with_capacity(blocks.len());
for block in &blocks {
let matcher = matcher.clone();
let traces = self.eth_api().trace_block_until(
block.hash().into(),
Some(block.clone()),
None,
TracingInspectorConfig::default_parity(),
move |tx_info, inspector, _, _, _| {
let mut traces =
inspector.into_parity_builder().into_localized_transaction_traces(tx_info);
traces.retain(|trace| matcher.matches(&trace.trace));
Ok(Some(traces))
},
);
block_traces.push(traces);
}

unfortunately, this is quite expensive and we don't have additional indexes for this, so the only way we can support this rn is by tracing all the blocks and then scan the internal txs -.-

we can however optimize this by doing a scan pass first and try to find if the account even exists (AccountReader), which is like a binary search to find the first occurrence of the account in question

@VyuduInc
Copy link

Mind if I try this one?

@mymiracle0118
Copy link

Can I try solving this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

7 participants