@@ -8,14 +8,16 @@ import {ETHBridge} from "./ETHBridge.sol";
8
8
import {ICommitmentStore} from "./ICommitmentStore.sol " ;
9
9
import {ISignalService} from "./ISignalService.sol " ;
10
10
11
- /// @dev SignalService combines secure cross-chain messaging with native token bridging.
11
+ /// @dev SignalService is used for secure cross-chain messaging
12
12
///
13
- /// This contract allows sending arbitrary data as signals via `sendSignal`, verifying signals from other chains using
14
- /// `verifySignal`, and bridging native ETH with built-in signal generation and verification. It integrates:
15
- /// - `CommitmentStore` to access state roots,
16
- /// - `LibSignal` for signal hashing, storage, and verification logic.
13
+ /// This contract allows sending arbitrary data as signals via `sendSignal` and verifying signals from other chains
14
+ /// using`verifySignal`
15
+ /// It integrates:
16
+ /// - `CommitmentStore` to access state roots,
17
+ /// - `LibSignal` for signal hashing, storage, and verification logic.
17
18
///
18
- /// Signals stored cannot be deleted and can be verified multiple times.
19
+ /// Signals stored cannot be deleted
20
+ /// WARN: this contract does not provide replay protection(signals can be verified multiple times).
19
21
contract SignalService is ISignalService , CommitmentStore {
20
22
using LibSignal for bytes32 ;
21
23
@@ -58,12 +60,20 @@ contract SignalService is ISignalService, CommitmentStore {
58
60
// For now it could be the block hash or other hashed value
59
61
// further work is needed to ensure we get the 'state root' of the chain
60
62
bytes32 root = commitmentAt (commitmentPublisher, height);
63
+
64
+ // A 0 root would probably fail further down the line but its better to explicitly check
65
+ require (root != 0 , CommitmentNotFound ());
66
+
61
67
SignalProof memory signalProof = abi.decode (proof, (SignalProof));
62
68
bytes [] memory accountProof = signalProof.accountProof;
63
69
bytes [] memory storageProof = signalProof.storageProof;
64
- // if there is no account proof, verify signal will treat root as a storage root
65
- // for now, we only support full state roots
70
+
71
+ // We only support state roots for verification
72
+ // this is to avoid state roots being used as storage roots (for safety)
66
73
require (accountProof.length != 0 , StorageRootCommitmentNotSupported ());
67
- value.verifySignal (namespace, sender, root, accountProof, storageProof);
74
+
75
+ value.verifySignal (sender, root, accountProof, storageProof);
76
+
77
+ emit SignalVerified (sender, value);
68
78
}
69
79
}
0 commit comments