make agg work

This commit is contained in:
Yostra 2020-09-15 11:47:11 -07:00 committed by Gene Hoffman
parent 7ce1e44654
commit afbec4160f
3 changed files with 19 additions and 19 deletions

View File

@ -313,6 +313,7 @@ class RLWallet(AbstractWallet):
coin,
await self.get_rl_parent(),
await self.get_rl_coin())
tx_record = TransactionRecord(
confirmed_at_index=uint32(0),
created_at_time=uint64(int(time.time())),
@ -687,7 +688,7 @@ class RLWallet(AbstractWallet):
raise ValueError("Rl coin record is None")
list_of_coinsolutions = []
self.rl_coin_record = await self.get_rl_coin_record()
pubkey, secretkey = await self.get_keys(self.rl_coin_record.coin.puzzle_hash)
# Spend wallet coin
puzzle = rl_puzzle_for_pk(
@ -708,12 +709,13 @@ class RLWallet(AbstractWallet):
rl_parent.amount,
rl_parent.parent_coin_info,
)
# cost, sexp = run_program(puzzle, solution)
signature = AugSchemeMPL.sign(secretkey, solution.get_tree_hash())
rl_spend = CoinSolution(self.rl_coin_record.coin, Program.to([puzzle, solution]))
list_of_coinsolutions.append(
CoinSolution(self.rl_coin_record.coin, Program.to([puzzle, solution]))
rl_spend
)
# Spend consolidating coin
@ -723,24 +725,22 @@ class RLWallet(AbstractWallet):
self.rl_coin_record.coin.parent_coin_info,
self.rl_coin_record.coin.amount,
)
list_of_coinsolutions.append(
CoinSolution(consolidating_coin, Program.to([puzzle, solution]))
)
agg_spend = CoinSolution(consolidating_coin, Program.to([puzzle, solution]))
list_of_coinsolutions.append(agg_spend)
# Spend lock
puzstring = (
"(r (c (q 0x"
+ hexlify(consolidating_coin.name()).decode("ascii")
+ ") (q ())))"
f"(r (c (q 0x{consolidating_coin.name().hex()}) (q ())))"
)
puzzle = Program(binutils.assemble(puzstring))
solution = Program(binutils.assemble("()"))
list_of_coinsolutions.append(
CoinSolution(
Coin(self.rl_coin_record.coin, puzzle.get_tree_hash(), uint64(0)),
ephemeral = CoinSolution(
Coin(self.rl_coin_record.coin.name(), puzzle.get_tree_hash(), uint64(0)),
Program.to([puzzle, solution]),
)
)
list_of_coinsolutions.append(ephemeral)
aggsig = AugSchemeMPL.aggregate([signature])

View File

@ -47,7 +47,7 @@ def rl_puzzle_for_pk(
RATE_LIMIT_PUZZLE = f"(c {TEMPLATE_SINGLETON_RL} (c {TEMPLATE_BLOCK_AGE} (c {CREATE_CHANGE} (c {TEMPLATE_MY_ID} (c {CREATE_NEW_COIN} (q ()))))))" # noqa: E501
TEMPLATE_MY_PARENT_ID_2 = "(sha256 (f (r (r (r (r (r (r (r (r 1))))))))) (f (r 1)) (f (r (r (r (r (r (r (r 1)))))))))" # noqa: E501
TEMPLATE_SINGLETON_RL_2 = f'((c (i (i (= {TEMPLATE_MY_PARENT_ID_2} (f (r (r (r (r (r 1))))))) (q 1) (= (f (r (r (r (r (r 1)))))) (q 0x{origin_id}))) (q (c (q 1) (q ()))) (q (x (q "Parent doesnt satisfy RL conditions")))) 1))' # noqa: E501
TEMPLATE_SINGLETON_RL_2 = f'((c (i (i (= {TEMPLATE_MY_PARENT_ID_2} (f (r (r (r (r (r 1))))))) (q 1) (= (f (r (r (r (r (r 1)))))) (q 0x{origin_id}))) (q ()) (q (x (q "Parent doesnt satisfy RL conditions")))) 1))' # noqa: E501
CREATE_CONSOLIDATED = f"(c (q 0x{opcode_create}) (c (f (r 1)) (c (+ (f (r (r (r (r 1))))) (f (r (r (r (r (r (r 1)))))))) (q ()))))" # noqa: E501
MODE_TWO_ME_STRING = f"(c (q 0x{opcode_myid}) (c (sha256 (f (r (r (r (r (r 1)))))) (f (r 1)) (f (r (r (r (r (r (r 1)))))))) (q ())))" # noqa: E501
CREATE_LOCK = f"(c (q 0x{opcode_create}) (c (sha256tree (c (q 7) (c (c (q 5) (c (c (q 1) (c (sha256 (f (r (r 1))) (f (r (r (r 1)))) (f (r (r (r (r 1)))))) (q ()))) (c (q (q ())) (q ())))) (q ())))) (c (q 0) (q ()))))" # noqa: E501

View File

@ -20,7 +20,7 @@ def event_loop():
yield loop
class TestCCWallet:
class TestRLWallet:
@pytest.fixture(scope="function")
async def three_wallet_nodes(self):
async for _ in setup_simulators_and_wallets(
@ -69,7 +69,7 @@ class TestCCWallet:
"wallet_type": "rl_wallet",
"rl_type": "admin",
"interval": 2,
"limit": 1,
"limit": 10,
"pubkey": pubkey,
"amount": 100,
"host": "127.0.0.1:5000",
@ -90,7 +90,7 @@ class TestCCWallet:
{
"wallet_id": user_wallet_id,
"interval": 2,
"limit": 1,
"limit": 10,
"origin": {
"parent_coin_info": origin.parent_coin_info.hex(),
"puzzle_hash": origin.puzzle_hash.hex(),
@ -146,7 +146,7 @@ class TestCCWallet:
utxo = [c for c in await full_node.coin_store.get_unspent_coin_records() if not c.coinbase]
val = await api_admin.add_rate_limited_funds({"wallet_id": admin_wallet_id, "amount": 100})
assert val["status"] == "SUCCESS"
for i in range(0, 2*num_blocks):
for i in range(0, 50):
await full_node.farm_new_block(FarmNewBlockProtocol(32 * b"\0"))
await time_out_assert(15, check_balance, 197, api_user, user_wallet_id)
utxo_2 = [c for c in await full_node.coin_store.get_unspent_coin_records() if not c.coinbase]
@ -155,7 +155,7 @@ class TestCCWallet:
val = await api_user.send_transaction(
{
"wallet_id": user_wallet_id,
"amount": 3,
"amount": 197,
"fee": 0,
"puzzle_hash": puzzle_hash,
}