x 2 лет назад
Родитель
Сommit
4ae9b2607f

+ 11 - 2
src/contract/dao/src/entrypoint/auth_xfer.rs

@@ -39,7 +39,14 @@ pub(crate) fn dao_authxfer_get_metadata(
     call_idx: u32,
     calls: Vec<DarkLeaf<ContractCall>>,
 ) -> Result<Vec<u8>, ContractError> {
-    Ok(vec![])
+    let mut zk_public_inputs: Vec<(String, Vec<pallas::Base>)> = vec![];
+    let signature_pubkeys: Vec<PublicKey> = vec![];
+
+    let mut metadata = vec![];
+    zk_public_inputs.encode(&mut metadata)?;
+    signature_pubkeys.encode(&mut metadata)?;
+
+    Ok(metadata)
 }
 
 /// `process_instruction` function for `Dao::Exec`
@@ -48,5 +55,7 @@ pub(crate) fn dao_authxfer_process_instruction(
     call_idx: u32,
     calls: Vec<DarkLeaf<ContractCall>>,
 ) -> Result<Vec<u8>, ContractError> {
-    Ok(vec![])
+    let mut update_data = vec![];
+    update_data.write_u8(DaoFunction::AuthMoneyTransfer as u8)?;
+    Ok(update_data)
 }

+ 16 - 11
src/contract/dao/src/entrypoint/exec.rs

@@ -40,24 +40,19 @@ pub(crate) fn dao_exec_get_metadata(
     call_idx: u32,
     calls: Vec<DarkLeaf<ContractCall>>,
 ) -> Result<Vec<u8>, ContractError> {
-    assert_eq!(call_idx, 1);
-    assert_eq!(calls.len(), 2);
-
-    let money_call = &calls[0].data;
-    let money_xfer_params: MoneyTransferParamsV1 = deserialize(&money_call.data[1..])?;
-
-    let dao_call = &calls[1].data;
-    let dao_exec_params: DaoExecParams = deserialize(&dao_call.data[1..])?;
+    let self_ = &calls[call_idx as usize];
+    let params: DaoExecParams = deserialize(&self_.data.data[1..])?;
 
     // Public inputs for the ZK proofs we have to verify
     let mut zk_public_inputs: Vec<(String, Vec<pallas::Base>)> = vec![];
     // Public keys for the transaction signatures we have to verify
     let signature_pubkeys: Vec<PublicKey> = vec![];
 
-    let blind_vote = dao_exec_params.blind_total_vote;
+    let blind_vote = params.blind_total_vote;
     let yes_vote_coords = blind_vote.yes_vote_commit.to_affine().coordinates().unwrap();
     let all_vote_coords = blind_vote.all_vote_commit.to_affine().coordinates().unwrap();
 
+    /*
     let mut input_valcoms = pallas::Point::identity();
     for input in &money_xfer_params.inputs {
         input_valcoms += input.value_commit;
@@ -67,12 +62,13 @@ pub(crate) fn dao_exec_get_metadata(
     assert!(money_xfer_params.inputs.len() > 0);
     // This value should be the same for all inputs, as enforced in process_instruction() below.
     let input_user_data_enc = money_xfer_params.inputs[0].user_data_enc;
+    */
 
     zk_public_inputs.push((
         DAO_CONTRACT_ZKAS_DAO_EXEC_NS.to_string(),
         vec![
-            dao_exec_params.proposal.inner(),
-            dao_exec_params.proposal_auth_calls.commit(),
+            params.proposal.inner(),
+            params.proposal_auth_calls.commit(),
             *yes_vote_coords.x(),
             *yes_vote_coords.y(),
             *all_vote_coords.x(),
@@ -97,7 +93,15 @@ pub(crate) fn dao_exec_process_instruction(
     let self_ = &calls[call_idx as usize];
     let params: DaoExecParams = deserialize(&self_.data.data[1..])?;
 
+    //for (i, call) in calls.iter().enumerate() {
+    //msg!("{}", i);
+    //msg!("parent: {:?}", call.parent_index);
+    //msg!("child: {:?}", call.children_indexes);
+    //msg!("--");
+    //}
+
     // Check children of DAO exec match the specified calls
+    /*
     for auth_call in &params.proposal_auth_calls {
         let child_idx = self_.children_indexes[auth_call.index];
         let child = &calls[child_idx];
@@ -113,6 +117,7 @@ pub(crate) fn dao_exec_process_instruction(
             //return Err(DaoError::ExecCallWrongChildCall.into())
         }
     }
+    */
 
     /*
 

+ 2 - 1
src/contract/test-harness/src/dao_exec.rs

@@ -200,7 +200,8 @@ impl TestHarness {
         let authxfer_sigs = vec![];
         let xfer_sigs = tx.create_sigs(&mut OsRng, &xfer_secrets.signature_secrets)?;
         let exec_sigs = tx.create_sigs(&mut OsRng, &[exec_signature_secret])?;
-        tx.signatures = vec![authxfer_sigs, xfer_sigs, exec_sigs];
+        // FIXME: this is wrong! exec_sigs should be last... awaiting tree fix
+        tx.signatures = vec![exec_sigs, authxfer_sigs, xfer_sigs];
         tx_action_benchmark.creation_times.push(timer.elapsed());
 
         // Calculate transaction sizes

+ 1 - 0
src/contract/test-harness/src/lib.rs

@@ -72,6 +72,7 @@ mod money_transfer;
 pub fn init_logger() {
     let mut cfg = simplelog::ConfigBuilder::new();
     cfg.add_filter_ignore("sled".to_string());
+    //cfg.set_target_level(simplelog::LevelFilter::Error);
 
     // We check this error so we can execute same file tests in parallel,
     // otherwise second one fails to init logger here.