Skip to content

Commit

Permalink
adding some notes for xiangan
Browse files Browse the repository at this point in the history
  • Loading branch information
laudiacay committed Oct 1, 2023
1 parent 00c6d40 commit 5ee39fa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions script/WorkedExample.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,19 @@ contract WorkedExampleScript is Script {
assert(!init);
}
}

// some vm bullshit + startBroadcast(deployer)
// callDeployerSection() // HOLY
// some more vm bullshit + stopBroadcast(deployer)
// startBroadcast(sender)
// callSenderSection() // ALSO HOLY
// vm bullshit
// stopBroadcast(sender)
// vm bullshit
// startBroadcast(solver)
// vm bullshit
// callSolverSection() // ALSO PURE UNTOUCHED AND HOLY
// vm bullshit
// stopBroadcast(solver)

// also: they may want special funky variable names for input and output variables- figure this out later
10 changes: 10 additions & 0 deletions src/examples/SelfCheckout.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ contract SelfCheckout {

(bool success, bytes memory returnvalue) = callbreakerAddress.call(abi.encode(callObj));

// note see comments below on checkBalance- you could also just assert on the returnvalue here.
// note you can also do some computation based on the returnvalue of that future call
// note (like maybe revert on the uniswap price after you did something in the future, if you moved the price too much?) (not all that useful)
// note another way you can use this: consider a problem checkable in O(1), but solvable only in O(n).
// note have the solver solve it, then just check it using the callbreaker (or otherwise on chain)
// what the callbreaker basically serves to do, is that you're inviting people to front/backrun you with the laminator,
// then using the callbreaker to make sure they behave themselves.

if (!success) {
revert("turner CallFailed");
}
Expand Down Expand Up @@ -133,6 +141,8 @@ contract SelfCheckout {
}

// check that you don't owe me anything.
// note: this gets scheduled to be called in the timeturner
// note that it could just return the imbalance after it's called, and then you could assert on the returnvalue when it leaves enterportal
function checkBalance() public {
require(imbalance == 0, "You still owe me some btoken!");
balanceScheduled = false;
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/ICallBreaker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "../TimeTypes.sol";

interface ICallBreaker {
function enterPortal(bytes calldata input) external payable returns (bytes memory);
// TODO (xiangan): add payable/fallback functions

function verify(bytes memory callObjs, bytes memory returnObjs) external;
}

0 comments on commit 5ee39fa

Please sign in to comment.