2
2
pragma solidity ^ 0.8.17 ;
3
3
4
4
5
- import {INitroTypes} from "../lib/nitro/src/interfaces/INitroTypes.sol " ;
6
- import {NitroUtils} from "../lib/nitro/src/libraries/NitroUtils.sol " ;
5
+ import {INitroTypes} from "nitro/interfaces/INitroTypes.sol " ;
6
+ import {NitroUtils} from "nitro/libraries/NitroUtils.sol " ;
7
+ import {IForceMoveApp} from "nitro/interfaces/IForceMoveApp.sol " ;
7
8
8
9
/**
9
10
* @title NitroRPC
10
11
* @dev Solidity implementation of Nitro RPC protocol structures
11
12
*/
12
- interface NitroRPC {
13
+ contract NitroRPC is IForceMoveApp {
13
14
struct Payload {
14
15
uint256 requestId;
15
16
uint256 timestamp;
@@ -20,8 +21,8 @@ interface NitroRPC {
20
21
21
22
struct PayloadSigned {
22
23
Payload rpcMessage;
23
- Signature clientSig;
24
- Signature serverSig;
24
+ INitroTypes. Signature clientSig;
25
+ INitroTypes. Signature serverSig;
25
26
}
26
27
27
28
enum AllocationIndices {
@@ -37,27 +38,27 @@ interface NitroRPC {
37
38
* @param candidate Recovered variable part the proof was supplied for.
38
39
*/
39
40
function stateIsSupported (
40
- FixedPart calldata fixedPart ,
41
- RecoveredVariablePart[] calldata proof ,
42
- RecoveredVariablePart calldata candidate
41
+ INitroTypes. FixedPart calldata fixedPart ,
42
+ INitroTypes. RecoveredVariablePart[] calldata proof ,
43
+ INitroTypes. RecoveredVariablePart calldata candidate
43
44
) external pure override returns (bool , string memory ) {
44
45
require (fixedPart.participants.length == uint256 (AllocationIndices.Server) + 1 , "bad number of participants " );
45
46
46
47
PayloadSigned memory payloadSigned = abi.decode (candidate.variablePart.appData, (PayloadSigned));
47
- requireValidPayload (payloadSigned);
48
+ requireValidPayload (fixedPart, payloadSigned);
48
49
49
50
return (true , "" );
50
51
}
51
52
52
- function requireValidPayload (PayloadSigned memory payloadSigned ) internal pure {
53
- require (recoverPayloadSigner (payloadSigned.rpcMessage, payloadSigned.clientSig) == fixedPart.participants[AllocationIndices.Client], "bad client signature " );
54
- require (recoverPayloadSigner (payloadSigned.rpcMessage, payloadSigned.serverSig) == fixedPart.participants[AllocationIndices.Server], "bad server signature " );
53
+ function requireValidPayload (INitroTypes.FixedPart calldata fixedPart , PayloadSigned memory payloadSigned ) internal pure {
54
+ require (recoverPayloadSigner (payloadSigned.rpcMessage, payloadSigned.clientSig) == fixedPart.participants[uint256 ( AllocationIndices.Client) ], "bad client signature " );
55
+ require (recoverPayloadSigner (payloadSigned.rpcMessage, payloadSigned.serverSig) == fixedPart.participants[uint256 ( AllocationIndices.Server) ], "bad server signature " );
55
56
56
57
// TODO: verify timestamp and requestId
57
58
}
58
59
59
60
// This pure internal function recovers the signer address from the payload and its signature.
60
- function recoverPayloadSigner (Payload memory payload , Signature memory signature ) internal pure returns (address ) {
61
+ function recoverPayloadSigner (Payload memory payload , INitroTypes. Signature memory signature ) internal pure returns (address ) {
61
62
// Encode and hash the payload data.
62
63
// Using abi.encode ensures proper padding and decoding, avoiding potential ambiguities with dynamic types.
63
64
bytes32 messageHash = keccak256 (
0 commit comments