Skip to content

Commit

Permalink
Enable keccak ops outside guard
Browse files Browse the repository at this point in the history
  • Loading branch information
Rigidity committed Nov 5, 2024
1 parent 60a291a commit 8c2a178
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
23 changes: 21 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@ paste = "1.0.15"
[profile.release]
lto = true
strip = "symbols"

[patch.crates-io]
clvmr = { git = "https://github.com/Chia-Network/clvm_rs", rev = "2f413e72fcf1bcafa4a3117f2c2a0a3a0e7e1c6b" }
14 changes: 4 additions & 10 deletions crates/chia-sdk-test/src/announcements.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use chia_protocol::{Bytes, Bytes32, CoinSpend};
use chia_sdk_types::{
announcement_id, AssertCoinAnnouncement, AssertPuzzleAnnouncement, CreateCoinAnnouncement,
CreatePuzzleAnnouncement,
announcement_id, run_puzzle, AssertCoinAnnouncement, AssertPuzzleAnnouncement,
CreateCoinAnnouncement, CreatePuzzleAnnouncement,
};
use clvm_traits::{FromClvm, ToClvm};
use clvmr::{reduction::Reduction, run_program, Allocator, ChiaDialect, NodePtr};
use clvmr::{Allocator, NodePtr};

#[derive(Debug, Default, Clone)]
pub struct Announcements {
Expand Down Expand Up @@ -77,13 +77,7 @@ pub fn announcements_for_spend(coin_spend: &CoinSpend) -> anyhow::Result<Announc
let puzzle = coin_spend.puzzle_reveal.to_clvm(allocator)?;
let solution = coin_spend.solution.to_clvm(allocator)?;

let Reduction(_cost, output) = run_program(
allocator,
&ChiaDialect::new(0),
puzzle,
solution,
11_000_000_000,
)?;
let output = run_puzzle(allocator, puzzle, solution)?;

let conditions = Vec::<NodePtr>::from_clvm(allocator, output)?;

Expand Down
3 changes: 2 additions & 1 deletion crates/chia-sdk-types/src/run_puzzle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use clvmr::{
chia_dialect::ENABLE_KECCAK_OPS_OUTSIDE_GUARD,
reduction::{EvalErr, Reduction},
Allocator, NodePtr,
};
Expand All @@ -10,7 +11,7 @@ pub fn run_puzzle(
) -> Result<NodePtr, EvalErr> {
let Reduction(_cost, output) = clvmr::run_program(
allocator,
&clvmr::ChiaDialect::new(0),
&clvmr::ChiaDialect::new(ENABLE_KECCAK_OPS_OUTSIDE_GUARD),
puzzle,
solution,
11_000_000_000,
Expand Down
3 changes: 2 additions & 1 deletion napi/src/clvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use chia::{
};
use chia_wallet_sdk::{self as sdk, HashedPtr, SpendContext};
use clvmr::{
chia_dialect::ENABLE_KECCAK_OPS_OUTSIDE_GUARD,
run_program,
serde::{node_from_bytes, node_from_bytes_backrefs},
ChiaDialect, NodePtr, MEMPOOL_MODE,
Expand Down Expand Up @@ -70,7 +71,7 @@ impl ClvmAllocator {
max_cost: BigInt,
mempool_mode: bool,
) -> Result<Output> {
let mut flags = 0;
let mut flags = ENABLE_KECCAK_OPS_OUTSIDE_GUARD;

if mempool_mode {
flags |= MEMPOOL_MODE;
Expand Down

0 comments on commit 8c2a178

Please sign in to comment.