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

Override EthTransactions::transaction_by_hash for OpApi #11606

Open
mattsse opened this issue Oct 9, 2024 · 3 comments · May be fixed by #11440
Open

Override EthTransactions::transaction_by_hash for OpApi #11606

mattsse opened this issue Oct 9, 2024 · 3 comments · May be fixed by #11440
Assignees
Labels
A-op-reth Related to Optimism and op-reth A-rpc Related to the RPC implementation

Comments

@mattsse
Copy link
Collaborator

mattsse commented Oct 9, 2024

Describe the feature

ref #11164
for OP deposits we need to fetch the receipt as well,

since EthTransactions only delegates

we can easily override this and if there's deposit we need to set the nonce and depositversion accordingly

Additional context

No response

@mattsse mattsse added C-enhancement New feature or request S-needs-triage This issue needs to be labelled A-rpc Related to the RPC implementation A-op-reth Related to Optimism and op-reth and removed C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Oct 9, 2024
@emhane
Copy link
Member

emhane commented Oct 9, 2024

don't see how this will solve the problem of #11440, because the return type of that method doesn't return the rpc transaction type. the problem is filling the rpc response with the consensus tx type + block info + op extra metadata.

@aroralanuk
Copy link

Maybe I'm missing some context here, but can we extend RpcTransaction for optimism like below:

pub enum ExtendedRpcTransaction<T> {
    Base(RpcTransaction<T>),
    Optimism(OptimismRpcTransaction<T>),
}
...

async fn transaction_by_hash(
    &self,
    hash: B256,
) -> RpcResult<Option<ExtendedRpcTransaction<T::NetworkTypes>>> {
    let transaction_option = EthTransactions::transaction_by_hash(self, hash).await?;
    if let Some(tx) = transaction_option {
        let receipt_option = EthTransactions::transaction_receipt(self, hash).await?;
        let is_deposit = tx.is_deposit();
        let (deposit_nonce, deposit_receipt_version) = if is_deposit {
            if let Some(receipt) = receipt_option {
                (
                    receipt.deposit_nonce,
                    receipt.deposit_receipt_version,
                )
            } else {
                (None, None)
            }
        } else {
            (None, None)
        };
        
        if is_deposit {
            let optimism_rpc_tx = OptimismRpcTransaction::new(
                tx,
                ...
                deposit_nonce,
                deposit_receipt_version,
            );

            Ok(Some(optimism_rpc_tx.into()))
        } else {
            Ok(Some(ExtendedRpcTransaction::from(base_rpc_tx)))
        }
    } else {
        Ok(None)
    }
}

@emhane
Copy link
Member

emhane commented Oct 10, 2024

changing the signature of EthTransactions::transaction_by_hash to return the rpc tx instead, and changing the impl of EthApiServer accordingly, allows to add despot receipt version field in op impl of EthTransactions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-op-reth Related to Optimism and op-reth A-rpc Related to the RPC implementation
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

3 participants