Skip to content

Commit

Permalink
Merge pull request #131 from weaveVM/rpc-get_arweave_storage_proof
Browse files Browse the repository at this point in the history
Rpc get arweave storage proof
  • Loading branch information
andreespirela authored Jan 23, 2025
2 parents d194e4d + 35dd9d8 commit 09e62e2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ borsh = "1.5.1"
brotlic = "0.8.2"

# exex-templates
exex-wvm-da = { git = "https://github.com/weaveVM/exex-templates?a", branch = "main" }
exex-wvm-bigquery = { git = "https://github.com/weaveVM/exex-templates?e", branch = "main" }
exex-wvm-da = { git = "https://github.com/weaveVM/exex-templates?i", branch = "main" }
exex-wvm-bigquery = { git = "https://github.com/weaveVM/exex-templates?i", branch = "main" }

# fees
fees = { git = "https://github.com/weaveVM/miscalleneous?c", branch = "main" }
Expand Down
10 changes: 10 additions & 0 deletions crates/rpc/rpc-eth-api/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ pub trait EthApi<T: RpcObject, B: RpcObject, R: RpcObject> {
#[method(name = "sendWvmTransaction")]
async fn send_wvm_transaction(&self, request: WvmTransactionRequest) -> RpcResult<B256>;

/// Gets the arweave transaction id that prooves the permanency of a given block
#[method(name = "getArweaveStorageProof")]
async fn get_arweave_storage_proof(&self, block_height: String) -> RpcResult<String>;

/// Sends signed transaction, returning its hash.
#[method(name = "sendRawTransaction")]
async fn send_raw_transaction(&self, bytes: Bytes) -> RpcResult<B256>;
Expand Down Expand Up @@ -777,6 +781,12 @@ where
Ok(EthTransactions::send_wvm_transaction(self, request).await?)
}

/// Handler for: `eth_getArweaveStorageProof`
async fn get_arweave_storage_proof(&self, block_height: String) -> RpcResult<String> {
trace!(target: "rpc::eth", ?block_height, "Serving eth_getArweaveStorageProof");
Ok(EthTransactions::get_arweave_storage_proof(self, block_height).await?)
}

/// Handler for: `eth_sendRawTransaction`
async fn send_raw_transaction(&self, tx: Bytes) -> RpcResult<B256> {
trace!(target: "rpc::eth", ?tx, "Serving eth_sendRawTransaction");
Expand Down
23 changes: 23 additions & 0 deletions crates/rpc/rpc-eth-api/src/helpers/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,29 @@ pub trait EthTransactions: LoadTransaction<Provider: BlockReaderIdExt> {
}
}

/// WVM Exclusive
/// Obtains the Arweave Hash of the transaction containing the WEVM Block
fn get_arweave_storage_proof(&self, block_height: String) -> impl Future<Output = Result<String, EthApiError>> + Send
where
Self: EthApiSpec + LoadBlock + LoadPendingBlock + Call {
let bq_client = (&*PRECOMPILE_WVM_BIGQUERY_CLIENT).clone();

async move {
let result_set = bq_client.bq_query_block(block_height).await;

match result_set {
Some(result_set) => {
match result_set.get_string_by_name("arweave_id") {
Ok(Some(arweave_id)) => Ok(arweave_id), // Successfully found the string
Ok(None) => Err(EthApiError::TransactionNotFound), // Field missing
Err(err) => Err(EthApiError::TransactionNotFound), // Handle the inner error
}
}
None => Err(EthApiError::TransactionNotFound), // Result set is None
}
}
}

/// Signs transaction with a matching signer, if any and submits the transaction to the pool.
/// Returns the hash of the signed transaction.
fn send_transaction(
Expand Down
2 changes: 2 additions & 0 deletions wvm-apps/wvm-exexed/crates/reth-exexed/src/exex/ar_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,14 @@ async fn update_bigquery(
update_bigquery_tags(big_query_client, block).await?;

let save_block_start_time = std::time::Instant::now();
let block_hash = block.block.hash().to_string();

let result = exex_wvm_bigquery::save_block(
state_repo.clone(),
block,
block_number,
arweave_id.to_string(),
block_hash
)
.await;

Expand Down

0 comments on commit 09e62e2

Please sign in to comment.