@@ -7,8 +7,8 @@ import {IRouter} from "../../interfaces/IRouter.sol";
77import {ITypeAndVersion} from "@chainlink/contracts/src/v0.8/shared/interfaces/ITypeAndVersion.sol " ;
88
99import {Client} from "../../libraries/Client.sol " ;
10-
1110import {FinalityCodec} from "../../libraries/FinalityCodec.sol " ;
11+
1212import {IERC165 } from "@openzeppelin/contracts@5.3.0/utils/introspection/IERC165.sol " ;
1313import {EnumerableSet} from "@openzeppelin/contracts@5.3.0/utils/structs/EnumerableSet.sol " ;
1414
@@ -29,14 +29,14 @@ abstract contract BaseVerifier is ICrossChainVerifierV1, ITypeAndVersion {
2929 event AllowListSendersRemoved (uint64 indexed destChainSelector , address senders );
3030 event AllowListStateChanged (uint64 indexed destChainSelector , bool allowlistEnabled );
3131 event StorageLocationsUpdated (string [] oldLocations , string [] newLocations );
32+ event FinalityConfigSet (bytes4 allowedFinality );
3233
3334 // solhint-disable-next-line gas-struct-packing
3435 struct RemoteChainConfig {
3536 IRouter router; // ─────────────╮ Local router to use for messages to/from this chain.
3637 uint16 feeUSDCents; // │ The fee in US dollar cents for messages to this remote chain. [0, $655.35]
3738 uint32 gasForVerification; // │ The gas to reserve for verification of messages on the remote chain.
3839 uint16 payloadSizeBytes; // │ The size of the verification payload on the remote chain.
39- bytes4 allowedFinalityConfig; //│ The finality configuration for the local chain for messages to the remote chain.
4040 bool allowlistEnabled; // ──────╯ True if the allowlist is enabled.
4141 EnumerableSet.AddressSet allowedSendersList; // The list of addresses allowed to send messages.
4242 }
@@ -46,9 +46,8 @@ abstract contract BaseVerifier is ICrossChainVerifierV1, ITypeAndVersion {
4646 uint64 remoteChainSelector; // │ Remote chain selector.
4747 bool allowlistEnabled; // │ True if the allowlist is enabled.
4848 uint16 feeUSDCents; // ────────╯ The fee in US dollar cents for messages to this remote chain.
49- uint32 gasForVerification; // ────╮ The gas to reserve for verification of messages on the remote chain.
50- uint16 payloadSizeBytes; // │ The size of the verification payload on the remote chain.
51- bytes4 allowedFinalityConfig; // ─╯ The finality configuration for the local chain for messages to the remote chain.
49+ uint32 gasForVerification; // ─╮ The gas to reserve for verification of messages on the remote chain.
50+ uint16 payloadSizeBytes; // ───╯ The size of the verification payload on the remote chain.
5251 }
5352
5453 /// @dev Struct to hold the allowlist configuration args per dest chain.
@@ -69,6 +68,10 @@ abstract contract BaseVerifier is ICrossChainVerifierV1, ITypeAndVersion {
6968 /// implement a way to update this value if needed.
7069 string [] internal s_storageLocations;
7170
71+ /// @dev Allowed finality config for fast finality transfers (see `FinalityCodec`).
72+ /// FinalityCodec.WAIT_FOR_FINALITY_FLAG means wait for finality.
73+ bytes4 internal s_allowedFinalityConfig;
74+
7275 constructor (
7376 string [] memory storageLocations ,
7477 address rmnAddress
@@ -110,6 +113,25 @@ abstract contract BaseVerifier is ICrossChainVerifierV1, ITypeAndVersion {
110113 return s_storageLocations;
111114 }
112115
116+ /// @notice Gets the finality config as defined in the FinalityCodec library. This value does NOT 1:1 translate to
117+ /// a block depth. The finality config contains special flags and should only be encoded/decoded using the
118+ /// FinalityCodec library. Checks must happen by calling `FinalityCodec._ensureRequestedFinalityAllowed`.
119+ function getAllowedFinalityConfig () public view virtual returns (bytes4 allowedFinality ) {
120+ return s_allowedFinalityConfig;
121+ }
122+
123+ /// @notice Sets the finality config according to the FinalityCodec library encoding.
124+ /// @param allowedFinality The finality settings allowed in this verifier, according to the FinalityCodec encoding.
125+ function _setAllowedFinalityConfig (
126+ bytes4 allowedFinality
127+ ) internal virtual {
128+ // Any bytes4 value is accepted as allowedFinality; the FinalityCodec semantics are enforced when requests are
129+ // checked against this value via FinalityCodec._ensureRequestedFinalityAllowed.
130+ s_allowedFinalityConfig = allowedFinality;
131+
132+ emit FinalityConfigSet (allowedFinality);
133+ }
134+
113135 /// @notice get ChainConfig configured for the remoteChainSelector.
114136 /// @param remoteChainSelector The remote chain selector.
115137 /// @return remoteChainConfig The struct containing the remote chain settings.
@@ -130,8 +152,7 @@ abstract contract BaseVerifier is ICrossChainVerifierV1, ITypeAndVersion {
130152 allowlistEnabled: config.allowlistEnabled,
131153 feeUSDCents: config.feeUSDCents,
132154 gasForVerification: config.gasForVerification,
133- payloadSizeBytes: config.payloadSizeBytes,
134- allowedFinalityConfig: config.allowedFinalityConfig
155+ payloadSizeBytes: config.payloadSizeBytes
135156 }),
136157 config.allowedSendersList.values ()
137158 );
@@ -168,7 +189,6 @@ abstract contract BaseVerifier is ICrossChainVerifierV1, ITypeAndVersion {
168189 remoteChainConfig.gasForVerification = remoteChainConfigArg.gasForVerification;
169190 // The payload could be zero bytes if no offchain data is required.
170191 remoteChainConfig.payloadSizeBytes = remoteChainConfigArg.payloadSizeBytes;
171- remoteChainConfig.allowedFinalityConfig = remoteChainConfigArg.allowedFinalityConfig;
172192
173193 emit RemoteChainConfigSet (
174194 remoteChainSelector, address (remoteChainConfigArg.router), remoteChainConfig.allowlistEnabled
@@ -265,7 +285,7 @@ abstract contract BaseVerifier is ICrossChainVerifierV1, ITypeAndVersion {
265285 if (config.router == IRouter (address (0 ))) {
266286 revert RemoteChainNotSupported (destChainSelector);
267287 }
268- FinalityCodec._ensureRequestedFinalityAllowed (requestedFinality, config.allowedFinalityConfig );
288+ FinalityCodec._ensureRequestedFinalityAllowed (requestedFinality, getAllowedFinalityConfig () );
269289
270290 return (config.feeUSDCents, config.gasForVerification, config.payloadSizeBytes);
271291 }
0 commit comments