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

Support cast run quorum private txn #9058

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 4 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
39 changes: 35 additions & 4 deletions crates/cast/bin/cmd/run.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use alloy_primitives::U256;
use alloy_primitives::{Bytes, Uint, U256};
use alloy_provider::Provider;
use alloy_rpc_types::BlockTransactions;
use alloy_transport::TransportResult;
use cast::{revm::primitives::EnvWithHandlerCfg, traces::TraceKind};
use clap::Parser;
use eyre::{Result, WrapErr};
Expand Down Expand Up @@ -109,7 +110,7 @@ impl RunArgs {
.build()?;

let tx_hash = self.tx_hash.parse().wrap_err("invalid tx hash")?;
let tx = provider
let mut tx = provider
.get_transaction_by_hash(tx_hash)
.await
.wrap_err_with(|| format!("tx not found: {tx_hash:?}"))?
Expand Down Expand Up @@ -188,10 +189,10 @@ impl RunArgs {
tx.transaction_type == Some(SYSTEM_TRANSACTION_TYPE)
{
pb.set_position((index + 1) as u64);
continue;
continue
}
if tx.hash == tx_hash {
break;
break
}

configure_tx_env(&mut env, &tx.inner);
Expand Down Expand Up @@ -231,6 +232,36 @@ impl RunArgs {
let result = {
executor.set_trace_printer(self.trace_printer);

if let Some(signature) = tx.inner.signature {
let v = signature.v;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not opposed to this, but I'd like to have this ideally as a separate function so we can properly document this and have this isolated.

this should probably also check the chainid?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mattsse

We agree on the first point to create a separate function, will update the PR

On the chainId topic:

Quorum explicitly doesn't allow a chainId of 1, it will not run if it is configured this way
https://docs.goquorum.consensys.io/concepts/network-and-chain-id

Are you saying that if chainId is 1, then is_private_quorum_txn should be false here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattsse, I refactored this out into a separate function, not sure if you want it isolated via a CLI flag as well


// 37/38 for private quorum transactions, tessera hash is 64 bytes
let is_private_quorum_txn =
(v == Uint::from(37) || v == Uint::from(38)) && tx.input.len() == 64;

if is_private_quorum_txn {
println!("Private quorum transaction detected.");

let result: TransportResult<Bytes> = provider
.client()
.request("eth_getQuorumPayload", (tx.input.clone(),))
.await;

match result {
Ok(tessera_input) => {
println!(
"Executing private quorum transaction with quorum payload: {:?}",
tessera_input.to_string()
);
tx.input = tessera_input;
}
Err(e) => {
println!("eth_getQuorumPayload threw an error: {e}, cannot fetch transaction input {:?}", tx.hash);
}
}
}
}

configure_tx_env(&mut env, &tx.inner);

if let Some(to) = tx.to {
Expand Down