mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
validator/verification: validate contract calls vector indexes
This commit is contained in:
11
src/error.rs
11
src/error.rs
@@ -469,6 +469,10 @@ pub enum Error {
|
||||
#[error("Contract execution failed")]
|
||||
ContractError(darkfi_sdk::error::ContractError),
|
||||
|
||||
#[cfg(feature = "darkfi-sdk")]
|
||||
#[error("Invalid DarkTree")]
|
||||
DarkTreeError(darkfi_sdk::error::DarkTreeError),
|
||||
|
||||
#[cfg(feature = "blockchain")]
|
||||
#[error("contract wasm bincode not found")]
|
||||
WasmBincodeNotFound,
|
||||
@@ -854,3 +858,10 @@ impl From<darkfi_sdk::error::ContractError> for Error {
|
||||
Self::ContractError(err)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "darkfi-sdk")]
|
||||
impl From<darkfi_sdk::error::DarkTreeError> for Error {
|
||||
fn from(err: darkfi_sdk::error::DarkTreeError) -> Self {
|
||||
Self::DarkTreeError(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ use std::{collections::HashMap, io::Cursor};
|
||||
use darkfi_sdk::{
|
||||
blockchain::{block_version, expected_reward},
|
||||
crypto::{schnorr::SchnorrPublic, PublicKey, CONSENSUS_CONTRACT_ID, MONEY_CONTRACT_ID},
|
||||
dark_tree::dark_leaf_vec_integrity_check,
|
||||
pasta::pallas,
|
||||
};
|
||||
use darkfi_serial::{Decodable, Encodable, WriteExt};
|
||||
@@ -30,7 +31,7 @@ use crate::{
|
||||
blockchain::{BlockInfo, BlockchainOverlayPtr},
|
||||
error::TxVerifyFailed,
|
||||
runtime::vm_runtime::Runtime,
|
||||
tx::Transaction,
|
||||
tx::{Transaction, MAX_TX_CALLS, MIN_TX_CALLS},
|
||||
util::time::TimeKeeper,
|
||||
validator::{
|
||||
consensus::{Consensus, Fork, Proposal, TXS_CAP},
|
||||
@@ -339,6 +340,9 @@ pub async fn verify_transaction(
|
||||
let tx_hash = tx.hash()?;
|
||||
debug!(target: "validator::verification::verify_transaction", "Validating transaction {}", tx_hash);
|
||||
|
||||
// Verify calls indexes integrity
|
||||
dark_leaf_vec_integrity_check(&tx.calls, Some(MIN_TX_CALLS), Some(MAX_TX_CALLS))?;
|
||||
|
||||
// Table of public inputs used for ZK proof verification
|
||||
let mut zkp_table = vec![];
|
||||
// Table of public keys used for signature verification
|
||||
|
||||
Reference in New Issue
Block a user