@@ -34,15 +34,8 @@ contract SignalService is ISignalService, ETHBridge, CommitmentStore {
34
34
}
35
35
36
36
/// @inheritdoc ISignalService
37
- function verifySignal (
38
- uint64 chainId ,
39
- uint256 height ,
40
- address sender ,
41
- bytes32 value ,
42
- bytes [] memory accountProof ,
43
- bytes [] memory storageProof
44
- ) external {
45
- _verifySignal (chainId, height, sender, value, accountProof, storageProof);
37
+ function verifySignal (uint64 chainId , uint256 height , address sender , bytes32 value , bytes memory proof ) external {
38
+ _verifySignal (chainId, height, sender, value, proof);
46
39
emit SignalVerified (chainId, sender, value);
47
40
}
48
41
@@ -55,29 +48,40 @@ contract SignalService is ISignalService, ETHBridge, CommitmentStore {
55
48
// CHECK: Should this function be non-reentrant?
56
49
/// @inheritdoc ETHBridge
57
50
/// @dev Overrides ETHBridge.claimDeposit to add signal verification logic.
58
- function claimDeposit (
59
- ETHDeposit memory deposit ,
60
- uint256 height ,
61
- bytes [] memory accountProof ,
62
- bytes [] memory storageProof
63
- ) external override returns (bytes32 id ) {
51
+ function claimDeposit (ETHDeposit memory deposit , uint256 height , bytes memory proof )
52
+ external
53
+ override
54
+ returns (bytes32 id )
55
+ {
64
56
id = _generateId (deposit);
65
57
66
- _verifySignal (deposit.chainId, height, deposit.from, id, accountProof, storageProof );
58
+ _verifySignal (deposit.chainId, height, deposit.from, id, proof );
67
59
68
60
super ._processClaimDepositWithId (id, deposit);
69
61
}
70
62
71
- function _verifySignal (
72
- uint64 chainId ,
73
- uint256 height ,
74
- address sender ,
75
- bytes32 value ,
76
- bytes [] memory accountProof ,
77
- bytes [] memory storageProof
78
- ) internal view {
63
+ function _verifySignal (uint64 chainId , uint256 height , address sender , bytes32 value , bytes memory proof )
64
+ internal
65
+ view
66
+ virtual
67
+ {
68
+ // TODO: commitmentAt(height) might not be the 'state root' of the chain
69
+ // For now it could be the block hash or other hashed value
70
+ // further work is needed to ensure we get the 'state root' of the chain
79
71
bytes32 root = commitmentAt (height);
80
- bool valid = LibSignal.verifySignal (root, chainId, sender, value, accountProof, storageProof);
72
+
73
+ SignalProof memory signalProof = abi.decode (proof, (SignalProof));
74
+ bytes [] memory accountProof = signalProof.accountProof;
75
+ bytes [] memory storageProof = signalProof.storageProof;
76
+ bool valid;
77
+ // If the account proof is empty we assume `root` is the root of the signal tree
78
+ if (accountProof.length == 0 ) {
79
+ // Only verifies a state proof not full storage proof
80
+ valid = LibSignal.verifySignal (root, chainId, sender, value, storageProof);
81
+ require (valid, SignalNotReceived (chainId, value));
82
+ return ;
83
+ }
84
+ valid = LibSignal.verifySignal (root, chainId, sender, value, accountProof, storageProof);
81
85
require (valid, SignalNotReceived (chainId, value));
82
86
}
83
87
}
0 commit comments