From 5e3918aa3219616a13e5356cf65af18e274c201a Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 25 Oct 2023 20:37:02 +0200 Subject: [PATCH] rename Policy -> Visitor. construct one per spend --- chia-tools/src/bin/analyze-chain.rs | 5 +-- chia-tools/src/bin/test-block-generators.rs | 10 ++--- fuzz/fuzz_targets/fast-forward.rs | 8 ++-- fuzz/fuzz_targets/parse-conditions.rs | 8 ++-- fuzz/fuzz_targets/parse-spends.rs | 5 +-- fuzz/fuzz_targets/process-spend.rs | 5 +-- fuzz/fuzz_targets/run-generator.rs | 8 ++-- fuzz/fuzz_targets/run-puzzle.rs | 5 +-- src/fast_forward.rs | 8 ++-- src/gen/conditions.rs | 42 ++++++++++----------- src/gen/mod.rs | 2 +- src/gen/run_block_generator.rs | 13 +++---- src/gen/run_puzzle.rs | 9 ++--- src/gen/{policy.rs => spend_visitor.rs} | 4 +- wheel/src/api.rs | 5 +-- wheel/src/run_generator.rs | 14 +++---- 16 files changed, 64 insertions(+), 87 deletions(-) rename src/gen/{policy.rs => spend_visitor.rs} (84%) diff --git a/chia-tools/src/bin/analyze-chain.rs b/chia-tools/src/bin/analyze-chain.rs index 8e6a82778..a924f0069 100644 --- a/chia-tools/src/bin/analyze-chain.rs +++ b/chia-tools/src/bin/analyze-chain.rs @@ -7,7 +7,7 @@ use std::time::SystemTime; use sqlite::State; -use chia::gen::conditions::{parse_spends, MempoolPolicy}; +use chia::gen::conditions::{parse_spends, MempoolVisitor}; use chia::gen::flags::MEMPOOL_MODE; use chia::gen::validation_error::ValidationErr; use chia::generator_rom::{COST_PER_BYTE, GENERATOR_ROM}; @@ -183,12 +183,11 @@ fn main() { let start_conditions = SystemTime::now(); // we pass in what's left of max_cost here, to fail early in case the // cost of a condition brings us over the cost limit - let conds = match parse_spends( + let conds = match parse_spends::( &a, generator_output, ti.cost - clvm_cost, MEMPOOL_MODE, - &mut MempoolPolicy::default(), ) { Err(ValidationErr(_, _)) => { panic!("failed to parse conditions in block {height}"); diff --git a/chia-tools/src/bin/test-block-generators.rs b/chia-tools/src/bin/test-block-generators.rs index 225594602..532edea27 100644 --- a/chia-tools/src/bin/test-block-generators.rs +++ b/chia-tools/src/bin/test-block-generators.rs @@ -5,7 +5,7 @@ use chia_traits::Streamable; use sqlite::State; -use chia::gen::conditions::{NewCoin, NonePolicy, Spend, SpendBundleConditions}; +use chia::gen::conditions::{NewCoin, EmptyVisitor, Spend, SpendBundleConditions}; use chia::gen::flags::{ALLOW_BACKREFS, MEMPOOL_MODE}; use chia::gen::run_block_generator::{run_block_generator, run_block_generator2}; use clvmr::allocator::NodePtr; @@ -157,9 +157,9 @@ fn main() { }; let block_runner = if args.rust_generator { - run_block_generator2::<_, NonePolicy> + run_block_generator2::<_, EmptyVisitor> } else { - run_block_generator::<_, NonePolicy> + run_block_generator::<_, EmptyVisitor> }; while let Ok(State::Row) = statement.next() { @@ -245,7 +245,6 @@ fn main() { &block_refs, ti.cost, flags, - &mut NonePolicy::default(), ) .expect("failed to run block generator"); @@ -262,13 +261,12 @@ fn main() { } if args.validate { - let mut baseline = run_block_generator( + let mut baseline = run_block_generator::<_, EmptyVisitor>( &mut a, prg.as_ref(), &block_refs, ti.cost, 0, - &mut NonePolicy::default(), ) .expect("failed to run block generator"); assert_eq!(baseline.cost, ti.cost); diff --git a/fuzz/fuzz_targets/fast-forward.rs b/fuzz/fuzz_targets/fast-forward.rs index de8360385..47efac326 100644 --- a/fuzz/fuzz_targets/fast-forward.rs +++ b/fuzz/fuzz_targets/fast-forward.rs @@ -1,6 +1,6 @@ #![no_main] use chia::fast_forward::fast_forward_singleton; -use chia::gen::conditions::MempoolPolicy; +use chia::gen::conditions::MempoolVisitor; use chia::gen::run_puzzle::run_puzzle; use chia::gen::validation_error::ValidationErr; use chia_protocol::Bytes32; @@ -57,7 +57,7 @@ fuzz_target!(|data: &[u8]| { let new_solution = node_to_bytes(&a, new_solution).expect("serialize new solution"); // run original spend - let conditions1 = run_puzzle( + let conditions1 = run_puzzle::( &mut a, spend.puzzle_reveal.as_slice(), spend.solution.as_slice(), @@ -65,11 +65,10 @@ fuzz_target!(|data: &[u8]| { spend.coin.amount, 11000000000, 0, - &mut MempoolPolicy::default(), ); // run new spend - let conditions2 = run_puzzle( + let conditions2 = run_puzzle::( &mut a, spend.puzzle_reveal.as_slice(), new_solution.as_slice(), @@ -77,7 +76,6 @@ fuzz_target!(|data: &[u8]| { new_coin.amount, 11000000000, 0, - &mut MempoolPolicy::default(), ); match (conditions1, conditions2) { diff --git a/fuzz/fuzz_targets/parse-conditions.rs b/fuzz/fuzz_targets/parse-conditions.rs index e8c1875da..b3cc662cd 100644 --- a/fuzz/fuzz_targets/parse-conditions.rs +++ b/fuzz/fuzz_targets/parse-conditions.rs @@ -2,8 +2,9 @@ use libfuzzer_sys::fuzz_target; use chia::gen::conditions::{ - parse_conditions, MempoolPolicy, ParseState, Spend, SpendBundleConditions, + parse_conditions, MempoolVisitor, ParseState, Spend, SpendBundleConditions, }; +use chia::gen::spend_visitor::SpendVisitor; use chia_protocol::Bytes32; use chia_protocol::Coin; use clvm_utils::tree_hash; @@ -44,7 +45,7 @@ fuzz_target!(|data: &[u8]| { NO_UNKNOWN_CONDS, ENABLE_SOFTFORK_CONDITION, ] { - let coin_spend = Spend { + let mut coin_spend = Spend { parent_id: a.new_atom(&parent_id).expect("atom failed"), coin_amount: amount, puzzle_hash: a.new_atom(&puzzle_hash).expect("atom failed"), @@ -65,6 +66,7 @@ fuzz_target!(|data: &[u8]| { agg_sig_parent_puzzle: Vec::new(), flags: 0_u32, }; + let mut visitor = MempoolVisitor::new_spend(&mut coin_spend); let mut max_cost: u64 = 3300000000; let _ret = parse_conditions( &a, @@ -74,7 +76,7 @@ fuzz_target!(|data: &[u8]| { input, *flags, &mut max_cost, - &mut MempoolPolicy::default(), + &mut visitor, ); } }); diff --git a/fuzz/fuzz_targets/parse-spends.rs b/fuzz/fuzz_targets/parse-spends.rs index c0b1378d6..4be56f7f9 100644 --- a/fuzz/fuzz_targets/parse-spends.rs +++ b/fuzz/fuzz_targets/parse-spends.rs @@ -1,7 +1,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use chia::gen::conditions::{parse_spends, MempoolPolicy}; +use chia::gen::conditions::{parse_spends, MempoolVisitor}; use clvmr::allocator::Allocator; use fuzzing_utils::{make_tree, BitCursor}; @@ -11,12 +11,11 @@ fuzz_target!(|data: &[u8]| { let mut a = Allocator::new(); let input = make_tree(&mut a, &mut BitCursor::new(data), false); for flags in &[0, COND_ARGS_NIL, STRICT_ARGS_COUNT, NO_UNKNOWN_CONDS] { - let _ret = parse_spends( + let _ret = parse_spends::( &a, input, 33000000000, *flags, - &mut MempoolPolicy::default(), ); } }); diff --git a/fuzz/fuzz_targets/process-spend.rs b/fuzz/fuzz_targets/process-spend.rs index 1e43222d3..bd57b7a26 100644 --- a/fuzz/fuzz_targets/process-spend.rs +++ b/fuzz/fuzz_targets/process-spend.rs @@ -1,6 +1,6 @@ #![no_main] use chia::gen::conditions::{ - process_single_spend, MempoolPolicy, ParseState, SpendBundleConditions, + process_single_spend, MempoolVisitor, ParseState, SpendBundleConditions, }; use chia::gen::flags::{COND_ARGS_NIL, NO_UNKNOWN_CONDS, STRICT_ARGS_COUNT}; use clvmr::allocator::Allocator; @@ -20,7 +20,7 @@ fuzz_target!(|data: &[u8]| { for flags in &[0, COND_ARGS_NIL, STRICT_ARGS_COUNT, NO_UNKNOWN_CONDS] { let mut cost_left = 11000000; - let _ = process_single_spend( + let _ = process_single_spend::( &a, &mut ret, &mut state, @@ -30,7 +30,6 @@ fuzz_target!(|data: &[u8]| { conds, *flags, &mut cost_left, - &mut MempoolPolicy::default(), ); } }); diff --git a/fuzz/fuzz_targets/run-generator.rs b/fuzz/fuzz_targets/run-generator.rs index f23b3ade8..d48bf5296 100644 --- a/fuzz/fuzz_targets/run-generator.rs +++ b/fuzz/fuzz_targets/run-generator.rs @@ -1,6 +1,6 @@ #![no_main] use chia::allocator::make_allocator; -use chia::gen::conditions::MempoolPolicy; +use chia::gen::conditions::MempoolVisitor; use chia::gen::flags::{ALLOW_BACKREFS, LIMIT_OBJECTS}; use chia::gen::run_block_generator::{run_block_generator, run_block_generator2}; use chia::gen::validation_error::{ErrorCode, ValidationErr}; @@ -9,24 +9,22 @@ use libfuzzer_sys::fuzz_target; fuzz_target!(|data: &[u8]| { let mut a1 = make_allocator(LIMIT_HEAP | LIMIT_OBJECTS); - let r1 = run_block_generator::<&[u8], MempoolPolicy>( + let r1 = run_block_generator::<&[u8], MempoolVisitor>( &mut a1, data, &[], 110000000, ALLOW_BACKREFS, - &mut MempoolPolicy::default(), ); drop(a1); let mut a2 = make_allocator(LIMIT_HEAP | LIMIT_OBJECTS); - let r2 = run_block_generator2::<&[u8], MempoolPolicy>( + let r2 = run_block_generator2::<&[u8], MempoolVisitor>( &mut a2, data, &[], 110000000, ALLOW_BACKREFS, - &mut MempoolPolicy::default(), ); drop(a2); diff --git a/fuzz/fuzz_targets/run-puzzle.rs b/fuzz/fuzz_targets/run-puzzle.rs index 75b3ee67c..d9a0c7513 100644 --- a/fuzz/fuzz_targets/run-puzzle.rs +++ b/fuzz/fuzz_targets/run-puzzle.rs @@ -1,5 +1,5 @@ #![no_main] -use chia::gen::conditions::MempoolPolicy; +use chia::gen::conditions::MempoolVisitor; use chia::gen::flags::ALLOW_BACKREFS; use chia::gen::run_puzzle::run_puzzle; use chia_protocol::CoinSpend; @@ -14,7 +14,7 @@ fuzz_target!(|data: &[u8]| { let Ok(spend) = CoinSpend::parse(&mut Cursor::new(data)) else { return; }; - let _ = run_puzzle( + let _ = run_puzzle::( &mut a, spend.puzzle_reveal.as_slice(), spend.solution.as_slice(), @@ -22,6 +22,5 @@ fuzz_target!(|data: &[u8]| { spend.coin.amount, 11000000000, ALLOW_BACKREFS, - &mut MempoolPolicy::default(), ); }); diff --git a/src/fast_forward.rs b/src/fast_forward.rs index 3b22268cf..fa5a619a2 100644 --- a/src/fast_forward.rs +++ b/src/fast_forward.rs @@ -182,7 +182,7 @@ pub fn fast_forward_singleton( #[cfg(test)] mod tests { use super::*; - use crate::gen::conditions::MempoolPolicy; + use crate::gen::conditions::MempoolVisitor; use crate::gen::run_puzzle::run_puzzle; use chia_protocol::CoinSpend; use chia_traits::streamable::Streamable; @@ -242,7 +242,7 @@ mod tests { let new_solution = node_to_bytes(&a, new_solution).expect("serialize new solution"); // run original spend - let conditions1 = run_puzzle( + let conditions1 = run_puzzle::( &mut a, spend.puzzle_reveal.as_slice(), spend.solution.as_slice(), @@ -250,12 +250,11 @@ mod tests { spend.coin.amount, 11000000000, 0, - &mut MempoolPolicy::default(), ) .expect("run_puzzle"); // run new spend - let conditions2 = run_puzzle( + let conditions2 = run_puzzle::( &mut a, spend.puzzle_reveal.as_slice(), new_solution.as_slice(), @@ -263,7 +262,6 @@ mod tests { new_coin.amount, 11000000000, 0, - &mut MempoolPolicy::default(), ) .expect("run_puzzle"); diff --git a/src/gen/conditions.rs b/src/gen/conditions.rs index 14c39bb6f..f31f6c4fd 100644 --- a/src/gen/conditions.rs +++ b/src/gen/conditions.rs @@ -18,7 +18,7 @@ use crate::gen::flags::{ AGG_SIG_ARGS, COND_ARGS_NIL, LIMIT_ANNOUNCES, NO_RELATIVE_CONDITIONS_ON_EPHEMERAL, NO_UNKNOWN_CONDS, STRICT_ARGS_COUNT, }; -use crate::gen::policy::ConditionPolicy; +use crate::gen::spend_visitor::SpendVisitor; use crate::gen::validation_error::check_nil; use chia_protocol::bytes::Bytes32; use clvmr::allocator::{Allocator, NodePtr, SExp}; @@ -47,22 +47,20 @@ pub const HAS_RELATIVE_CONDITION: u32 = 2; // 4. it has an output coin with the same puzzle hash and amount as the spend itself pub const ELIGIBLE_FOR_FF: u32 = 4; -#[derive(Default)] -pub struct NonePolicy {} +pub struct EmptyVisitor {} -impl ConditionPolicy for NonePolicy { - fn new_spend(&mut self, _spend: &mut Spend) {} +impl SpendVisitor for EmptyVisitor { + fn new_spend(_spend: &mut Spend) -> Self { Self{} } fn condition(&mut self, _spend: &mut Spend, _c: &Condition) {} fn post_spend(&mut self, _a: &Allocator, _spend: &mut Spend) {} } -#[derive(Default)] -pub struct MempoolPolicy { +pub struct MempoolVisitor { condition_counter: i32, } -impl ConditionPolicy for MempoolPolicy { - fn new_spend(&mut self, spend: &mut Spend) { +impl SpendVisitor for MempoolVisitor { + fn new_spend(spend: &mut Spend) -> Self { // assume it's eligibe. We'll clear this flag if it isn't let mut spend_flags = ELIGIBLE_FOR_DEDUP; @@ -71,7 +69,8 @@ impl ConditionPolicy for MempoolPolicy { spend_flags |= ELIGIBLE_FOR_FF; } spend.flags |= spend_flags; - self.condition_counter = 0; + + Self { condition_counter: 0 } } fn condition(&mut self, spend: &mut Spend, c: &Condition) { @@ -754,7 +753,7 @@ pub(crate) fn parse_single_spend( } #[allow(clippy::too_many_arguments)] -pub fn process_single_spend( +pub fn process_single_spend( a: &Allocator, ret: &mut SpendBundleConditions, state: &mut ParseState, @@ -764,7 +763,6 @@ pub fn process_single_spend( conditions: NodePtr, flags: u32, max_cost: &mut Cost, - policy: &mut T, ) -> Result<(), ValidationErr> { let parent_id = sanitize_hash(a, parent_id, 32, ErrorCode::InvalidParentId)?; let puzzle_hash = sanitize_hash(a, puzzle_hash, 32, ErrorCode::InvalidPuzzleHash)?; @@ -789,9 +787,9 @@ pub fn process_single_spend( let mut spend = Spend::new(parent_id, my_amount, puzzle_hash, coin_id); - policy.new_spend(&mut spend); + let mut visitor = V::new_spend(&mut spend); - parse_conditions(a, ret, state, spend, conditions, flags, max_cost, policy) + parse_conditions(a, ret, state, spend, conditions, flags, max_cost, &mut visitor) } fn assert_not_ephemeral(spend_flags: &mut u32, state: &mut ParseState, idx: usize) { @@ -813,7 +811,7 @@ fn decrement(cnt: &mut u32, n: NodePtr) -> Result<(), ValidationErr> { } #[allow(clippy::too_many_arguments)] -pub fn parse_conditions( +pub fn parse_conditions( a: &Allocator, ret: &mut SpendBundleConditions, state: &mut ParseState, @@ -821,7 +819,7 @@ pub fn parse_conditions( mut iter: NodePtr, flags: u32, max_cost: &mut Cost, - policy: &mut T, + visitor: &mut V, ) -> Result<(), ValidationErr> { let mut announce_countdown: u32 = if (flags & LIMIT_ANNOUNCES) != 0 { 1024 @@ -869,7 +867,7 @@ pub fn parse_conditions( } c = rest(a, c)?; let cva = parse_args(a, c, op, flags)?; - policy.condition(&mut spend, &cva); + visitor.condition(&mut spend, &cva); match cva { Condition::ReserveFee(limit) => { // reserve fees are accumulated @@ -1097,7 +1095,7 @@ pub fn parse_conditions( } } - policy.post_spend(a, &mut spend); + visitor.post_spend(a, &mut spend); ret.spends.push(spend); Ok(()) @@ -1130,12 +1128,11 @@ fn is_ephemeral( // This function parses, and validates aspects of, the above structure and // returns a list of all spends, along with all conditions, organized by // condition op-code -pub fn parse_spends( +pub fn parse_spends( a: &Allocator, spends: NodePtr, max_cost: Cost, flags: u32, - policy: &mut T, ) -> Result { let mut ret = SpendBundleConditions::default(); let mut state = ParseState::default(); @@ -1152,7 +1149,7 @@ pub fn parse_spends( // as well as updates it with any conditions let (parent_id, puzzle_hash, amount, conds) = parse_single_spend(a, spend)?; - process_single_spend( + process_single_spend::( a, &mut ret, &mut state, @@ -1162,7 +1159,6 @@ pub fn parse_spends( conds, flags, &mut cost_left, - policy, )?; } @@ -1567,7 +1563,7 @@ fn cond_test_cb( print!("{:02x}", c); } println!(); - match parse_spends(&a, n, 11000000000, flags, &mut MempoolPolicy::default()) { + match parse_spends::(&a, n, 11000000000, flags) { Ok(list) => { for n in &list.spends { println!("{:?}", n); diff --git a/src/gen/mod.rs b/src/gen/mod.rs index c835afa63..983df3426 100644 --- a/src/gen/mod.rs +++ b/src/gen/mod.rs @@ -4,7 +4,7 @@ pub mod conditions; pub mod flags; pub mod get_puzzle_and_solution; pub mod opcodes; -pub mod policy; +pub mod spend_visitor; pub mod run_block_generator; pub mod run_puzzle; pub mod sanitize_int; diff --git a/src/gen/run_block_generator.rs b/src/gen/run_block_generator.rs index 9b712a183..cc4bcd272 100644 --- a/src/gen/run_block_generator.rs +++ b/src/gen/run_block_generator.rs @@ -2,7 +2,7 @@ use crate::gen::conditions::{ parse_spends, process_single_spend, validate_conditions, ParseState, SpendBundleConditions, }; use crate::gen::flags::ALLOW_BACKREFS; -use crate::gen::policy::ConditionPolicy; +use crate::gen::spend_visitor::SpendVisitor; use crate::gen::validation_error::{first, ErrorCode, ValidationErr}; use crate::generator_rom::{CLVM_DESERIALIZER, COST_PER_BYTE, GENERATOR_ROM}; use clvm_utils::tree_hash; @@ -36,13 +36,12 @@ fn subtract_cost(a: &Allocator, cost_left: &mut Cost, subtract: Cost) -> Result< // the only reason we need to pass in the allocator is because the returned // SpendBundleConditions contains NodePtr fields. If that's changed, we could // create the allocator inside this functions as well. -pub fn run_block_generator, T: ConditionPolicy>( +pub fn run_block_generator, V: SpendVisitor>( a: &mut Allocator, program: &[u8], block_refs: &[GenBuf], max_cost: u64, flags: u32, - policy: &mut T, ) -> Result { let mut cost_left = max_cost; let byte_cost = program.len() as u64 * COST_PER_BYTE; @@ -76,7 +75,7 @@ pub fn run_block_generator, T: ConditionPolicy>( // we pass in what's left of max_cost here, to fail early in case the // cost of a condition brings us over the cost limit - let mut result = parse_spends(a, generator_output, cost_left, flags, policy)?; + let mut result = parse_spends::(a, generator_output, cost_left, flags)?; result.cost += max_cost - cost_left; Ok(result) } @@ -110,13 +109,12 @@ pub fn extract_n( // you only pay cost for the generator, the puzzles and the conditions). // it also does not apply the stack depth or object allocation limits the same, // as each puzzle run in its own environment. -pub fn run_block_generator2, T: ConditionPolicy>( +pub fn run_block_generator2, V: SpendVisitor>( a: &mut Allocator, program: &[u8], block_refs: &[GenBuf], max_cost: u64, flags: u32, - policy: &mut T, ) -> Result { let byte_cost = program.len() as u64 * COST_PER_BYTE; @@ -171,7 +169,7 @@ pub fn run_block_generator2, T: ConditionPolicy>( let buf = tree_hash(a, puzzle); let puzzle_hash = a.new_atom(&buf)?; - process_single_spend( + process_single_spend::( a, &mut ret, &mut state, @@ -181,7 +179,6 @@ pub fn run_block_generator2, T: ConditionPolicy>( conditions, flags, &mut cost_left, - policy, )?; } if a.atom_len(all_spends) != 0 { diff --git a/src/gen/run_puzzle.rs b/src/gen/run_puzzle.rs index b35907cc6..a4463b49c 100644 --- a/src/gen/run_puzzle.rs +++ b/src/gen/run_puzzle.rs @@ -1,6 +1,6 @@ use crate::gen::conditions::{parse_conditions, ParseState, Spend, SpendBundleConditions}; use crate::gen::flags::ALLOW_BACKREFS; -use crate::gen::policy::ConditionPolicy; +use crate::gen::spend_visitor::SpendVisitor; use crate::gen::validation_error::ValidationErr; use chia_protocol::bytes::Bytes32; use chia_protocol::coin::Coin; @@ -13,7 +13,7 @@ use clvmr::serde::{node_from_bytes, node_from_bytes_backrefs}; use std::sync::Arc; #[allow(clippy::too_many_arguments)] -pub fn run_puzzle( +pub fn run_puzzle( a: &mut Allocator, puzzle: &[u8], solution: &[u8], @@ -21,7 +21,6 @@ pub fn run_puzzle( amount: u64, max_cost: u64, flags: u32, - policy: &mut T, ) -> Result { let deserialize = if (flags & ALLOW_BACKREFS) != 0 { node_from_bytes_backrefs @@ -58,7 +57,7 @@ pub fn run_puzzle( coin_id, ); - policy.new_spend(&mut spend); + let mut visitor = V::new_spend(&mut spend); let mut cost_left = max_cost - clvm_cost; @@ -70,7 +69,7 @@ pub fn run_puzzle( conditions, flags, &mut cost_left, - policy, + &mut visitor, )?; ret.cost = max_cost - cost_left; Ok(ret) diff --git a/src/gen/policy.rs b/src/gen/spend_visitor.rs similarity index 84% rename from src/gen/policy.rs rename to src/gen/spend_visitor.rs index cbc51759e..e768a19cc 100644 --- a/src/gen/policy.rs +++ b/src/gen/spend_visitor.rs @@ -4,8 +4,8 @@ use clvmr::allocator::Allocator; // These are customization points for the condition parsing and validation. The // mempool wants to record additional information than plain consensus // validation, so it hooks into these. -pub trait ConditionPolicy { - fn new_spend(&mut self, spend: &mut Spend); +pub trait SpendVisitor{ + fn new_spend(spend: &mut Spend) -> Self; fn condition(&mut self, spend: &mut Spend, c: &Condition); fn post_spend(&mut self, a: &Allocator, spend: &mut Spend); } diff --git a/wheel/src/api.rs b/wheel/src/api.rs index 859d58f2f..9b27e7a47 100644 --- a/wheel/src/api.rs +++ b/wheel/src/api.rs @@ -4,7 +4,7 @@ use crate::run_generator::{ PySpendBundleConditions, }; use chia::allocator::make_allocator; -use chia::gen::conditions::MempoolPolicy; +use chia::gen::conditions::MempoolVisitor; use chia::gen::flags::{ AGG_SIG_ARGS, ALLOW_BACKREFS, ANALYZE_SPENDS, COND_ARGS_NIL, ENABLE_SOFTFORK_CONDITION, LIMIT_ANNOUNCES, LIMIT_OBJECTS, MEMPOOL_MODE, NO_RELATIVE_CONDITIONS_ON_EPHEMERAL, @@ -161,7 +161,7 @@ fn run_puzzle( flags: u32, ) -> PyResult { let mut a = make_allocator(LIMIT_HEAP); - let conds = native_run_puzzle( + let conds = native_run_puzzle::( &mut a, puzzle, solution, @@ -169,7 +169,6 @@ fn run_puzzle( amount, max_cost, flags, - &mut MempoolPolicy::default(), )?; Ok(convert_spend_bundle_conds(&a, conds)) } diff --git a/wheel/src/run_generator.rs b/wheel/src/run_generator.rs index 240279125..864c40283 100644 --- a/wheel/src/run_generator.rs +++ b/wheel/src/run_generator.rs @@ -1,5 +1,5 @@ use chia::allocator::make_allocator; -use chia::gen::conditions::{MempoolPolicy, NonePolicy, Spend, SpendBundleConditions}; +use chia::gen::conditions::{MempoolVisitor, EmptyVisitor, Spend, SpendBundleConditions}; use chia::gen::flags::ANALYZE_SPENDS; use chia::gen::run_block_generator::run_block_generator as native_run_block_generator; use chia::gen::run_block_generator::run_block_generator2 as native_run_block_generator2; @@ -168,22 +168,20 @@ pub fn run_block_generator( unsafe { std::slice::from_raw_parts(program.buf_ptr() as *const u8, program.len_bytes()) }; let r = if (flags & ANALYZE_SPENDS) == 0 { - native_run_block_generator( + native_run_block_generator::<_, EmptyVisitor>( &mut allocator, program, &refs, max_cost, flags, - &mut NonePolicy::default(), ) } else { - native_run_block_generator( + native_run_block_generator::<_, MempoolVisitor>( &mut allocator, program, &refs, max_cost, flags, - &mut MempoolPolicy::default(), ) }; @@ -231,22 +229,20 @@ pub fn run_block_generator2( unsafe { std::slice::from_raw_parts(program.buf_ptr() as *const u8, program.len_bytes()) }; let r = if (flags & ANALYZE_SPENDS) == 0 { - native_run_block_generator2( + native_run_block_generator2::<_, EmptyVisitor>( &mut allocator, program, &refs, max_cost, flags, - &mut NonePolicy::default(), ) } else { - native_run_block_generator2( + native_run_block_generator2::<_, MempoolVisitor>( &mut allocator, program, &refs, max_cost, flags, - &mut MempoolPolicy::default(), ) };