mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-30 04:35:22 +08:00
cargo fmt
This commit is contained in:
@@ -18,7 +18,7 @@ use blockstack_lib::vm::ast::build_ast;
|
|||||||
use blockstack_lib::vm::contexts::GlobalContext;
|
use blockstack_lib::vm::contexts::GlobalContext;
|
||||||
use blockstack_lib::vm::costs::LimitedCostTracker;
|
use blockstack_lib::vm::costs::LimitedCostTracker;
|
||||||
use blockstack_lib::vm::errors::InterpreterResult;
|
use blockstack_lib::vm::errors::InterpreterResult;
|
||||||
use blockstack_lib::vm::{ContractContext, eval_all};
|
use blockstack_lib::vm::{eval_all, ContractContext};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
use blockstack_lib::clarity_vm::database::marf::MarfedKV;
|
use blockstack_lib::clarity_vm::database::marf::MarfedKV;
|
||||||
@@ -490,10 +490,7 @@ fn expensive_contract_test(scaling: u32, buildup_count: u32, genesis_size: u32)
|
|||||||
this_cost
|
this_cost
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute_in_epoch(
|
pub fn execute_in_epoch(program: &str, epoch: StacksEpochId) -> InterpreterResult<Option<Value>> {
|
||||||
program: &str,
|
|
||||||
epoch: StacksEpochId,
|
|
||||||
) -> InterpreterResult<Option<Value>> {
|
|
||||||
let contract_id = QualifiedContractIdentifier::transient();
|
let contract_id = QualifiedContractIdentifier::transient();
|
||||||
let mut contract_context = ContractContext::new(contract_id.clone());
|
let mut contract_context = ContractContext::new(contract_id.clone());
|
||||||
let mut marf = MemoryBackingStore::new();
|
let mut marf = MemoryBackingStore::new();
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ use blockstack_lib::clarity_vm::database::marf::MarfedKV;
|
|||||||
use blockstack_lib::types::chainstate::StacksBlockId;
|
use blockstack_lib::types::chainstate::StacksBlockId;
|
||||||
use blockstack_lib::types::proof::ClarityMarfTrieId;
|
use blockstack_lib::types::proof::ClarityMarfTrieId;
|
||||||
use blockstack_lib::vm::database::NULL_BURN_STATE_DB;
|
use blockstack_lib::vm::database::NULL_BURN_STATE_DB;
|
||||||
use blockstack_lib::{
|
use blockstack_lib::{vm::database::NULL_HEADER_DB, vm::types::QualifiedContractIdentifier};
|
||||||
vm::database::NULL_HEADER_DB, vm::types::QualifiedContractIdentifier,
|
|
||||||
};
|
|
||||||
use criterion::Criterion;
|
use criterion::Criterion;
|
||||||
|
|
||||||
pub fn rollback_log_memory_test() {
|
pub fn rollback_log_memory_test() {
|
||||||
@@ -47,13 +45,16 @@ pub fn rollback_log_memory_test() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
conn.as_transaction(|conn| {
|
conn.as_transaction(|conn| {
|
||||||
let (ct_ast, _ct_analysis) =
|
let (ct_ast, _ct_analysis) = conn
|
||||||
conn.analyze_smart_contract(&contract_identifier, &contract).unwrap();
|
.analyze_smart_contract(&contract_identifier, &contract)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert!(format!(
|
assert!(format!(
|
||||||
"{:?}",
|
"{:?}",
|
||||||
conn.initialize_smart_contract(&contract_identifier, &ct_ast, &contract, |_, _| false)
|
conn.initialize_smart_contract(&contract_identifier, &ct_ast, &contract, |_, _| {
|
||||||
.unwrap_err()
|
false
|
||||||
|
})
|
||||||
|
.unwrap_err()
|
||||||
)
|
)
|
||||||
.contains("MemoryBalanceExceeded"));
|
.contains("MemoryBalanceExceeded"));
|
||||||
});
|
});
|
||||||
@@ -114,9 +115,12 @@ pub fn ccall_memory_test() {
|
|||||||
let (ct_ast, ct_analysis) = conn
|
let (ct_ast, ct_analysis) = conn
|
||||||
.analyze_smart_contract(&contract_identifier, &contract)
|
.analyze_smart_contract(&contract_identifier, &contract)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
conn.initialize_smart_contract(&contract_identifier, &ct_ast, &contract, |_, _| {
|
conn.initialize_smart_contract(
|
||||||
false
|
&contract_identifier,
|
||||||
})
|
&ct_ast,
|
||||||
|
&contract,
|
||||||
|
|_, _| false,
|
||||||
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
conn.save_analysis(&contract_identifier, &ct_analysis)
|
conn.save_analysis(&contract_identifier, &ct_analysis)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|||||||
@@ -12,7 +12,11 @@ use std::fs;
|
|||||||
use blockstack_lib::chainstate::stacks::index::{marf::MARF, storage::TrieFileStorage};
|
use blockstack_lib::chainstate::stacks::index::{marf::MARF, storage::TrieFileStorage};
|
||||||
use blockstack_lib::types::chainstate::{MARFValue, StacksBlockId};
|
use blockstack_lib::types::chainstate::{MARFValue, StacksBlockId};
|
||||||
|
|
||||||
pub fn begin(marf: &mut MARF<StacksBlockId>, chain_tip: &StacksBlockId, next_chain_tip: &StacksBlockId) -> Result<(), Error> {
|
pub fn begin(
|
||||||
|
marf: &mut MARF<StacksBlockId>,
|
||||||
|
chain_tip: &StacksBlockId,
|
||||||
|
next_chain_tip: &StacksBlockId,
|
||||||
|
) -> Result<(), Error> {
|
||||||
let mut tx = marf.begin_tx()?;
|
let mut tx = marf.begin_tx()?;
|
||||||
tx.begin(chain_tip, next_chain_tip)?;
|
tx.begin(chain_tip, next_chain_tip)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -63,7 +67,10 @@ fn benchmark_marf_usage(
|
|||||||
|
|
||||||
for _k in 0..reads_per_block {
|
for _k in 0..reads_per_block {
|
||||||
let (key, value) = values.as_slice().choose(&mut rng).unwrap();
|
let (key, value) = values.as_slice().choose(&mut rng).unwrap();
|
||||||
assert_eq!(marf.get_with_proof(&block_header, key).unwrap().unwrap().0, *value);
|
assert_eq!(
|
||||||
|
marf.get_with_proof(&block_header, key).unwrap().unwrap().0,
|
||||||
|
*value
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut next_block_header = (i + 1).to_le_bytes().to_vec();
|
let mut next_block_header = (i + 1).to_le_bytes().to_vec();
|
||||||
|
|||||||
Reference in New Issue
Block a user