build is back to functioning after rebasing from next to develop

This commit is contained in:
Aaron Blankstein
2021-12-23 14:33:14 -06:00
parent 618767a1c8
commit c752e30d74
26 changed files with 56 additions and 213 deletions

View File

@@ -454,7 +454,7 @@ fn handle_contract_call(
Value::try_deserialize_hex_untyped(input)?
},
"-e" => {
blockstack_lib::clarity_cli::vm_execute(input, &clarity_version)?
blockstack_lib::clarity_cli::vm_execute(input)?
.ok_or("Supplied argument did not evaluate to a Value")?
},
_ => {

View File

@@ -622,7 +622,7 @@ impl Burnchain {
pub fn connect_db<I: BurnchainIndexer>(
&self,
_indexer: &I,
indexer: &I,
readwrite: bool,
first_block_header_hash: BurnchainHeaderHash,
first_block_header_timestamp: u64,

View File

@@ -38,7 +38,6 @@ use vm::types::{
TupleData, TupleTypeSignature, TypeSignature, Value, NONE,
};
use crate::core::POX_TESTNET_CYCLE_LENGTH;
use crate::{
burnchains::PoxConstants,
clarity_vm::{clarity::ClarityBlockConnection, database::marf::WritableMarfStore},

View File

@@ -52,7 +52,6 @@ use crate::types::chainstate::StacksBlockId;
use crate::types::chainstate::TrieHash;
use crate::types::chainstate::{BlockHeaderHash, StacksAddress, StacksWorkScore};
use chainstate::stacks::address::StacksAddressExtensions;
use chainstate::stacks::db::blocks::SetupBlockResult;
use chainstate::stacks::StacksBlockHeader;
use chainstate::stacks::StacksMicroblockHeader;

View File

@@ -51,7 +51,6 @@ use crate::clarity::{
vm::errors::{Error, InterpreterResult, RuntimeErrorType},
vm::eval_all,
vm::types::{OptionalData, PrincipalData, QualifiedContractIdentifier},
vm::ClarityVersion,
vm::ContractContext,
vm::ContractName,
vm::{SymbolicExpression, SymbolicExpressionType, Value},
@@ -152,9 +151,8 @@ struct EvalInput {
fn parse(
contract_identifier: &QualifiedContractIdentifier,
source_code: &str,
version: ClarityVersion,
) -> Result<Vec<SymbolicExpression>, Error> {
let ast = build_ast(contract_identifier, source_code, &mut (), version)
let ast = build_ast(contract_identifier, source_code, &mut ())
.map_err(|e| RuntimeErrorType::ASTError(e))?;
Ok(ast.expressions)
}
@@ -208,8 +206,6 @@ fn run_analysis_free<C: ClarityStorage>(
&mut marf_kv.get_analysis_db(),
save_contract,
LimitedCostTracker::new_free(),
// ClarityVersionPragmaTodo: need to use contract's declared version
ClarityVersion::Clarity1,
)
}
@@ -238,8 +234,6 @@ fn run_analysis<C: ClarityStorage>(
&mut marf_kv.get_analysis_db(),
save_contract,
cost_track,
// ClarityVersionPragmaTodo: need to use contract's declared version
ClarityVersion::Clarity1,
)
}
@@ -416,9 +410,9 @@ where
/// Execute program in a transient environment. To be used only by CLI tools
/// for program evaluation, not by consensus critical code.
pub fn vm_execute(program: &str, version: &ClarityVersion) -> Result<Option<Value>, Error> {
pub fn vm_execute(program: &str) -> Result<Option<Value>, Error> {
let contract_id = QualifiedContractIdentifier::transient();
let mut contract_context = ContractContext::new(contract_id.clone(), version.clone());
let mut contract_context = ContractContext::new(contract_id.clone());
let mut marf = MemoryBackingStore::new();
let conn = marf.as_clarity_db();
let mut global_context = GlobalContext::new(
@@ -428,8 +422,8 @@ pub fn vm_execute(program: &str, version: &ClarityVersion) -> Result<Option<Valu
DEFAULT_CLI_EPOCH,
);
global_context.execute(|g| {
let parsed = ast::build_ast(&contract_id, program, &mut (), version.clone())?.expressions;
eval_all(&parsed, &mut contract_context, g, None)
let parsed = ast::build_ast(&contract_id, program, &mut ())?.expressions;
eval_all(&parsed, &mut contract_context, g)
})
}
@@ -734,8 +728,6 @@ fn install_boot_code<C: ClarityStorage>(header_db: &CLIHeadersDB, marf: &mut C)
*STACKS_BOOT_CODE_TESTNET
};
let clarity_version = ClarityVersion::Clarity1;
for (boot_code_name, boot_code_contract) in boot_code.iter() {
let contract_identifier = QualifiedContractIdentifier::new(
boot_code_addr(mainnet).into(),
@@ -750,7 +742,7 @@ fn install_boot_code<C: ClarityStorage>(header_db: &CLIHeadersDB, marf: &mut C)
);
let mut ast = friendly_expect(
parse(&contract_identifier, &contract_content, clarity_version),
parse(&contract_identifier, &contract_content),
"Failed to parse program.",
);
@@ -760,7 +752,7 @@ fn install_boot_code<C: ClarityStorage>(header_db: &CLIHeadersDB, marf: &mut C)
let db = marf.get_clarity_db(header_db, &NULL_BURN_STATE_DB);
let mut vm_env = OwnedEnvironment::new_free(mainnet, db, DEFAULT_CLI_EPOCH);
vm_env
.initialize_contract(contract_identifier, &contract_content, None)
.initialize_contract(contract_identifier, &contract_content)
.unwrap();
}
Err(_) => {
@@ -790,7 +782,6 @@ fn install_boot_code<C: ClarityStorage>(header_db: &CLIHeadersDB, marf: &mut C)
vm_env
.execute_transaction(
sender,
None,
pox_contract,
"set-burnchain-parameters",
params.as_slice(),
@@ -819,7 +810,6 @@ pub fn add_serialized_output(result: &mut serde_json::Value, value: Value) {
}
/// Returns (process-exit-code, Option<json-output>)
/// Assumes version Clarity1.
pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_json::Value>) {
if args.len() < 1 {
print_usage(invoked_by);
@@ -1004,10 +994,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
};
// TODO: Add --clarity_version as command line argument
let mut ast = friendly_expect(
parse(&contract_id, &content, ClarityVersion::Clarity1),
"Failed to parse program",
);
let mut ast = friendly_expect(parse(&contract_id, &content), "Failed to parse program");
let contract_analysis_res = {
if argv.len() >= 3 {
@@ -1085,7 +1072,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
let mut marf = MemoryBackingStore::new();
let mut vm_env =
OwnedEnvironment::new_free(mainnet, marf.as_clarity_db(), DEFAULT_CLI_EPOCH);
let mut exec_env = vm_env.get_exec_environment(None, None);
let mut exec_env = vm_env.get_exec_environment(None);
let mut analysis_marf = MemoryBackingStore::new();
let contract_id = QualifiedContractIdentifier::transient();
@@ -1110,8 +1097,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
}
};
// TODO: Add --clarity_version as command line argument
let mut ast = match parse(&contract_id, &content, ClarityVersion::Clarity1) {
let mut ast = match parse(&contract_id, &content) {
Ok(val) => val,
Err(error) => {
println!("Parse error:\n{}", error);
@@ -1155,14 +1141,11 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
let contract_id = QualifiedContractIdentifier::transient();
// TODO: Add --clarity_version as command line argument
let mut ast = friendly_expect(
parse(&contract_id, &content, ClarityVersion::Clarity1),
"Failed to parse program.",
);
let mut ast =
friendly_expect(parse(&contract_id, &content), "Failed to parse program.");
match run_analysis_free(&contract_id, &mut ast, &mut analysis_marf, true) {
Ok(_) => {
let result = vm_env.get_exec_environment(None, None).eval_raw(&content);
let result = vm_env.get_exec_environment(None).eval_raw(&content);
match result {
Ok(x) => (
0,
@@ -1212,7 +1195,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
let (_, _, result_and_cost) = in_block(header_db, marf_kv, |header_db, mut marf| {
let result_and_cost = with_env_costs(mainnet, &header_db, &mut marf, |vm_env| {
vm_env
.get_exec_environment(None, None)
.get_exec_environment(None)
.eval_read_only(&evalInput.contract_identifier, &evalInput.content)
});
(header_db, marf, result_and_cost)
@@ -1265,7 +1248,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
let result_and_cost = at_chaintip(vm_filename, marf_kv, |mut marf| {
let result_and_cost = with_env_costs(mainnet, &header_db, &mut marf, |vm_env| {
vm_env
.get_exec_environment(None, None)
.get_exec_environment(None)
.eval_read_only(&evalInput.contract_identifier, &evalInput.content)
});
(marf, result_and_cost)
@@ -1338,7 +1321,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
let result_and_cost = at_block(chain_tip, marf_kv, |mut marf| {
let result_and_cost = with_env_costs(mainnet, &header_db, &mut marf, |vm_env| {
vm_env
.get_exec_environment(None, None)
.get_exec_environment(None)
.eval_read_only(&contract_identifier, &content)
});
(marf, result_and_cost)
@@ -1409,11 +1392,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
// TODO: Add --clarity_version as command line argument
let mut ast = friendly_expect(
parse(
&contract_identifier,
&contract_content,
ClarityVersion::Clarity1,
),
parse(&contract_identifier, &contract_content),
"Failed to parse program.",
);
let header_db =
@@ -1433,11 +1412,8 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
Ok(analysis) => {
let result_and_cost =
with_env_costs(mainnet, &header_db, &mut marf, |vm_env| {
vm_env.initialize_contract(
contract_identifier,
&contract_content,
None,
)
vm_env
.initialize_contract(contract_identifier, &contract_content)
});
(header_db, marf, Ok((analysis, result_and_cost)))
}
@@ -1535,7 +1511,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
.iter()
.map(|argument| {
let argument_parsed = friendly_expect(
vm_execute(argument, &ClarityVersion::Clarity1),
vm_execute(argument),
&format!("Error parsing argument \"{}\"", argument),
);
let argument_value = friendly_expect_opt(
@@ -1548,13 +1524,7 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
let (_, _, result_and_cost) = in_block(header_db, marf_kv, |header_db, mut marf| {
let result_and_cost = with_env_costs(mainnet, &header_db, &mut marf, |vm_env| {
vm_env.execute_transaction(
sender,
None,
contract_identifier,
&tx_name,
&arguments,
)
vm_env.execute_transaction(sender, contract_identifier, &tx_name, &arguments)
});
(header_db, marf, result_and_cost)
});

View File

@@ -20,7 +20,6 @@ use std::fmt;
use std::thread;
use crate::chainstate::stacks::boot::BOOT_CODE_COSTS_2_TESTNET;
use crate::chainstate::stacks::boot::POX_2_NAME;
use crate::chainstate::stacks::db::StacksChainState;
use crate::chainstate::stacks::index::ClarityMarfTrieId;
use crate::chainstate::stacks::StacksMicroblockHeader;
@@ -43,11 +42,7 @@ use crate::{
burnchains::Burnchain,
clarity_vm::database::marf::{MarfedKV, WritableMarfStore},
};
use crate::{
clarity_vm::database::marf::ReadOnlyMarfStore, core::StacksEpochId, vm::ClarityVersion,
};
use chainstate::stacks::boot::POX_2_MAINNET_CODE;
use chainstate::stacks::boot::POX_2_TESTNET_CODE;
use crate::{clarity_vm::database::marf::ReadOnlyMarfStore, core::StacksEpochId};
use chainstate::stacks::boot::{
BOOT_CODE_COSTS, BOOT_CODE_COSTS_2, BOOT_CODE_COST_VOTING_TESTNET as BOOT_CODE_COST_VOTING,
BOOT_CODE_POX_TESTNET, COSTS_2_NAME,
@@ -78,29 +73,6 @@ use vm::types::{
};
use vm::ContractName;
use crate::chainstate::stacks::boot::BOOT_CODE_COSTS_2_TESTNET;
use crate::chainstate::stacks::db::StacksChainState;
use crate::chainstate::stacks::TransactionAuth;
use crate::chainstate::stacks::TransactionPayload;
use crate::chainstate::stacks::TransactionPublicKeyEncoding;
use crate::chainstate::stacks::TransactionSmartContract;
use crate::chainstate::stacks::TransactionSpendingCondition;
use crate::chainstate::stacks::TransactionVersion;
use crate::clarity_vm::database::marf::ReadOnlyMarfStore;
use crate::clarity_vm::database::marf::{MarfedKV, WritableMarfStore};
use crate::core::StacksEpoch;
use crate::core::StacksEpochId;
use crate::core::FIRST_STACKS_BLOCK_ID;
use crate::core::GENESIS_EPOCH;
use crate::types::chainstate::BlockHeaderHash;
use crate::types::chainstate::SortitionId;
use crate::types::chainstate::StacksBlockId;
use crate::types::chainstate::StacksMicroblockHeader;
use crate::types::proof::TrieHash;
use crate::util::boot::{boot_code_acc, boot_code_addr, boot_code_id, boot_code_tx_auth};
use crate::util::secp256k1::MessageSignature;
use types::chainstate::BurnchainHeaderHash;
///
/// A high-level interface for interacting with the Clarity VM.
///
@@ -1178,7 +1150,7 @@ impl<'a, 'b> ClarityTransactionConnection<'a, 'b> {
self.with_abort_callback(
|vm_env| {
vm_env
.execute_in_env(sender.clone(), None, |env| {
.execute_in_env(sender.clone(), |env| {
env.run_as_transaction(|env| {
StacksChainState::handle_poison_microblock(
env,

View File

@@ -29,10 +29,10 @@ use vm::database::{
use vm::errors::{InterpreterResult, RuntimeErrorType};
use vm::test_util::{TEST_BURN_STATE_DB, TEST_HEADER_DB};
use crate::burnchains::PoxConstants;
use crate::types::chainstate::StacksBlockId;
use crate::types::chainstate::{BlockHeaderHash, BurnchainHeaderHash, SortitionId};
use crate::types::chainstate::{StacksAddress, VRFSeed};
use crate::{burnchains::PoxConstants, types::chainstate::StacksBlockId};
use chainstate::stacks::index::{ClarityMarfTrieId, TrieMerkleProof};
use core::{StacksEpoch, StacksEpochId, STACKS_EPOCH_MAX};

View File

@@ -325,12 +325,6 @@ fn test_ord_for_stacks_epoch_id() {
);
}
pub trait StacksEpochExtension {
fn all(
epoch_2_0_block_height: u64,
epoch_2_05_block_height: u64,
epoch_2_1_block_height: u64,
) -> Vec<StacksEpoch>;
#[cfg(test)]
fn unit_test(stacks_epoch_id: StacksEpochId, epoch_2_0_block_height: u64) -> Vec<StacksEpoch>;
#[cfg(test)]
@@ -341,36 +335,23 @@ pub trait StacksEpochExtension {
impl StacksEpochExtension for StacksEpoch {
#[cfg(test)]
fn unit_test(stacks_epoch_id: StacksEpochId, epoch_2_0_block_height: u64) -> Vec<StacksEpoch> {
match stacks_epoch_id {
StacksEpochId::Epoch10 | StacksEpochId::Epoch20 => {
StacksEpoch::unit_test_pre_2_05(epoch_2_0_block_height)
}
StacksEpochId::Epoch2_05 => StacksEpoch::unit_test_2_05(epoch_2_0_block_height),
StacksEpochId::Epoch21 => {
panic!("This method signature is not prepared to go up to Stacks 2.1")
}
}
}
#[cfg(test)]
fn unit_test_pre_2_05(epoch_2_0_block_height: u64) -> Vec<StacksEpoch> {
fn unit_test_pre_2_05(first_burnchain_height: u64) -> Vec<StacksEpoch> {
info!(
"StacksEpoch unit_test first_burn_height = {}",
epoch_2_0_block_height
first_burnchain_height
);
vec![
StacksEpoch {
epoch_id: StacksEpochId::Epoch10,
start_height: 0,
end_height: epoch_2_0_block_height,
end_height: first_burnchain_height,
block_limit: ExecutionCost::max_value(),
network_epoch: PEER_VERSION_EPOCH_1_0,
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch20,
start_height: epoch_2_0_block_height,
start_height: first_burnchain_height,
end_height: STACKS_EPOCH_MAX,
block_limit: ExecutionCost::max_value(),
network_epoch: PEER_VERSION_EPOCH_2_0,
@@ -379,30 +360,30 @@ impl StacksEpochExtension for StacksEpoch {
}
#[cfg(test)]
fn unit_test_2_05(epoch_2_0_block_height: u64) -> Vec<StacksEpoch> {
fn unit_test_2_05(first_burnchain_height: u64) -> Vec<StacksEpoch> {
info!(
"StacksEpoch unit_test first_burn_height = {}",
epoch_2_0_block_height
first_burnchain_height
);
vec![
StacksEpoch {
epoch_id: StacksEpochId::Epoch10,
start_height: 0,
end_height: epoch_2_0_block_height,
end_height: first_burnchain_height,
block_limit: ExecutionCost::max_value(),
network_epoch: PEER_VERSION_EPOCH_1_0,
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch20,
start_height: epoch_2_0_block_height,
end_height: epoch_2_0_block_height + 4,
start_height: first_burnchain_height,
end_height: first_burnchain_height + 4,
block_limit: ExecutionCost::max_value(),
network_epoch: PEER_VERSION_EPOCH_2_0,
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch2_05,
start_height: epoch_2_0_block_height + 4,
start_height: first_burnchain_height + 4,
end_height: STACKS_EPOCH_MAX,
block_limit: ExecutionCost {
write_length: 205205,
@@ -416,40 +397,13 @@ impl StacksEpochExtension for StacksEpoch {
]
}
fn all(
epoch_2_0_block_height: u64,
epoch_2_05_block_height: u64,
epoch_2_1_block_height: u64,
) -> Vec<StacksEpoch> {
vec![
StacksEpoch {
epoch_id: StacksEpochId::Epoch10,
start_height: 0,
end_height: epoch_2_0_block_height,
block_limit: ExecutionCost::max_value(),
network_epoch: PEER_VERSION_EPOCH_1_0,
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch20,
start_height: epoch_2_0_block_height,
end_height: epoch_2_05_block_height,
block_limit: ExecutionCost::max_value(),
network_epoch: PEER_VERSION_EPOCH_1_0,
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch2_05,
start_height: epoch_2_05_block_height,
end_height: epoch_2_1_block_height,
block_limit: ExecutionCost::max_value(),
network_epoch: PEER_VERSION_EPOCH_1_0,
},
StacksEpoch {
epoch_id: StacksEpochId::Epoch21,
start_height: epoch_2_1_block_height,
end_height: STACKS_EPOCH_MAX,
block_limit: ExecutionCost::max_value(),
network_epoch: PEER_VERSION_EPOCH_1_0,
},
]
#[cfg(test)]
fn unit_test(stacks_epoch_id: StacksEpochId, first_burnchain_height: u64) -> Vec<StacksEpoch> {
match stacks_epoch_id {
StacksEpochId::Epoch10 | StacksEpochId::Epoch20 => {
StacksEpoch::unit_test_pre_2_05(first_burnchain_height)
}
StacksEpochId::Epoch2_05 => StacksEpoch::unit_test_2_05(first_burnchain_height),
}
}
}

View File

@@ -43,14 +43,6 @@ extern crate serde_json;
#[macro_use]
extern crate assert_json_diff;
#[cfg(test)]
#[macro_use]
extern crate rstest;
#[cfg(test)]
#[macro_use]
extern crate rstest_reuse;
#[macro_use]
extern crate stacks_common;

View File

@@ -60,7 +60,6 @@ use blockstack_lib::chainstate::stacks::StacksBlockHeader;
use blockstack_lib::chainstate::stacks::*;
use blockstack_lib::clarity::vm::costs::ExecutionCost;
use blockstack_lib::clarity::vm::types::StacksAddressExtensions;
use blockstack_lib::clarity::vm::ClarityVersion;
use blockstack_lib::codec::StacksMessageCodec;
use blockstack_lib::core::*;
use blockstack_lib::cost_estimates::metrics::UnitMetric;

View File

@@ -1966,6 +1966,7 @@ pub mod test {
use std::ops::Deref;
use std::ops::DerefMut;
use std::sync::mpsc::sync_channel;
use std::sync::Mutex;
use std::thread;
use mio;

View File

@@ -70,7 +70,6 @@ pub enum StacksEpochId {
Epoch10 = 0x01000,
Epoch20 = 0x02000,
Epoch2_05 = 0x02005,
Epoch21 = 0x0200a,
}
impl std::fmt::Display for StacksEpochId {
@@ -79,7 +78,6 @@ impl std::fmt::Display for StacksEpochId {
StacksEpochId::Epoch10 => write!(f, "1.0"),
StacksEpochId::Epoch20 => write!(f, "2.0"),
StacksEpochId::Epoch2_05 => write!(f, "2.05"),
StacksEpochId::Epoch21 => write!(f, "2.1"),
}
}
}
@@ -92,7 +90,6 @@ impl TryFrom<u32> for StacksEpochId {
x if x == StacksEpochId::Epoch10 as u32 => Ok(StacksEpochId::Epoch10),
x if x == StacksEpochId::Epoch20 as u32 => Ok(StacksEpochId::Epoch20),
x if x == StacksEpochId::Epoch2_05 as u32 => Ok(StacksEpochId::Epoch2_05),
x if x == StacksEpochId::Epoch21 as u32 => Ok(StacksEpochId::Epoch21),
_ => Err("Invalid epoch"),
}
}

View File

@@ -14,12 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
use crate::vm::ClarityVersion;
#[cfg(test)]
use rstest::rstest;
#[cfg(test)]
use rstest_reuse::{self, *};
use vm::analysis::type_checker::tests::mem_type_check;
use vm::analysis::{
arithmetic_checker::ArithmeticOnlyChecker, arithmetic_checker::Error,
arithmetic_checker::Error::*, mem_type_check, ContractAnalysis,

View File

@@ -14,7 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
use vm::analysis::type_checker::tests::{contracts::type_check, mem_type_check};
use vm::analysis::mem_type_check;
use vm::analysis::type_check;
use vm::analysis::{CheckError, CheckErrors};
use vm::ast::parse;
use vm::database::MemoryBackingStore;

View File

@@ -27,7 +27,7 @@ use vm::types::QualifiedContractIdentifier;
use vm::{
analysis::{CheckError, ContractAnalysis},
costs::LimitedCostTracker,
ClarityVersion, SymbolicExpression,
SymbolicExpression,
};
const SIMPLE_TOKENS: &str = "(define-map tokens { account: principal } { balance: uint })

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
use vm::analysis::type_checker::tests::mem_type_check as run_analysis_helper;
use vm::analysis::mem_type_check as run_analysis_helper;
use vm::ast::definition_sorter::DefinitionSorter;
use vm::ast::errors::ParseErrors;
use vm::ast::errors::ParseResult;

View File

@@ -73,9 +73,6 @@ pub fn build_ast<T: CostTracker>(
mod tests {
use super::*;
use crate::types::chainstate::StacksBlockId;
use crate::types::proof::ClarityMarfTrieId;
use clarity_vm::clarity::ClarityInstance;
use clarity_vm::database::marf::MarfedKV;
use std::collections::HashMap;
use vm::costs::*;
use vm::database::*;

View File

@@ -44,7 +44,6 @@ use vm::{eval, is_reserved};
use crate::{types::chainstate::StacksBlockId, types::StacksEpochId};
use core::StacksEpochId;
use serde::Serialize;
use vm::costs::cost_functions::ClarityCostFunction;
@@ -680,7 +679,7 @@ impl<'a> OwnedEnvironment<'a> {
#[cfg(any(test, feature = "testing"))]
pub fn stx_faucet(&mut self, recipient: &PrincipalData, amount: u128) {
self.execute_in_env::<_, _, ::vm::errors::Error>(recipient.clone(), None, |env| {
self.execute_in_env::<_, _, ::vm::errors::Error>(recipient.clone(), |env| {
let mut snapshot = env
.global_context
.database
@@ -983,7 +982,7 @@ impl<'a, 'b> Environment<'a, 'b> {
match res {
Ok(value) => {
if let Some(handler) = self.global_context.database.get_cc_special_cases_handler() {
handler(&mut self.global_context, self.sender.as_ref(), self.sponsor.as_ref(), contract_identifier, tx_name, &value)?;
handler(&mut self.global_context, self.sender.as_ref(), contract_identifier, tx_name, &value)?;
}
Ok(value)
},

View File

@@ -599,10 +599,7 @@ impl<'a> ClarityDatabase<'a> {
pub fn get_current_burnchain_block_height(&mut self) -> u32 {
let cur_stacks_height = self.store.get_current_block_height();
let last_mined_bhh = if cur_stacks_height == 0 {
StacksBlockHeader::make_index_block_hash(
&FIRST_BURNCHAIN_CONSENSUS_HASH,
&FIRST_STACKS_BLOCK_HASH,
)
StacksBlockId::new(&FIRST_BURNCHAIN_CONSENSUS_HASH, &FIRST_STACKS_BLOCK_HASH)
} else {
self.get_index_block_header_hash(
cur_stacks_height

View File

@@ -43,8 +43,6 @@ pub type SpecialCaseHandler = &'static dyn Fn(
&mut GlobalContext,
// the current sender
Option<&PrincipalData>,
// the current sponsor
Option<&PrincipalData>,
// the invoked contract
&QualifiedContractIdentifier,
// the invoked function name

View File

@@ -1809,7 +1809,7 @@ mod test {
use crate::types::chainstate::{BlockHeaderHash, BurnchainHeaderHash};
use crate::types::chainstate::{SortitionId, StacksAddress, StacksBlockId};
use crate::{types::chainstate::VRFSeed, vm::StacksEpoch};
use vm::analysis::type_checker::tests::contracts::type_check;
use vm::analysis::type_check;
use vm::costs::ExecutionCost;

View File

@@ -147,7 +147,6 @@ pub struct STXTransferEventData {
pub sender: PrincipalData,
pub recipient: PrincipalData,
pub amount: u128,
pub memo: BuffData,
}
impl STXTransferEventData {
@@ -156,7 +155,6 @@ impl STXTransferEventData {
"sender": format!("{}",self.sender),
"recipient": format!("{}",self.recipient),
"amount": format!("{}", self.amount),
"memo": format!("{}", self.memo),
})
}
}

View File

@@ -383,7 +383,6 @@ pub fn eval_all(
/// database. Only used for testing
/// This method executes the program in Epoch 2.0 *and* Epoch 2.05 and asserts
/// that the result is the same before returning the result
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn execute_on_network(program: &str, use_mainnet: bool) -> Result<Option<Value>> {
let epoch_200_result = execute_in_epoch(program, StacksEpochId::Epoch20, use_mainnet);
@@ -397,13 +396,12 @@ pub fn execute_on_network(program: &str, use_mainnet: bool) -> Result<Option<Val
}
/// Execute `program` on the `Testnet`.
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn execute(program: &str) -> Result<Option<Value>> {
execute_on_network(program, false)
}
#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
pub fn execute_in_epoch(
program: &str,
epoch: StacksEpochId,
@@ -415,7 +413,8 @@ pub fn execute_in_epoch(
let mut contract_context = ContractContext::new(contract_id.clone());
let mut marf = MemoryBackingStore::new();
let conn = marf.as_clarity_db();
let mut global_context = GlobalContext::new(false, conn, LimitedCostTracker::new_free(), epoch);
let mut global_context =
GlobalContext::new(use_mainnet, conn, LimitedCostTracker::new_free(), epoch);
global_context.execute(|g| {
let parsed = ast::build_ast(&contract_id, program, &mut ())?.expressions;
eval_all(&parsed, &mut contract_context, g)

View File

@@ -139,23 +139,4 @@ impl BurnStateDB for UnitTestBurnStateDB {
fn get_stacks_epoch_by_epoch_id(&self, _epoch_id: &StacksEpochId) -> Option<StacksEpoch> {
self.get_stacks_epoch(0)
}
fn get_v1_unlock_height(&self) -> u32 {
u32::max_value()
}
fn get_pox_prepare_length(&self) -> u32 {
1
}
fn get_pox_reward_cycle_length(&self) -> u32 {
1
}
fn get_pox_rejection_fraction(&self) -> u64 {
1
}
fn get_burn_start_height(&self) -> u32 {
0
}
}

View File

@@ -16,9 +16,6 @@
use crate::types::chainstate::BlockHeaderHash;
use crate::types::chainstate::StacksBlockId;
use crate::types::proof::ClarityMarfTrieId;
use chainstate::stacks::index::storage::TrieFileStorage;
use clarity_vm::clarity::ClarityInstance;
use util::hash::hex_bytes;
use vm::ast;
use vm::ast::errors::ParseErrors;

View File

@@ -39,7 +39,6 @@ use vm::{CallStack, ContractContext, Environment, GlobalContext, LocalContext, V
use vm::database::MemoryBackingStore;
use vm::types::StacksAddressExtensions;
use vm::ClarityVersion;
#[test]
fn test_doubly_defined_persisted_vars() {