Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step 1, first part of going on chain #44

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3585869
Starting to add go on chain to potato handler
prozacchiwawa Oct 7, 2024
be745e4
WIP
prozacchiwawa Oct 8, 2024
f8bad49
Completed the loop logically but not spendable yet
prozacchiwawa Oct 9, 2024
668cafc
Organic move on chain is spending the channel coin and we need to pus…
prozacchiwawa Oct 14, 2024
c3579b9
We're spending the unroll coin i think at the right state along with …
prozacchiwawa Oct 18, 2024
851ef70
WIP: routed in puzzle and solution for requested coins
prozacchiwawa Nov 7, 2024
3aadb66
WIP: we're now starting to engage with spent handlers in channel handler
prozacchiwawa Nov 7, 2024
aa36e29
Merge remote-tracking branch 'upstream/main' into 20241007-potato-go-…
prozacchiwawa Nov 7, 2024
36fe1f1
Merge remote-tracking branch 'upstream/main' into 20241007-potato-go-…
prozacchiwawa Nov 7, 2024
42b305c
fmt + clippy
prozacchiwawa Nov 8, 2024
aadbd68
clippy
prozacchiwawa Nov 8, 2024
b7cd791
Merge up
prozacchiwawa Nov 8, 2024
77e1ee6
Change comment language
prozacchiwawa Nov 8, 2024
be2444f
Small wip
prozacchiwawa Nov 9, 2024
5442af6
Up to spend, wrong puzzle provided (WIP)
prozacchiwawa Nov 12, 2024
32d43fe
More parameterization which gives us the freedom to match things
prozacchiwawa Nov 12, 2024
9ba499e
Ensure that we can give a correct spend of the channel coin downstrea…
prozacchiwawa Nov 14, 2024
08cda55
Add decision about whether we add our half of the signature or whethe…
prozacchiwawa Nov 14, 2024
54e7d53
Add an unroll time lock into channel handler. This is needed to prev…
prozacchiwawa Nov 14, 2024
565ccdb
Rename get_unroll_coin_transaction to get_create_unroll_coin_transact…
prozacchiwawa Nov 14, 2024
4844ccc
Timeout
prozacchiwawa Nov 14, 2024
873fc26
Converting to a better rendition of the state machine given a new und…
prozacchiwawa Nov 14, 2024
1832cb8
Small cleanup: deduplicate some code
prozacchiwawa Nov 14, 2024
2f22c49
Fix up some flow, fallout of deduplication. Primed for the next roun…
prozacchiwawa Nov 14, 2024
5144436
Fix up timeout reporting and filtering in full coinset reports in pee…
prozacchiwawa Nov 14, 2024
4bb00eb
We can spend the unroll coin after the timeout (from the first user's…
prozacchiwawa Nov 15, 2024
d713df5
both players complete on chain transition. We need to populate finis…
prozacchiwawa Nov 16, 2024
328159f
Passing test
prozacchiwawa Nov 16, 2024
e8f4fc8
fmt
prozacchiwawa Nov 16, 2024
5a8309d
Fix most of the clippy traffic.
prozacchiwawa Nov 16, 2024
8bc013d
Ensure we can find the clone method. Figure out something better
prozacchiwawa Nov 16, 2024
7ce16b8
Deref
prozacchiwawa Nov 16, 2024
4880720
fmt + clippy
prozacchiwawa Nov 16, 2024
a0db32e
clippy update
prozacchiwawa Nov 16, 2024
ab2cf99
fmt
prozacchiwawa Nov 16, 2024
57346b7
Fixes
prozacchiwawa Dec 30, 2024
be5bc9c
clippy
prozacchiwawa Dec 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP: we're now starting to engage with spent handlers in channel handler
  • Loading branch information
prozacchiwawa committed Nov 7, 2024
commit 3aadb663c7bc3ec6ada6e38544a428a0bd2af2b4
4 changes: 2 additions & 2 deletions src/channel_handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,15 +1100,15 @@ impl ChannelHandler {
let state_number = usize_from_atom(&rem_conditions[0])
.ok_or_else(|| Error::StrErr("Unconvertible state number".to_string()))?;

let our_parity = self.unroll.coin.state_number & 1;
let our_parity = full_coin.coin.state_number & 1;
let their_parity = state_number & 1;

debug!(
"CHANNEL COIN SPENT: my state {} coin state {} channel coin state {state_number}",
self.current_state_number, full_coin.coin.state_number
);

match state_number.cmp(&self.current_state_number) {
match state_number.cmp(&full_coin.coin.state_number) {
Ordering::Greater => Err(Error::StrErr(format!(
"Reply from the future onchain {} (me {}) vs {}",
state_number, self.current_state_number, self.unroll.coin.state_number
Expand Down
48 changes: 42 additions & 6 deletions src/potato_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,7 @@ impl PotatoHandler {
penv: &mut dyn PeerEnv<'a, G, R>,
action: GameAction,
) -> Result<(), Error>
where
where
G: ToLocalUI + BootstrapTowardWallet + WalletSpendInterface + PacketSender + 'a,
{
if !matches!(self.handshake_state, HandshakeState::Finished(_)) {
Expand All @@ -1652,6 +1652,40 @@ where

Ok(())
}

fn handle_channel_coin_spent<'a, G, R: Rng + 'a>(
&mut self,
penv: &mut dyn PeerEnv<'a, G, R>,
coin_id: &CoinString,
puzzle_and_solution: Option<(&Program, &Program)>,
) -> Result<(), Error>
where
G: ToLocalUI + BootstrapTowardWallet + WalletSpendInterface + PacketSender + 'a,
{
let (puzzle, solution) =
if let Some((puzzle, solution)) = puzzle_and_solution {
(puzzle, solution)
} else {
return Err(Error::StrErr("Retrieve of puzzle and solution failed for channel coin".to_string()));
};

let mut ch = self.channel_handler_mut()?;
let (env, _) = penv.env();
let run_puzzle = puzzle.to_nodeptr(env.allocator)?;
let run_args = solution.to_nodeptr(env.allocator)?;
let conditions = run_program(
env.allocator.allocator(),
&chia_dialect(),
run_puzzle,
run_args,
0,
).into_gen()?;
let cs_spend_result = ch.channel_coin_spent(
env,
conditions.1,
)?;
todo!();
}
}

impl<G: ToLocalUI + BootstrapTowardWallet + WalletSpendInterface + PacketSender, R: Rng>
Expand Down Expand Up @@ -1893,8 +1927,8 @@ impl<G: ToLocalUI + BootstrapTowardWallet + WalletSpendInterface + PacketSender,
fn coin_puzzle_and_solution<'a>(
&mut self,
penv: &mut dyn PeerEnv<'a, G, R>,
_coin_id: &CoinString,
_puzzle_and_solution: Option<(&Program, &Program)>,
coin_id: &CoinString,
puzzle_and_solution: Option<(&Program, &Program)>,
) -> Result<(), Error>
where
G: 'a,
Expand All @@ -1907,8 +1941,10 @@ impl<G: ToLocalUI + BootstrapTowardWallet + WalletSpendInterface + PacketSender,
return Ok(());
};

let mut ch = self.channel_handler_mut()?;
let (env, _) = penv.env();
todo!();
if *coin_id == state_coin_id {
return self.handle_channel_coin_spent(penv, coin_id, puzzle_and_solution);
}

Ok(())
}
}