diff --git a/elf/riscv32im-succinct-zkvm-elf b/elf/riscv32im-succinct-zkvm-elf index f38ed95..ec0f517 100755 Binary files a/elf/riscv32im-succinct-zkvm-elf and b/elf/riscv32im-succinct-zkvm-elf differ diff --git a/program/src/main.rs b/program/src/main.rs index 811e391..6b6b2e9 100644 --- a/program/src/main.rs +++ b/program/src/main.rs @@ -34,8 +34,8 @@ pub fn main() { let mut memorizer = sp1_zkvm::io::read::(); } else { println!("Hello, world! from non zkvm"); - let rpc_url: String = env::var("RPC_URL").expect("RPC_URL not set"); - let mut memorizer = Memorizer::new(Some(Url::from_str(&rpc_url).unwrap())); + // let rpc_url: String = env::var("RPC_URL").expect("RPC_URL not set"); + let mut memorizer = Memorizer::new(Some(Url::from_str("https://sepolia.ethereum.iosis.tech/").unwrap())); } } diff --git a/program/src/memorizer/mod.rs b/program/src/memorizer/mod.rs index a602d83..ffab980 100644 --- a/program/src/memorizer/mod.rs +++ b/program/src/memorizer/mod.rs @@ -40,10 +40,10 @@ impl Memorizer { #[cfg(test)] mod tests { - use alloy_primitives::B256; + use alloy_primitives::{Bytes, B256}; use std::fs; use tempdir::TempDir; - use values::HeaderMemorizerValue; + use values::{HeaderMemorizerValue, TransactionMemorizerValue}; use super::*; @@ -58,6 +58,16 @@ mod tests { B256::ZERO, MemorizerValue::Header(HeaderMemorizerValue::default()), ); + let raw_tx = alloy_primitives::hex::decode("02f86f0102843b9aca0085029e7822d68298f094d9e1459a7a482635700cbc20bbaf52d495ab9c9680841b55ba3ac080a0c199674fcb29f353693dd779c017823b954b3c69dffa3cd6b2a6ff7888798039a028ca912de909e7e6cdef9cdcaf24c54dd8c1032946dfa1d85c206b32a9064fe8").unwrap(); + // let res = TxEnvelope::decode(&mut raw_tx.as_slice()).unwrap(); + original_mem.map.insert( + B256::ZERO, + MemorizerValue::Transaction(TransactionMemorizerValue { + transaction_encoded: Bytes::from(raw_tx), + tx_index: 0, + proof: Default::default(), + }), + ); fs::write(&path, original_mem.as_bytes().unwrap()).unwrap(); diff --git a/program/src/memorizer/transaction/online.rs b/program/src/memorizer/transaction/online.rs index 18b6003..167fd9b 100644 --- a/program/src/memorizer/transaction/online.rs +++ b/program/src/memorizer/transaction/online.rs @@ -1,4 +1,5 @@ use alloy_consensus::TxEnvelope; +use alloy_rlp::Encodable; use hdp_lib::transaction::{TransactionClient, TransactionResponse}; use tokio::runtime::Runtime; @@ -22,11 +23,13 @@ impl TransactionMemorizer for Memorizer { }); let tx = transaction.tx.0; + let mut out = Vec::new(); + tx.encode(&mut out); self.map.insert( key.into(), crate::memorizer::values::MemorizerValue::Transaction(TransactionMemorizerValue { - transaction: tx.clone(), + transaction_encoded: out.into(), tx_index: transaction.tx_index, proof: transaction.proof, }), diff --git a/program/src/memorizer/transaction/zkvm.rs b/program/src/memorizer/transaction/zkvm.rs index 271d935..ea5d672 100644 --- a/program/src/memorizer/transaction/zkvm.rs +++ b/program/src/memorizer/transaction/zkvm.rs @@ -3,6 +3,7 @@ use crate::memorizer::{ keys::HeaderKey, keys::MemorizerKey, keys::TransactionKey, values::MemorizerValue, Memorizer, }; use alloy_consensus::TxEnvelope; +use alloy_rlp::Decodable; use hdp_lib::mpt::Mpt; use std::error::Error; @@ -23,7 +24,8 @@ impl TransactionMemorizer for Memorizer { println!("cycle-tracker-start: mpt"); mpt.verify(tx_value.tx_index, tx_value.proof.clone()); println!("cycle-tracker-end: mpt"); - Ok(tx_value.transaction.clone()) + let tx_encoded = tx_value.transaction_encoded.clone(); + Ok(TxEnvelope::decode(&mut tx_encoded.as_ref()).unwrap()) } else { Err("Transaction not found".into()) } diff --git a/program/src/memorizer/values.rs b/program/src/memorizer/values.rs index d4b3295..47957a4 100644 --- a/program/src/memorizer/values.rs +++ b/program/src/memorizer/values.rs @@ -1,4 +1,4 @@ -use alloy_consensus::{serde_bincode_compat, TxEnvelope}; +use alloy_consensus::serde_bincode_compat; use alloy_consensus::{Account, Header}; use alloy_primitives::{Bytes, B256, U256}; use serde::{Deserialize, Serialize}; @@ -30,7 +30,7 @@ pub struct StorageMemorizerValue { #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct TransactionMemorizerValue { - pub transaction: TxEnvelope, + pub transaction_encoded: Bytes, pub tx_index: u64, pub proof: Vec, }