Skip to content

Commit

Permalink
remove LIMIT_OBJECTS flag and neable it unconditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Dec 4, 2023
1 parent 3818e45 commit 8e2f190
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 19 deletions.
6 changes: 3 additions & 3 deletions fuzz/fuzz_targets/run-generator.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#![no_main]
use chia::allocator::make_allocator;
use chia::gen::conditions::MempoolVisitor;
use chia::gen::flags::{ALLOW_BACKREFS, LIMIT_OBJECTS};
use chia::gen::flags::ALLOW_BACKREFS;
use chia::gen::run_block_generator::{run_block_generator, run_block_generator2};
use chia::gen::validation_error::{ErrorCode, ValidationErr};
use clvmr::chia_dialect::LIMIT_HEAP;
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
let mut a1 = make_allocator(LIMIT_HEAP | LIMIT_OBJECTS);
let mut a1 = make_allocator(LIMIT_HEAP);
let r1 =
run_block_generator::<&[u8], MempoolVisitor>(&mut a1, data, &[], 110000000, ALLOW_BACKREFS);
drop(a1);

let mut a2 = make_allocator(LIMIT_HEAP | LIMIT_OBJECTS);
let mut a2 = make_allocator(LIMIT_HEAP);
let r2 = run_block_generator2::<&[u8], MempoolVisitor>(
&mut a2,
data,
Expand Down
5 changes: 1 addition & 4 deletions src/allocator.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use crate::gen::flags::LIMIT_OBJECTS;
use clvmr::allocator::Allocator;
use clvmr::chia_dialect::LIMIT_HEAP;

pub fn make_allocator(flags: u32) -> Allocator {
if flags & LIMIT_HEAP != 0 {
Allocator::new_limited(500000000, 62500000, 62500000)
} else if flags & LIMIT_OBJECTS != 0 {
Allocator::new_limited(u32::MAX as usize, 62500000, 62500000)
} else {
Allocator::new()
Allocator::new_limited(u32::MAX as usize, 62500000, 62500000)
}
}
6 changes: 0 additions & 6 deletions src/gen/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ use clvmr::MEMPOOL_MODE as CLVM_MEMPOOL_MODE;

// flags controlling to condition parsing

// When set, limit the number of atoms allowed to be allocated to 62'500'000
// Also limit the number of pairs allowed to be allocated to the same limit
// This is similar to LIMIT_HEAP, except this flag only limits the total number
// of pairs and atoms we allow to be allocated, not the total heap size
pub const LIMIT_OBJECTS: u32 = 0x10000;

// unknown condition codes are disallowed
pub const NO_UNKNOWN_CONDS: u32 = 0x20000;

Expand Down
1 change: 0 additions & 1 deletion wheel/chia_rs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ NO_RELATIVE_CONDITIONS_ON_EPHEMERAL: int = ...
ENABLE_BLS_OPS: int = ...
ENABLE_SECP_OPS: int = ...
ENABLE_BLS_OPS_OUTSIDE_GUARD: int = ...
LIMIT_OBJECTS: int = ...
ENABLE_FIXED_DIV: int = ...
ALLOW_BACKREFS: int = ...

Expand Down
1 change: 0 additions & 1 deletion wheel/generate_type_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ def run_puzzle(
ENABLE_BLS_OPS: int = ...
ENABLE_SECP_OPS: int = ...
ENABLE_BLS_OPS_OUTSIDE_GUARD: int = ...
LIMIT_OBJECTS: int = ...
ENABLE_FIXED_DIV: int = ...
ALLOW_BACKREFS: int = ...
Expand Down
5 changes: 1 addition & 4 deletions wheel/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use chia::allocator::make_allocator;
use chia::gen::conditions::MempoolVisitor;
use chia::gen::flags::{
AGG_SIG_ARGS, ALLOW_BACKREFS, ANALYZE_SPENDS, COND_ARGS_NIL, ENABLE_SOFTFORK_CONDITION,
LIMIT_OBJECTS, MEMPOOL_MODE, NO_RELATIVE_CONDITIONS_ON_EPHEMERAL, NO_UNKNOWN_CONDS,
STRICT_ARGS_COUNT,
MEMPOOL_MODE, NO_RELATIVE_CONDITIONS_ON_EPHEMERAL, NO_UNKNOWN_CONDS, STRICT_ARGS_COUNT,
};
use chia::gen::run_puzzle::run_puzzle as native_run_puzzle;
use chia::gen::solution_generator::solution_generator as native_solution_generator;
Expand Down Expand Up @@ -364,7 +363,6 @@ pub fn chia_rs(py: Python, m: &PyModule) -> PyResult<()> {
NO_RELATIVE_CONDITIONS_ON_EPHEMERAL,
)?;
m.add("MEMPOOL_MODE", MEMPOOL_MODE)?;
m.add("LIMIT_OBJECTS", LIMIT_OBJECTS)?;
m.add("ALLOW_BACKREFS", ALLOW_BACKREFS)?;
m.add("ANALYZE_SPENDS", ANALYZE_SPENDS)?;

Expand Down Expand Up @@ -474,7 +472,6 @@ pub fn chia_rs(py: Python, m: &PyModule) -> PyResult<()> {
m.add("ENABLE_BLS_OPS", ENABLE_BLS_OPS)?;
m.add("ENABLE_SECP_OPS", ENABLE_SECP_OPS)?;
m.add("ENABLE_BLS_OPS_OUTSIDE_GUARD", ENABLE_BLS_OPS_OUTSIDE_GUARD)?;
m.add("LIMIT_OBJECTS", LIMIT_OBJECTS)?;

m.add_function(wrap_pyfunction!(serialized_length, m)?)?;
m.add_function(wrap_pyfunction!(compute_merkle_set_root, m)?)?;
Expand Down

0 comments on commit 8e2f190

Please sign in to comment.