Преглед изворни кода

drk: bincode rpc retrieval fixed, transfer tx generation fixed

skoupidi пре 2 година
родитељ
комит
e956ee71f2

+ 6 - 1
bin/darkfid/src/rpc_blockchain.rs

@@ -244,7 +244,12 @@ impl Darkfid {
                 return JsonError::new(InternalError, None, id).into()
             };
 
-            let zkas_bincode = base64::encode(&zkas_bytes);
+            let (zkbin, _): (Vec<u8>, Vec<u8>) = match deserialize_async(&zkas_bytes).await {
+                Ok(pair) => pair,
+                Err(_) => return JsonError::new(InternalError, None, id).into(),
+            };
+
+            let zkas_bincode = base64::encode(&zkbin);
             ret.push(JsonValue::Array(vec![
                 JsonValue::String(zkas_ns),
                 JsonValue::String(zkas_bincode),

+ 2 - 5
bin/drk/src/rpc.rs

@@ -346,8 +346,6 @@ impl Drk {
 
     /// Try to fetch zkas bincodes for the given `ContractId`.
     pub async fn lookup_zkas(&self, contract_id: &ContractId) -> Result<Vec<(String, Vec<u8>)>> {
-        println!("Querying zkas bincode for {contract_id}");
-
         let params = JsonValue::Array(vec![JsonValue::String(format!("{contract_id}"))]);
         let req = JsonRequest::new("blockchain.lookup_zkas", params);
 
@@ -357,9 +355,8 @@ impl Drk {
         let mut ret = Vec::with_capacity(params.len());
         for param in params {
             let zkas_ns = param[0].get::<String>().unwrap().clone();
-            let zkas_bincode_bytes = base64::decode(param.get::<String>().unwrap()).unwrap();
-            let zkas_bincode = deserialize_async(&zkas_bincode_bytes).await?;
-            ret.push((zkas_ns, zkas_bincode));
+            let zkas_bincode_bytes = base64::decode(param[1].get::<String>().unwrap()).unwrap();
+            ret.push((zkas_ns, zkas_bincode_bytes));
         }
 
         Ok(ret)

+ 2 - 3
bin/drk/src/transfer.rs

@@ -45,7 +45,6 @@ impl Drk {
         recipient: PublicKey,
     ) -> Result<Transaction> {
         // First get all unspent OwnCoins to see what our balance is.
-        println!("Fetching OwnCoins");
         let owncoins = self.get_coins(false).await?;
         let mut owncoins: Vec<OwnCoin> = owncoins.iter().map(|x| x.0.clone()).collect();
         // We're only interested in the ones for the token_id we're sending
@@ -98,11 +97,11 @@ impl Drk {
         let mint_circuit = ZkCircuit::new(empty_witnesses(&mint_zkbin)?, &mint_zkbin);
         let burn_circuit = ZkCircuit::new(empty_witnesses(&burn_zkbin)?, &burn_zkbin);
 
-        println!("Creating Mint and Burn circuit proving keys");
+        // Creating Mint and Burn circuit proving keys
         let mint_pk = ProvingKey::build(mint_zkbin.k, &mint_circuit);
         let burn_pk = ProvingKey::build(burn_zkbin.k, &burn_circuit);
 
-        println!("Building transaction parameters");
+        // Building transaction parameters
         let (params, secrets, spent_coins) = make_transfer_call(
             keypair, recipient, amount, token_id, owncoins, tree, mint_zkbin, mint_pk, burn_zkbin,
             burn_pk,

+ 5 - 1
contrib/localnet/darkfid-single-node/README.md

@@ -55,7 +55,7 @@ of the guide can be added for future regressions.
 | 10 | Alias add                 | alias add {ALIAS} {TOKEN}                        | Pass                             |
 | 11 | Aliases retrieval         | alias show                                       | Pass                             |
 | 12 | Mint generation           | token mint {ALIAS} {AMOUNT} {ADDR}               | Failure: disabled                |
-| 13 | Transfer                  | transfer {AMOUNT} {ALIAS} {ADDR}                 | Failure: rpc.rs:360 unwrap fails |
+| 13 | Transfer                  | transfer {AMOUNT} {ALIAS} {ADDR}                 | Failure: fee is missing          |
 | 14 | Coins retrieval           | wallet --coins                                   | Pass                             |
 | 15 | OTC initialization        | otc init -v {AMOUNT}:{AMOUNT} -t {ALIAS}:{ALIAS} | Failure: needs #12               |
 | 16 | OTC join                  | otc join                                         | Failure: needs #15               |
@@ -71,4 +71,8 @@ of the guide can be added for future regressions.
 | 26 | DAO proposal retrieval    | dao proposal {DAO} {PROPOSAL_ID}                 | Failure: needs #24               |
 | 27 | DAO vote                  | dao vote {DAO} {PROPOSAL_ID} {VOTE} {WEIGHT}     | Failure: needs #24               |
 | 28 | DAO proposal execution    | dao exec {DAO} {PROPOSAL_ID}                     | Failure: needs #27               |
+| 29 | Coins unspend             | unspend {COIN}                                   | Pass                             |
+| 30 | Transaction inspect       | inspect                                          | Pass                             |
+| 31 | Transaction simulate      | explorer simulate-tx                             | Pass                             |
+| 31 | Transaction broadcast     | broadcast                                        | Pass                             |
 

+ 3 - 3
src/contract/money/src/client/transfer_v1/builder.rs

@@ -27,7 +27,7 @@ use darkfi_sdk::{
     },
     pasta::pallas,
 };
-use log::{debug, info};
+use log::debug;
 use rand::rngs::OsRng;
 
 use super::proof::{create_transfer_burn_proof, create_transfer_mint_proof};
@@ -93,7 +93,7 @@ impl TransferCallBuilder {
             let signature_secret = SecretKey::random(&mut OsRng);
             signature_secrets.push(signature_secret);
 
-            info!("Creating transfer burn proof for input {}", i);
+            debug!("Creating transfer burn proof for input {}", i);
             let (proof, public_inputs) = create_transfer_burn_proof(
                 &self.burn_zkbin,
                 &self.burn_pk,
@@ -129,7 +129,7 @@ impl TransferCallBuilder {
 
             output_blinds.push(value_blind);
 
-            info!("Creating transfer mint proof for output {}", i);
+            debug!("Creating transfer mint proof for output {}", i);
             let (proof, public_inputs) = create_transfer_mint_proof(
                 &self.mint_zkbin,
                 &self.mint_pk,