Merge branch 'next' into feat/poison-microblock

This commit is contained in:
Jude Nelson
2020-11-23 23:12:32 -05:00
8 changed files with 35 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
FEE_RATE=300
MAX_CHAINING=5
MAX_CHAINING=25
CONFIRMATIONS=1
exit_error() {

View File

@@ -7,7 +7,7 @@
(define-constant PREPARE_CYCLE_LENGTH u250)
;; Default length of the PoX reward cycle, in burnchain blocks.
(define-constant REWARD_CYCLE_LENGTH u1000)
(define-constant REWARD_CYCLE_LENGTH u2000)
;; Valid values for burnchain address versions.
;; These correspond to address hash modes in Stacks 2.0.

View File

@@ -57,7 +57,7 @@ use rusqlite::Error as SqliteError;
// maximum number of confirmations a transaction can have before it's garbage-collected
pub const MEMPOOL_MAX_TRANSACTION_AGE: u64 = 256;
pub const MAXIMUM_MEMPOOL_TX_CHAINING: u64 = 5;
pub const MAXIMUM_MEMPOOL_TX_CHAINING: u64 = 25;
pub struct MemPoolAdmitter {
cur_block: BlockHeaderHash,

View File

@@ -58,7 +58,7 @@ pub const POX_SUNSET_START: u64 = (FIRST_BURNCHAIN_BLOCK_HEIGHT as u64) + 100_00
pub const POX_SUNSET_END: u64 = POX_SUNSET_START + 400_000;
pub const POX_PREPARE_WINDOW_LENGTH: u32 = 240;
pub const POX_REWARD_CYCLE_LENGTH: u32 = 1000;
pub const POX_REWARD_CYCLE_LENGTH: u32 = 2000;
/// The maximum amount that PoX rewards can be scaled by.
/// That is, if participation is very low, rewards are:
/// POX_MAXIMAL_SCALING x (rewards with 100% participation)

View File

@@ -125,6 +125,7 @@ pub struct LocalContext<'a> {
pub struct CallStack {
stack: Vec<FunctionIdentifier>,
set: HashSet<FunctionIdentifier>,
apply_depth: usize,
}
pub type StackTrace = Vec<FunctionIdentifier>;
@@ -1396,11 +1397,12 @@ impl CallStack {
CallStack {
stack: Vec::new(),
set: HashSet::new(),
apply_depth: 0,
}
}
pub fn depth(&self) -> usize {
self.stack.len()
self.stack.len() + self.apply_depth
}
pub fn contains(&self, function: &FunctionIdentifier) -> bool {
@@ -1414,6 +1416,14 @@ impl CallStack {
}
}
pub fn incr_apply_depth(&mut self) {
self.apply_depth += 1;
}
pub fn decr_apply_depth(&mut self) {
self.apply_depth -= 1;
}
pub fn remove(&mut self, function: &FunctionIdentifier, tracked: bool) -> Result<()> {
if let Some(removed) = self.stack.pop() {
if removed != *function {

View File

@@ -149,16 +149,15 @@ pub fn apply(
env.call_stack.remove(&identifier, track_recursion)?;
resp
} else {
env.call_stack.insert(&identifier, track_recursion);
let mut used_memory = 0;
let mut evaluated_args = vec![];
env.call_stack.incr_apply_depth();
for arg_x in args.iter() {
let arg_value = match eval(arg_x, env, context) {
Ok(x) => x,
Err(e) => {
env.drop_memory(used_memory);
env.call_stack.remove(&identifier, track_recursion)?;
env.call_stack.decr_apply_depth();
return Err(e);
}
};
@@ -167,13 +166,16 @@ pub fn apply(
Ok(_x) => {}
Err(e) => {
env.drop_memory(used_memory);
env.call_stack.remove(&identifier, track_recursion)?;
env.call_stack.decr_apply_depth();
return Err(Error::from(e));
}
};
used_memory += arg_value.get_memory_use();
evaluated_args.push(arg_value);
}
env.call_stack.decr_apply_depth();
env.call_stack.insert(&identifier, track_recursion);
let mut resp = match function {
CallableType::NativeFunction(_, function, cost_function) => {
let arg_size = evaluated_args.len();

View File

@@ -911,6 +911,18 @@ fn test_lets() {
.for_each(|(program, expectation)| assert_eq!(expectation.clone(), execute(program)));
}
#[test]
fn test_2053_stacked_user_funcs() {
let test = "
(define-read-only (identity (n int)) n)
(begin (identity (identity 1)))
";
let expectation = Value::Int(1);
assert_eq!(expectation, execute(test));
}
#[test]
fn test_asserts() {
let tests = [

View File

@@ -901,7 +901,7 @@ fn contract_stx_transfer() {
})
}
),
5999
25999
);
// check that 1000 stx _was_ debited from SK_3
let sk_3 = StacksPrivateKey::from_hex(SK_3).unwrap();
@@ -916,7 +916,7 @@ fn contract_stx_transfer() {
})
}
),
93000
69000
);
}