Puzzle #8
RollApp Sequencer Challenge
Author
1// SPDX-License-Identifier: UNLICENSED2pragma solidity 0.8.24;3
4import "@/contracts/interfaces/IPuzzle.sol";5
6/**7 * @title RollApp Sequencer Challenge8 * @author ChainLight / https://x.com/chainlight_io9 * @notice This contract receives data from the rollApp based on pre-allowed addresses and interacts with the rollApp through shared sequencing based on compressed data.10 */11contract ChallengeApp is IPuzzle {12 address public rollApp;13 address public stateStorage;14 address public owner;15
16 error InvalidCaller();17 error InvalidSolution();18 error InvalidRollAppCaller();19
20 mapping(address => mapping(bytes32 => bool)) internal _rollAppStatesReceived;21
22 constructor(address _stateStorage, address _rollApp) {23 rollApp = _rollApp;24 stateStorage = _stateStorage;25 owner = msg.sender;26 }27
28 function recvRollAppData(bytes32 solutionCode) external onlyRollApp returns (bool) {29 if (solutionCode == bytes32(0)) {30 return false;31 }32 _rollAppStatesReceived[tx.origin][solutionCode] = true;33 return true;34 }35
36 function name() external pure returns (string memory) {37 return "RollApp Sequencer Challenge";38 }39
40 function generate(address seed) external view returns (uint256) {41 return uint256(uint160(seed));42 }43
44 function verify(uint256 seed, uint256 solution) external view returns (bool) {45 address solver = address(uint160(seed));46 if (solution != uint256(uint128(uint256(keccak256(abi.encode(seed)))))) {47 revert InvalidSolution();48 }49
50 bytes32 solutionCode = keccak256(abi.encodePacked(seed, solution));51 return _rollAppStatesReceived[solver][solutionCode];52 }53
54 modifier onlyRollApp() {55 if (msg.sender != rollApp) {56 revert InvalidRollAppCaller();57 }58 _;59 }60}
Time Left
Solve locally (WIP)
- Clone GitHub repo + install deps
git clone https://github.com/waterfall-mkt/curta-puzzles.git && cd curta-puzzles && forge install
- Set
RPC_URL_MAINNET
in.env
.env
RPC_URL_MAINNET=""
- Write solution + run script
forge script <PATH_TO_PUZZLE> -f mainnet -vvv
This is still WIP.