From 191a8d93c0f4240df7a141572e8194d47c9a759b Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 22 Nov 2022 13:23:07 +0100 Subject: [PATCH] instead of using a bool field, expose a flags field where one flag indicates eligible for dedup --- src/gen/conditions.rs | 129 +++++++++++++++++++------------------ tests/test_streamable.py | 16 ++--- wheel/src/api.rs | 6 ++ wheel/src/run_generator.rs | 4 +- 4 files changed, 83 insertions(+), 72 deletions(-) diff --git a/src/gen/conditions.rs b/src/gen/conditions.rs index 94a967cc0..c62f353c1 100644 --- a/src/gen/conditions.rs +++ b/src/gen/conditions.rs @@ -305,6 +305,12 @@ impl PartialEq for NewCoin { } } +// spend flags + +// a spend is eligible for deduplication if it does not have any AGG_SIG_ME +// nor AGG_SIG_UNSAFE +pub const ELIGIBLE_FOR_DEDUP: u32 = 1; + // These are all the conditions related directly to a specific spend. #[derive(Debug)] pub struct Spend { @@ -322,9 +328,8 @@ pub struct Spend { pub create_coin: HashSet, // Agg Sig Me conditions pub agg_sig_me: Vec<(NodePtr, NodePtr)>, - // a spend is eligible for deduplication if it does not have any AGG_SIG_ME - // nor AGG_SIG_UNSAFE - pub eligible_for_dedup: bool, + // Flags describing properties of this spend. See flags above + pub flags: u32, } // these are all the conditions and properties of a complete spend bundle. @@ -411,7 +416,7 @@ fn parse_spend_conditions( create_coin: HashSet::new(), agg_sig_me: Vec::new(), // assume it's eligible until we see an agg-sig condition - eligible_for_dedup: true, + flags: ELIGIBLE_FOR_DEDUP, }; let mut iter = first(a, cond)?; @@ -516,11 +521,11 @@ fn parse_spend_conditions( } Condition::AggSigMe(pk, msg) => { spend.agg_sig_me.push((pk, msg)); - spend.eligible_for_dedup = false; + spend.flags &= !ELIGIBLE_FOR_DEDUP; } Condition::AggSigUnsafe(pk, msg) => { ret.agg_sig_unsafe.push((pk, msg)); - spend.eligible_for_dedup = false; + spend.flags &= !ELIGIBLE_FOR_DEDUP; } Condition::Skip => {} } @@ -907,7 +912,7 @@ fn test_invalid_condition_args_terminator() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(spend.seconds_relative, 50); } @@ -934,7 +939,7 @@ fn test_invalid_condition_list_terminator() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(spend.seconds_relative, 50); } @@ -993,7 +998,7 @@ fn test_single_seconds_relative() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(spend.seconds_relative, 101); } @@ -1009,7 +1014,7 @@ fn test_single_seconds_relative_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(spend.seconds_relative, 101); } @@ -1048,7 +1053,7 @@ fn test_multiple_seconds_relative() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); // we use the MAX value assert_eq!(spend.seconds_relative, 503); @@ -1064,7 +1069,7 @@ fn test_single_seconds_absolute() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(conds.seconds_absolute, 104); } @@ -1080,7 +1085,7 @@ fn test_single_seconds_absolute_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(conds.seconds_absolute, 104); } @@ -1122,7 +1127,7 @@ fn test_multiple_seconds_absolute() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); // we use the MAX value assert_eq!(conds.seconds_absolute, 503); @@ -1138,7 +1143,7 @@ fn test_single_height_relative() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(spend.height_relative, Some(101)); } @@ -1154,7 +1159,7 @@ fn test_single_height_relative_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(spend.height_relative, Some(101)); } @@ -1184,7 +1189,7 @@ fn test_single_height_relative_zero() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(spend.height_relative, Some(0)); } @@ -1211,7 +1216,7 @@ fn test_multiple_height_relative() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); // we use the MAX value assert_eq!(spend.height_relative, Some(503)); @@ -1227,7 +1232,7 @@ fn test_single_height_absolute() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(conds.height_absolute, 100); } @@ -1243,7 +1248,7 @@ fn test_single_height_absolute_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(conds.height_absolute, 100); } @@ -1285,7 +1290,7 @@ fn test_multiple_height_absolute() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); // we use the MAX value assert_eq!(conds.height_absolute, 503); @@ -1301,7 +1306,7 @@ fn test_single_reserve_fee() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(conds.reserve_fee, 100); } @@ -1317,7 +1322,7 @@ fn test_single_reserve_fee_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); assert_eq!(conds.reserve_fee, 100); } @@ -1361,7 +1366,7 @@ fn test_multiple_reserve_fee() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); // reserve fee conditions are accumulated 100 + 50 = 150 assert_eq!(conds.reserve_fee, 175); @@ -1380,7 +1385,7 @@ fn test_coin_announces_consume() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1399,7 +1404,7 @@ fn test_create_coin_announce_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1434,7 +1439,7 @@ fn test_assert_coin_announce_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1515,7 +1520,7 @@ fn test_puzzle_announces_consume() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1534,7 +1539,7 @@ fn test_create_puzzle_announces_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1569,7 +1574,7 @@ fn test_assert_puzzle_announces_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1649,7 +1654,7 @@ fn test_single_assert_my_amount() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1663,7 +1668,7 @@ fn test_single_assert_my_amount_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1726,7 +1731,7 @@ fn test_multiple_assert_my_amount() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1761,7 +1766,7 @@ fn test_single_assert_my_coin_id() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1775,7 +1780,7 @@ fn test_single_assert_my_coin_id_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1816,7 +1821,7 @@ fn test_multiple_assert_my_coin_id() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1853,7 +1858,7 @@ fn test_single_assert_my_parent_coin_id() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1867,7 +1872,7 @@ fn test_single_assert_my_parent_coin_id_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1895,7 +1900,7 @@ fn test_multiple_assert_my_parent_coin_id() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1931,7 +1936,7 @@ fn test_single_assert_my_puzzle_hash() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1945,7 +1950,7 @@ fn test_single_assert_my_puzzle_hash_extra_arg() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -1973,7 +1978,7 @@ fn test_multiple_assert_my_puzzle_hash() { let spend = &conds.spends[0]; assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2015,7 +2020,7 @@ fn test_single_create_coin() { assert_eq!(c.amount, 42_u64); assert_eq!(c.hint, a.null()); } - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2035,7 +2040,7 @@ fn test_create_coin_max_amount() { assert_eq!(c.amount, 0xffffffffffffffff_u64); assert_eq!(c.hint, a.null()); } - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2087,7 +2092,7 @@ fn test_create_coin_with_hint() { assert!(c.amount == 42_u64); assert!(a.atom(c.hint) == H1.to_vec()); } - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2108,7 +2113,7 @@ fn test_create_coin_extra_arg() { assert!(c.amount == 42_u64); assert!(a.atom(c.hint) == H1.to_vec()); } - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2142,7 +2147,7 @@ fn test_create_coin_with_multiple_hints() { assert!(c.amount == 42_u64); assert!(a.atom(c.hint) == H1.to_vec()); } - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2162,7 +2167,7 @@ fn test_create_coin_with_hint_as_atom() { assert_eq!(c.amount, 42_u64); assert_eq!(c.hint, a.null()); } - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2181,7 +2186,7 @@ fn test_create_coin_with_invalid_hint_as_terminator() { assert_eq!(c.amount, 42_u64); assert_eq!(c.hint, a.null()); } - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2213,7 +2218,7 @@ fn test_create_coin_with_short_hint() { assert!(c.amount == 42_u64); assert!(a.atom(c.hint) == MSG1.to_vec()); } - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2233,7 +2238,7 @@ fn test_create_coin_with_long_hint() { assert_eq!(c.amount, 42_u64); assert_eq!(c.hint, a.null()); } - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2254,7 +2259,7 @@ fn test_create_coin_with_pair_hint() { assert_eq!(c.amount, 42_u64); assert_eq!(a.atom(c.hint), H1.to_vec()); } - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2274,7 +2279,7 @@ fn test_create_coin_with_cons_hint() { assert_eq!(c.amount, 42_u64); assert_eq!(c.hint, a.null()); } - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2300,7 +2305,7 @@ fn test_multiple_create_coin() { amount: 43_u64, hint: a.null() })); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2363,7 +2368,7 @@ fn test_single_agg_sig_me() { assert_eq!(a.atom(c.0), PUBKEY); assert_eq!(a.atom(c.1), MSG1); } - assert_eq!(spend.eligible_for_dedup, false); + assert_eq!(spend.flags, 0); } #[test] @@ -2385,7 +2390,7 @@ fn test_duplicate_agg_sig_me() { assert_eq!(a.atom(c.0), PUBKEY); assert_eq!(a.atom(c.1), MSG1); } - assert_eq!(spend.eligible_for_dedup, false); + assert_eq!(spend.flags, 0); } #[test] @@ -2459,7 +2464,7 @@ fn test_single_agg_sig_unsafe() { assert_eq!(a.atom(*pk), PUBKEY); assert_eq!(a.atom(*msg), MSG1); } - assert_eq!(spend.eligible_for_dedup, false); + assert_eq!(spend.flags, 0); } #[test] @@ -2527,7 +2532,7 @@ fn test_agg_sig_unsafe_invalid_terminator() { assert_eq!(a.atom(*pk), PUBKEY); assert_eq!(a.atom(*msg), MSG1); } - assert_eq!(spend.eligible_for_dedup, false); + assert_eq!(spend.flags, 0); } #[test] @@ -2562,7 +2567,7 @@ fn test_agg_sig_me_invalid_terminator() { assert_eq!(a.atom(*pk), PUBKEY); assert_eq!(a.atom(*msg), MSG1); } - assert_eq!(spend.eligible_for_dedup, false); + assert_eq!(spend.flags, 0); } #[test] @@ -2599,7 +2604,7 @@ fn test_duplicate_agg_sig_unsafe() { assert_eq!(a.atom(*pk), PUBKEY); assert_eq!(a.atom(*msg), MSG1); } - assert_eq!(spend.eligible_for_dedup, false); + assert_eq!(spend.flags, 0); } #[test] @@ -2725,7 +2730,7 @@ fn test_always_true() { assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); assert_eq!(spend.agg_sig_me.len(), 0); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } #[test] @@ -2747,5 +2752,5 @@ fn test_always_true_with_arg() { assert_eq!(*spend.coin_id, test_coin_id(H1, H2, 123)); assert_eq!(a.atom(spend.puzzle_hash), H2); assert_eq!(spend.agg_sig_me.len(), 0); - assert_eq!(spend.eligible_for_dedup, true); + assert_eq!(spend.flags, ELIGIBLE_FOR_DEDUP); } diff --git a/tests/test_streamable.py b/tests/test_streamable.py index f40b96a82..01e80b185 100644 --- a/tests/test_streamable.py +++ b/tests/test_streamable.py @@ -39,7 +39,7 @@ def test_json_spend() -> None: "seconds_relative": 0, "create_coin": [["0x" + ph2.hex(), 1000000, None]], "agg_sig_me": [["0x" + sig.hex(), "0x6d7367"]], - "eligible_for_dedup": False, + "flags": 0, } def test_from_json_spend() -> None: @@ -53,7 +53,7 @@ def test_from_json_spend() -> None: "seconds_relative": 0, "create_coin": [["0x" + ph2.hex(), 1000000, None]], "agg_sig_me": [["0x" + sig.hex(), "0x6d7367"]], - "eligible_for_dedup": False, + "flags": 0, }) assert a == b @@ -68,7 +68,7 @@ def test_from_json_spend_set_optional() -> None: "seconds_relative": 0, "create_coin": [["0x" + ph2.hex(), 1000000, None]], "agg_sig_me": [["0x" + sig.hex(), "0x6d7367"]], - "eligible_for_dedup": False, + "flags": 0, }) assert a == b @@ -83,7 +83,7 @@ def test_invalid_hex_prefix() -> None: "seconds_relative": 0, "create_coin": [["0x" + ph2.hex(), 1000000, None]], "agg_sig_me": [["0x" + sig.hex(), "0x6d7367"]], - "eligible_for_dedup": False, + "flags": 0, }) def test_invalid_hex_prefix_bytes() -> None: @@ -97,7 +97,7 @@ def test_invalid_hex_prefix_bytes() -> None: "create_coin": [["0x" + ph2.hex(), 1000000, None]], # the message field is missing the 0x prefix and is variable length bytes "agg_sig_me": [["0x" + sig.hex(), "6d7367"]], - "eligible_for_dedup": False, + "flags": 0, }) def test_invalid_hex_digit() -> None: @@ -111,7 +111,7 @@ def test_invalid_hex_digit() -> None: "seconds_relative": 0, "create_coin": [["0x" + ph2.hex(), 1000000, None]], "agg_sig_me": [["0x" + sig.hex(), "0x6d7367"]], - "eligible_for_dedup": False, + "flags": 0, }) def test_invalid_hex_length() -> None: @@ -125,7 +125,7 @@ def test_invalid_hex_length() -> None: "seconds_relative": 0, "create_coin": [["0x" + ph2.hex(), 1000000, None]], "agg_sig_me": [["0x" + sig.hex(), "0x6d7367"]], - "eligible_for_dedup": False, + "flags": 0, }) def test_missing_field() -> None: @@ -138,7 +138,7 @@ def test_missing_field() -> None: "seconds_relative": 0, "create_coin": [["0x" + ph2.hex(), 1000000, None]], "agg_sig_me": [["0x" + sig.hex(), "0x6d7367"]], - "eligible_for_dedup": False, + "flags": 0, }) diff --git a/wheel/src/api.rs b/wheel/src/api.rs index 5a2f74831..b05af2297 100644 --- a/wheel/src/api.rs +++ b/wheel/src/api.rs @@ -98,13 +98,19 @@ pub fn get_puzzle_and_solution_for_coin<'py>( #[pymodule] pub fn chia_rs(_py: Python, m: &PyModule) -> PyResult<()> { + // generator functions m.add_function(wrap_pyfunction!(run_generator, m)?)?; m.add_class::()?; + m.add("ELIGIBLE_FOR_DEDUP", chia::gen::conditions::ELIGIBLE_FOR_DEDUP)?; m.add_class::()?; + + // clvm functions m.add("COND_ARGS_NIL", COND_ARGS_NIL)?; m.add("NO_UNKNOWN_CONDS", NO_UNKNOWN_CONDS)?; m.add("STRICT_ARGS_COUNT", STRICT_ARGS_COUNT)?; m.add("MEMPOOL_MODE", MEMPOOL_MODE)?; + + // Chia classes m.add_class::()?; m.add_class::()?; m.add_class::()?; diff --git a/wheel/src/run_generator.rs b/wheel/src/run_generator.rs index 3fd2354e2..9744bb44e 100644 --- a/wheel/src/run_generator.rs +++ b/wheel/src/run_generator.rs @@ -30,7 +30,7 @@ pub struct PySpend { pub seconds_relative: u64, pub create_coin: Vec<(Bytes32, u64, Option)>, pub agg_sig_me: Vec<(Bytes48, Bytes)>, - pub eligible_for_dedup: bool, + pub flags: u32, } #[pyclass(name = "SpendBundleConditions")] @@ -72,7 +72,7 @@ fn convert_spend(a: &Allocator, spend: Spend) -> PySpend { seconds_relative: spend.seconds_relative, create_coin, agg_sig_me: agg_sigs, - eligible_for_dedup: spend.eligible_for_dedup, + flags: spend.flags, } }