mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-03 22:03:06 +00:00
fix: fix 2
This commit is contained in:
parent
8f838fc524
commit
73e49f5bf6
@ -362,7 +362,7 @@ impl NodeCore {
|
||||
|
||||
(
|
||||
TransactionPayload {
|
||||
tx_kind: TxKind::Private,
|
||||
tx_kind: TxKind::Shielded,
|
||||
execution_input: serde_json::to_vec(&ActionData::SendMoneyShieldedTx(
|
||||
SendMoneyShieldedTx {
|
||||
acc_sender: acc,
|
||||
@ -389,19 +389,13 @@ impl NodeCore {
|
||||
pub async fn transfer_utxo_deshielded(
|
||||
&self,
|
||||
utxo: UTXO,
|
||||
comm_gen_hash: [u8; 32],
|
||||
receivers: Vec<(u128, AccountAddress)>,
|
||||
) -> Transaction {
|
||||
let commitment_in = {
|
||||
info!("Attempting to get write guard for commitments");
|
||||
let guard = self.storage.write().await;
|
||||
info!("Guard got");
|
||||
|
||||
guard.utxo_commitments_store.get_tx(utxo.hash).unwrap().hash
|
||||
};
|
||||
info!("Commitnment got");
|
||||
|
||||
let acc_map_read_guard = self.storage.read().await;
|
||||
|
||||
let commitment_in = acc_map_read_guard.utxo_commitments_store.get_tx(comm_gen_hash).unwrap().hash;
|
||||
|
||||
let accout = acc_map_read_guard.acc_map.get(&utxo.owner).unwrap();
|
||||
|
||||
let nullifier = generate_nullifiers(
|
||||
@ -414,11 +408,10 @@ impl NodeCore {
|
||||
.to_vec(),
|
||||
);
|
||||
|
||||
info!("Starting send proof");
|
||||
let (resulting_balances, receipt) = prove_send_utxo_deshielded(utxo, receivers);
|
||||
|
||||
TransactionPayload {
|
||||
tx_kind: TxKind::Private,
|
||||
tx_kind: TxKind::Deshielded,
|
||||
execution_input: vec![],
|
||||
execution_output: serde_json::to_vec(&ActionData::SendMoneyDeshieldedTx(
|
||||
SendMoneyDeshieldedTx {
|
||||
@ -440,15 +433,17 @@ impl NodeCore {
|
||||
&self,
|
||||
acc: AccountAddress,
|
||||
amount: u128,
|
||||
) -> Result<(SendTxResponse, [u8; 32])> {
|
||||
) -> Result<(SendTxResponse, [u8; 32], [u8; 32])> {
|
||||
let point_before_prove = std::time::Instant::now();
|
||||
let (tx, utxo_hash) = self.mint_utxo_private(acc, amount).await;
|
||||
let point_after_prove = std::time::Instant::now();
|
||||
|
||||
let commitment_generated_hash = tx.utxo_commitments_created_hashes[0];
|
||||
|
||||
let timedelta = (point_after_prove - point_before_prove).as_millis();
|
||||
info!("Mint utxo proof spent {timedelta:?} milliseconds");
|
||||
|
||||
Ok((self.sequencer_client.send_tx(tx).await?, utxo_hash))
|
||||
Ok((self.sequencer_client.send_tx(tx).await?, utxo_hash, commitment_generated_hash))
|
||||
}
|
||||
|
||||
pub async fn send_public_deposit(
|
||||
@ -496,11 +491,11 @@ impl NodeCore {
|
||||
pub async fn send_deshielded_send_tx(
|
||||
&self,
|
||||
utxo: UTXO,
|
||||
comm_gen_hash: [u8; 32],
|
||||
receivers: Vec<(u128, AccountAddress)>,
|
||||
) -> Result<SendTxResponse> {
|
||||
let point_before_prove = std::time::Instant::now();
|
||||
info!("Starting deshielded transfer");
|
||||
let tx = self.transfer_utxo_deshielded(utxo, receivers).await;
|
||||
let tx = self.transfer_utxo_deshielded(utxo, comm_gen_hash, receivers).await;
|
||||
let point_after_prove = std::time::Instant::now();
|
||||
|
||||
let timedelta = (point_after_prove - point_before_prove).as_millis();
|
||||
@ -514,7 +509,7 @@ impl NodeCore {
|
||||
let acc_addr = self.create_new_account().await;
|
||||
info!("Account created {acc_addr:?}");
|
||||
|
||||
let (resp, new_utxo_hash) = self.send_private_mint_tx(acc_addr, 100).await.unwrap();
|
||||
let (resp, new_utxo_hash, comm_gen_hash) = self.send_private_mint_tx(acc_addr, 100).await.unwrap();
|
||||
info!("Response for mint private is {resp:?}");
|
||||
|
||||
info!("Awaiting new blocks");
|
||||
@ -533,7 +528,7 @@ impl NodeCore {
|
||||
};
|
||||
|
||||
let resp = self
|
||||
.send_deshielded_send_tx(new_utxo, vec![(100, acc_addr)])
|
||||
.send_deshielded_send_tx(new_utxo, comm_gen_hash, vec![(100, acc_addr)])
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Response for send deshielded is {resp:?}");
|
||||
@ -597,7 +592,7 @@ impl NodeCore {
|
||||
let acc_addr = self.create_new_account().await;
|
||||
let acc_addr_rec = self.create_new_account().await;
|
||||
|
||||
let (resp, new_utxo_hash) = self.send_private_mint_tx(acc_addr, 100).await.unwrap();
|
||||
let (resp, _, new_utxo_hash) = self.send_private_mint_tx(acc_addr, 100).await.unwrap();
|
||||
info!("Response for mint private is {resp:?}");
|
||||
|
||||
info!("Awaiting new blocks");
|
||||
@ -688,7 +683,7 @@ impl NodeCore {
|
||||
let acc_addr = self.create_new_account().await;
|
||||
let acc_addr_rec = self.create_new_account().await;
|
||||
|
||||
let (resp, new_utxo_hash) = self.send_private_mint_tx(acc_addr, 100).await.unwrap();
|
||||
let (resp, comm_gen_hash, new_utxo_hash) = self.send_private_mint_tx(acc_addr, 100).await.unwrap();
|
||||
info!("Response for mint private is {resp:?}");
|
||||
|
||||
info!("Awaiting new blocks");
|
||||
@ -707,7 +702,7 @@ impl NodeCore {
|
||||
};
|
||||
|
||||
let resp = self
|
||||
.send_deshielded_send_tx(new_utxo, vec![(100, acc_addr_rec)])
|
||||
.send_deshielded_send_tx(new_utxo, comm_gen_hash, vec![(100, acc_addr_rec)])
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Response for send deshielded is {resp:?}");
|
||||
|
||||
@ -54,6 +54,8 @@ impl NodeChainStore {
|
||||
|
||||
pub fn dissect_insert_block(&mut self, block: Block) -> Result<()> {
|
||||
for tx in &block.transactions {
|
||||
// let public_action = serde_json::from_slice(tx.execution_output);
|
||||
|
||||
self.utxo_commitments_store.add_tx_multiple(
|
||||
tx.utxo_commitments_created_hashes
|
||||
.clone()
|
||||
|
||||
@ -60,6 +60,15 @@ impl UTXO {
|
||||
pub fn interpret_asset<'de, ToInterpret: Deserialize<'de>>(&'de self) -> Result<ToInterpret> {
|
||||
Ok(serde_json::from_slice(&self.asset)?)
|
||||
}
|
||||
|
||||
pub fn into_payload(&self) -> UTXOPayload {
|
||||
UTXOPayload {
|
||||
owner: self.owner,
|
||||
asset: self.asset.clone(),
|
||||
amount: self.amount,
|
||||
privacy_flag: self.privacy_flag,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@ -93,8 +93,9 @@ pub fn prove_send_utxo_deshielded(
|
||||
owners_parts: Vec<(u128, AccountAddress)>,
|
||||
) -> (Vec<(u128, AccountAddress)>, Receipt) {
|
||||
let mut builder = ExecutorEnv::builder();
|
||||
let utxo_payload = spent_utxo.into_payload();
|
||||
|
||||
builder.write(&spent_utxo).unwrap();
|
||||
builder.write(&utxo_payload).unwrap();
|
||||
builder.write(&owners_parts).unwrap();
|
||||
|
||||
let env = builder.build().unwrap();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user