@keep-network/tbtc-v2 1.3.0-dev.6 → 1.3.0-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/BLS.json +1 -1
- package/artifacts/Bank.json +3 -3
- package/artifacts/BeaconAuthorization.json +1 -1
- package/artifacts/BeaconDkg.json +1 -1
- package/artifacts/BeaconDkgValidator.json +1 -1
- package/artifacts/BeaconInactivity.json +1 -1
- package/artifacts/BeaconSortitionPool.json +3 -3
- package/artifacts/Bridge.json +5 -5
- package/artifacts/BridgeGovernance.json +2 -2
- package/artifacts/BridgeGovernanceParameters.json +2 -2
- package/artifacts/Deposit.json +2 -2
- package/artifacts/DepositSweep.json +2 -2
- package/artifacts/DonationVault.json +3 -3
- package/artifacts/EcdsaDkgValidator.json +1 -1
- package/artifacts/EcdsaInactivity.json +1 -1
- package/artifacts/EcdsaSortitionPool.json +3 -3
- package/artifacts/Fraud.json +2 -2
- package/artifacts/KeepRegistry.json +1 -1
- package/artifacts/KeepStake.json +2 -2
- package/artifacts/KeepToken.json +2 -2
- package/artifacts/KeepTokenStaking.json +1 -1
- package/artifacts/LightRelay.json +18 -18
- package/artifacts/LightRelayMaintainerProxy.json +8 -8
- package/artifacts/MaintainerProxy.json +19 -19
- package/artifacts/MovingFunds.json +2 -2
- package/artifacts/NuCypherStakingEscrow.json +1 -1
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeacon.json +2 -2
- package/artifacts/RandomBeaconChaosnet.json +2 -2
- package/artifacts/RandomBeaconGovernance.json +2 -2
- package/artifacts/Redemption.json +2 -2
- package/artifacts/ReimbursementPool.json +2 -2
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +3 -3
- package/artifacts/TBTCToken.json +3 -3
- package/artifacts/TBTCVault.json +23 -23
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +3 -3
- package/artifacts/VendingMachineKeep.json +1 -1
- package/artifacts/VendingMachineNuCypher.json +1 -1
- package/artifacts/VendingMachineV2.json +3 -3
- package/artifacts/VendingMachineV3.json +3 -3
- package/artifacts/WalletCoordinator.json +134 -70
- package/artifacts/WalletRegistry.json +5 -5
- package/artifacts/WalletRegistryGovernance.json +2 -2
- package/artifacts/Wallets.json +2 -2
- package/artifacts/solcInputs/{7da6b4ef582799bac2eaf0403f4eac81.json → 009e6f26634d88e04ffd661b04b7f1be.json} +1 -1
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
- package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
- package/build/contracts/bridge/BridgeGovernanceParameters.sol/BridgeGovernanceParameters.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
- package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
- package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachineV2.sol/VendingMachineV2.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachineV3.sol/VendingMachineV3.dbg.json +1 -1
- package/build/contracts/bridge/WalletCoordinator.sol/WalletCoordinator.dbg.json +1 -1
- package/build/contracts/bridge/WalletCoordinator.sol/WalletCoordinator.json +123 -59
- package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
- package/build/contracts/l2/L2TBTC.sol/L2TBTC.dbg.json +1 -1
- package/build/contracts/l2/L2WormholeGateway.sol/IWormholeTokenBridge.dbg.json +1 -1
- package/build/contracts/l2/L2WormholeGateway.sol/L2WormholeGateway.dbg.json +1 -1
- package/build/contracts/maintainer/MaintainerProxy.sol/MaintainerProxy.dbg.json +1 -1
- package/build/contracts/relay/LightRelay.sol/ILightRelay.dbg.json +1 -1
- package/build/contracts/relay/LightRelay.sol/LightRelay.dbg.json +1 -1
- package/build/contracts/relay/LightRelay.sol/RelayUtils.dbg.json +1 -1
- package/build/contracts/relay/LightRelayMaintainerProxy.sol/LightRelayMaintainerProxy.dbg.json +1 -1
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +1 -1
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCOptimisticMinting.sol/TBTCOptimisticMinting.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
- package/contracts/bridge/WalletCoordinator.sol +110 -51
- package/export/artifacts/contracts/bridge/Bridge.sol/Bridge.json +22 -22
- package/export/artifacts/contracts/bridge/VendingMachine.sol/VendingMachine.json +6 -6
- package/export/artifacts/contracts/bridge/VendingMachineV2.sol/VendingMachineV2.json +6 -6
- package/export/artifacts/contracts/bridge/VendingMachineV3.sol/VendingMachineV3.json +6 -6
- package/export/artifacts/contracts/bridge/WalletCoordinator.sol/WalletCoordinator.json +7692 -5347
- package/export/artifacts/contracts/l2/L2TBTC.sol/L2TBTC.json +40 -40
- package/export/artifacts/contracts/l2/L2WormholeGateway.sol/L2WormholeGateway.json +47 -47
- package/export/artifacts/contracts/maintainer/MaintainerProxy.sol/MaintainerProxy.json +88 -88
- package/export/artifacts/contracts/relay/LightRelay.sol/LightRelay.json +57 -57
- package/export/artifacts/contracts/relay/LightRelayMaintainerProxy.sol/LightRelayMaintainerProxy.json +31 -31
- package/export/artifacts/contracts/test/BankStub.sol/BankStub.json +2 -2
- package/export/artifacts/contracts/test/BridgeStub.sol/BridgeStub.json +58 -58
- package/export/artifacts/contracts/test/GoerliLightRelay.sol/GoerliLightRelay.json +57 -57
- package/export/artifacts/contracts/test/HeartbeatStub.sol/HeartbeatStub.json +2 -2
- package/export/artifacts/contracts/test/LightRelayStub.sol/LightRelayStub.json +59 -59
- package/export/artifacts/contracts/test/ReceiveApprovalStub.sol/ReceiveApprovalStub.json +7 -7
- package/export/artifacts/contracts/test/SystemTestRelay.sol/SystemTestRelay.json +14 -14
- package/export/artifacts/contracts/test/TestERC20.sol/TestERC20.json +6 -6
- package/export/artifacts/contracts/test/TestERC721.sol/TestERC721.json +8 -8
- package/export/artifacts/contracts/test/TestEcdsaLib.sol/TestEcdsaLib.json +2 -2
- package/export/artifacts/contracts/test/WormholeBridgeStub.sol/WormholeBridgeStub.json +37 -37
- package/export/artifacts/contracts/token/TBTC.sol/TBTC.json +2 -2
- package/export/artifacts/contracts/vault/DonationVault.sol/DonationVault.json +11 -11
- package/export/artifacts/contracts/vault/TBTCVault.sol/TBTCVault.json +135 -135
- package/export/typechain/factories/WalletCoordinator__factory.js +116 -52
- package/package.json +1 -1
|
@@ -48,6 +48,8 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
48
48
|
enum WalletAction {
|
|
49
49
|
/// @dev The wallet does not perform any action.
|
|
50
50
|
Idle,
|
|
51
|
+
/// @dev The wallet is executing heartbeat.
|
|
52
|
+
Heartbeat,
|
|
51
53
|
/// @dev The wallet is handling a deposit sweep action.
|
|
52
54
|
DepositSweep,
|
|
53
55
|
/// @dev The wallet is handling a redemption action.
|
|
@@ -119,6 +121,21 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
119
121
|
/// @notice Handle to the Bridge contract.
|
|
120
122
|
Bridge public bridge;
|
|
121
123
|
|
|
124
|
+
/// @notice Determines the wallet heartbeat request validity time. In other
|
|
125
|
+
/// words, this is the worst-case time for a wallet heartbeat
|
|
126
|
+
/// during which the wallet is busy and canot take other actions.
|
|
127
|
+
/// This is also the duration of the time lock applied to the wallet
|
|
128
|
+
/// once a new heartbeat request is submitted.
|
|
129
|
+
///
|
|
130
|
+
/// For example, if a deposit sweep proposal was submitted at
|
|
131
|
+
/// 2 pm and heartbeatRequestValidity is 1 hour, the next request or
|
|
132
|
+
/// proposal (of any type) can be submitted after 3 pm.
|
|
133
|
+
uint32 public heartbeatRequestValidity;
|
|
134
|
+
|
|
135
|
+
/// @notice Gas that is meant to balance the heartbeat request overall cost.
|
|
136
|
+
/// Can be updated by the owner based on the current conditions.
|
|
137
|
+
uint32 public heartbeatRequestGasOffset;
|
|
138
|
+
|
|
122
139
|
/// @notice Determines the deposit sweep proposal validity time. In other
|
|
123
140
|
/// words, this is the worst-case time for a deposit sweep during
|
|
124
141
|
/// which the wallet is busy and cannot take another actions. This
|
|
@@ -165,7 +182,7 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
165
182
|
|
|
166
183
|
/// @notice Gas that is meant to balance the deposit sweep proposal
|
|
167
184
|
/// submission overall cost. Can be updated by the owner based on
|
|
168
|
-
/// the current
|
|
185
|
+
/// the current conditions.
|
|
169
186
|
uint32 public depositSweepProposalSubmissionGasOffset;
|
|
170
187
|
|
|
171
188
|
event CoordinatorAdded(address indexed coordinator);
|
|
@@ -174,17 +191,22 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
174
191
|
|
|
175
192
|
event WalletManuallyUnlocked(bytes20 indexed walletPubKeyHash);
|
|
176
193
|
|
|
177
|
-
event
|
|
178
|
-
uint32
|
|
194
|
+
event HeartbeatRequestParametersUpdated(
|
|
195
|
+
uint32 heartbeatRequestValidity,
|
|
196
|
+
uint32 heartbeatRequestGasOffset
|
|
179
197
|
);
|
|
180
198
|
|
|
181
|
-
event
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
199
|
+
event HeartbeatRequestSubmitted(
|
|
200
|
+
bytes20 walletPubKeyHash,
|
|
201
|
+
bytes message,
|
|
202
|
+
address indexed coordinator
|
|
203
|
+
);
|
|
186
204
|
|
|
187
|
-
event
|
|
205
|
+
event DepositSweepProposalParametersUpdated(
|
|
206
|
+
uint32 depositSweepProposalValidity,
|
|
207
|
+
uint32 depositMinAge,
|
|
208
|
+
uint32 depositRefundSafetyMargin,
|
|
209
|
+
uint16 depositSweepMaxSize,
|
|
188
210
|
uint32 depositSweepProposalSubmissionGasOffset
|
|
189
211
|
);
|
|
190
212
|
|
|
@@ -195,7 +217,6 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
195
217
|
|
|
196
218
|
modifier onlyCoordinator() {
|
|
197
219
|
require(isCoordinator[msg.sender], "Caller is not a coordinator");
|
|
198
|
-
|
|
199
220
|
_;
|
|
200
221
|
}
|
|
201
222
|
|
|
@@ -220,11 +241,14 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
220
241
|
// Pre-fetch addresses to save gas later.
|
|
221
242
|
(, , , reimbursementPool) = _bridge.contractReferences();
|
|
222
243
|
|
|
244
|
+
heartbeatRequestValidity = 1 hours;
|
|
245
|
+
heartbeatRequestGasOffset = 5_000;
|
|
246
|
+
|
|
223
247
|
depositSweepProposalValidity = 4 hours;
|
|
224
248
|
depositMinAge = 2 hours;
|
|
225
249
|
depositRefundSafetyMargin = 24 hours;
|
|
226
250
|
depositSweepMaxSize = 5;
|
|
227
|
-
depositSweepProposalSubmissionGasOffset =
|
|
251
|
+
depositSweepProposalSubmissionGasOffset = 5_000;
|
|
228
252
|
}
|
|
229
253
|
|
|
230
254
|
/// @notice Adds the given address to the set of coordinator addresses.
|
|
@@ -268,61 +292,96 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
268
292
|
emit WalletManuallyUnlocked(walletPubKeyHash);
|
|
269
293
|
}
|
|
270
294
|
|
|
271
|
-
/// @notice Updates
|
|
272
|
-
/// @param
|
|
295
|
+
/// @notice Updates parameters related to heartbeat request.
|
|
296
|
+
/// @param _heartbeatRequestValidity The new value of `heartbeatRequestValidity`.
|
|
297
|
+
/// @param _heartbeatRequestGasOffset The new value of `heartbeatRequestGasOffset`.
|
|
273
298
|
/// @dev Requirements:
|
|
274
299
|
/// - The caller must be the owner.
|
|
275
|
-
function
|
|
276
|
-
uint32
|
|
300
|
+
function updateHeartbeatRequestParameters(
|
|
301
|
+
uint32 _heartbeatRequestValidity,
|
|
302
|
+
uint32 _heartbeatRequestGasOffset
|
|
277
303
|
) external onlyOwner {
|
|
278
|
-
|
|
279
|
-
|
|
304
|
+
heartbeatRequestValidity = _heartbeatRequestValidity;
|
|
305
|
+
heartbeatRequestGasOffset = _heartbeatRequestGasOffset;
|
|
306
|
+
emit HeartbeatRequestParametersUpdated(
|
|
307
|
+
_heartbeatRequestValidity,
|
|
308
|
+
_heartbeatRequestGasOffset
|
|
309
|
+
);
|
|
280
310
|
}
|
|
281
311
|
|
|
282
|
-
/// @notice Updates
|
|
283
|
-
/// @param
|
|
312
|
+
/// @notice Updates parameters related to deposit sweep proposal.
|
|
313
|
+
/// @param _depositSweepProposalValidity The new value of `depositSweepProposalValidity`.
|
|
314
|
+
/// @param _depositMinAge The new value of `depositMinAge`.
|
|
315
|
+
/// @param _depositRefundSafetyMargin The new value of `depositRefundSafetyMargin`.
|
|
316
|
+
/// @param _depositSweepMaxSize The new value of `depositSweepMaxSize`.
|
|
284
317
|
/// @dev Requirements:
|
|
285
318
|
/// - The caller must be the owner.
|
|
286
|
-
function
|
|
319
|
+
function updateDepositSweepProposalParameters(
|
|
320
|
+
uint32 _depositSweepProposalValidity,
|
|
321
|
+
uint32 _depositMinAge,
|
|
322
|
+
uint32 _depositRefundSafetyMargin,
|
|
323
|
+
uint16 _depositSweepMaxSize,
|
|
324
|
+
uint32 _depositSweepProposalSubmissionGasOffset
|
|
325
|
+
) external onlyOwner {
|
|
326
|
+
depositSweepProposalValidity = _depositSweepProposalValidity;
|
|
287
327
|
depositMinAge = _depositMinAge;
|
|
288
|
-
emit DepositMinAgeUpdated(_depositMinAge);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/// @notice Updates the value of the depositRefundSafetyMargin parameter.
|
|
292
|
-
/// @param _depositRefundSafetyMargin New value.
|
|
293
|
-
/// @dev Requirements:
|
|
294
|
-
/// - The caller must be the owner.
|
|
295
|
-
function updateDepositRefundSafetyMargin(uint32 _depositRefundSafetyMargin)
|
|
296
|
-
external
|
|
297
|
-
onlyOwner
|
|
298
|
-
{
|
|
299
328
|
depositRefundSafetyMargin = _depositRefundSafetyMargin;
|
|
300
|
-
|
|
329
|
+
depositSweepMaxSize = _depositSweepMaxSize;
|
|
330
|
+
depositSweepProposalSubmissionGasOffset = _depositSweepProposalSubmissionGasOffset;
|
|
331
|
+
|
|
332
|
+
emit DepositSweepProposalParametersUpdated(
|
|
333
|
+
_depositSweepProposalValidity,
|
|
334
|
+
_depositMinAge,
|
|
335
|
+
_depositRefundSafetyMargin,
|
|
336
|
+
_depositSweepMaxSize,
|
|
337
|
+
_depositSweepProposalSubmissionGasOffset
|
|
338
|
+
);
|
|
301
339
|
}
|
|
302
340
|
|
|
303
|
-
/// @notice
|
|
304
|
-
///
|
|
341
|
+
/// @notice Submits a heartbeat request from the wallet. Locks the wallet
|
|
342
|
+
/// for a specific time, equal to the request validity period.
|
|
343
|
+
/// This function validates the proposed heartbeat messge to see
|
|
344
|
+
/// if it matches the heartbeat format expected by the Bridge.
|
|
345
|
+
/// @param walletPubKeyHash 20-byte public key hash of the wallet that is
|
|
346
|
+
/// supposed to execute the heartbeat.
|
|
347
|
+
/// @param message The proposed heartbeat message for the wallet to sign.
|
|
305
348
|
/// @dev Requirements:
|
|
306
|
-
/// - The caller
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
349
|
+
/// - The caller is a coordinator,
|
|
350
|
+
/// - The wallet is not time-locked,
|
|
351
|
+
/// - The message to sign is a valid heartbeat message.
|
|
352
|
+
function requestHeartbeat(bytes20 walletPubKeyHash, bytes calldata message)
|
|
353
|
+
public
|
|
354
|
+
onlyCoordinator
|
|
355
|
+
onlyAfterWalletLock(walletPubKeyHash)
|
|
310
356
|
{
|
|
311
|
-
|
|
312
|
-
|
|
357
|
+
require(
|
|
358
|
+
Heartbeat.isValidHeartbeatMessage(message),
|
|
359
|
+
"Not a valid heartbeat message"
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
walletLock[walletPubKeyHash] = WalletLock(
|
|
363
|
+
/* solhint-disable-next-line not-rely-on-time */
|
|
364
|
+
uint32(block.timestamp) + heartbeatRequestValidity,
|
|
365
|
+
WalletAction.Heartbeat
|
|
366
|
+
);
|
|
367
|
+
|
|
368
|
+
emit HeartbeatRequestSubmitted(walletPubKeyHash, message, msg.sender);
|
|
313
369
|
}
|
|
314
370
|
|
|
315
|
-
/// @notice
|
|
316
|
-
///
|
|
317
|
-
/// @
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
371
|
+
/// @notice Wraps `requestHeartbeat` call and reimburses the caller's
|
|
372
|
+
/// transaction cost.
|
|
373
|
+
/// @dev See `requestHeartbeat` function documentation.
|
|
374
|
+
function requestHeartbeatWithReimbursement(
|
|
375
|
+
bytes20 walletPubKeyHash,
|
|
376
|
+
bytes calldata message
|
|
377
|
+
) external {
|
|
378
|
+
uint256 gasStart = gasleft();
|
|
379
|
+
|
|
380
|
+
requestHeartbeat(walletPubKeyHash, message);
|
|
381
|
+
|
|
382
|
+
reimbursementPool.refund(
|
|
383
|
+
(gasStart - gasleft()) + heartbeatRequestGasOffset,
|
|
384
|
+
msg.sender
|
|
326
385
|
);
|
|
327
386
|
}
|
|
328
387
|
|