@keep-network/tbtc-v2 1.3.0-dev.5 → 1.3.0-dev.6
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 +6 -6
- package/artifacts/BeaconDkgValidator.json +8 -8
- package/artifacts/BeaconInactivity.json +8 -8
- 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 +6 -6
- package/artifacts/EcdsaInactivity.json +8 -8
- package/artifacts/EcdsaSortitionPool.json +4 -4
- 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 +109 -109
- package/artifacts/RandomBeaconChaosnet.json +4 -4
- package/artifacts/RandomBeaconGovernance.json +59 -59
- package/artifacts/Redemption.json +2 -2
- package/artifacts/ReimbursementPool.json +13 -13
- 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 +45 -92
- package/artifacts/WalletRegistry.json +5 -5
- package/artifacts/WalletRegistryGovernance.json +50 -50
- package/artifacts/Wallets.json +2 -2
- package/artifacts/solcInputs/{08bd3c90d7f376263925b4f52b0adff9.json → 7da6b4ef582799bac2eaf0403f4eac81.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 +34 -81
- 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 +31 -84
- 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 +7299 -9140
- 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 +33 -80
- package/package.json +3 -3
|
@@ -17,7 +17,6 @@ pragma solidity 0.8.17;
|
|
|
17
17
|
|
|
18
18
|
import {BTCUtils} from "@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol";
|
|
19
19
|
import {BytesLib} from "@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol";
|
|
20
|
-
import {IWalletRegistry as EcdsaWalletRegistry} from "@keep-network/ecdsa/contracts/api/IWalletRegistry.sol";
|
|
21
20
|
import "@keep-network/random-beacon/contracts/Reimbursable.sol";
|
|
22
21
|
import "@keep-network/random-beacon/contracts/ReimbursementPool.sol";
|
|
23
22
|
|
|
@@ -70,13 +69,6 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
70
69
|
WalletAction cause;
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
/// @notice Helper structure carrying data necessary to validate the wallet
|
|
74
|
-
/// membership of the caller.
|
|
75
|
-
struct WalletMemberContext {
|
|
76
|
-
uint32[] walletMembersIDs;
|
|
77
|
-
uint256 walletMemberIndex;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
72
|
/// @notice Helper structure representing a deposit sweep proposal.
|
|
81
73
|
struct DepositSweepProposal {
|
|
82
74
|
// 20-byte public key hash of the target wallet.
|
|
@@ -116,8 +108,9 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
116
108
|
bytes4 refundLocktime;
|
|
117
109
|
}
|
|
118
110
|
|
|
119
|
-
/// @notice Mapping that holds addresses allowed to submit proposals
|
|
120
|
-
|
|
111
|
+
/// @notice Mapping that holds addresses allowed to submit proposals and
|
|
112
|
+
/// request heartbeats.
|
|
113
|
+
mapping(address => bool) public isCoordinator;
|
|
121
114
|
|
|
122
115
|
/// @notice Mapping that holds wallet time locks. The key is a 20-byte
|
|
123
116
|
/// wallet public key hash.
|
|
@@ -126,9 +119,6 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
126
119
|
/// @notice Handle to the Bridge contract.
|
|
127
120
|
Bridge public bridge;
|
|
128
121
|
|
|
129
|
-
/// @notice Handle to the WalletRegistry contract.
|
|
130
|
-
EcdsaWalletRegistry public walletRegistry;
|
|
131
|
-
|
|
132
122
|
/// @notice Determines the deposit sweep proposal validity time. In other
|
|
133
123
|
/// words, this is the worst-case time for a deposit sweep during
|
|
134
124
|
/// which the wallet is busy and cannot take another actions. This
|
|
@@ -178,9 +168,9 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
178
168
|
/// the current market conditions.
|
|
179
169
|
uint32 public depositSweepProposalSubmissionGasOffset;
|
|
180
170
|
|
|
181
|
-
event
|
|
171
|
+
event CoordinatorAdded(address indexed coordinator);
|
|
182
172
|
|
|
183
|
-
event
|
|
173
|
+
event CoordinatorRemoved(address indexed coordinator);
|
|
184
174
|
|
|
185
175
|
event WalletManuallyUnlocked(bytes20 indexed walletPubKeyHash);
|
|
186
176
|
|
|
@@ -200,35 +190,11 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
200
190
|
|
|
201
191
|
event DepositSweepProposalSubmitted(
|
|
202
192
|
DepositSweepProposal proposal,
|
|
203
|
-
address indexed
|
|
193
|
+
address indexed coordinator
|
|
204
194
|
);
|
|
205
195
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
modifier onlyProposalSubmitterOrWalletMember(
|
|
209
|
-
bytes20 walletPubKeyHash,
|
|
210
|
-
WalletMemberContext calldata walletMemberContext
|
|
211
|
-
) {
|
|
212
|
-
bool proposalSubmitter = isProposalSubmitter[msg.sender];
|
|
213
|
-
bool walletMember = false;
|
|
214
|
-
|
|
215
|
-
if (!proposalSubmitter) {
|
|
216
|
-
bytes32 ecdsaWalletID = bridge
|
|
217
|
-
.wallets(walletPubKeyHash)
|
|
218
|
-
.ecdsaWalletID;
|
|
219
|
-
|
|
220
|
-
walletMember = walletRegistry.isWalletMember(
|
|
221
|
-
ecdsaWalletID,
|
|
222
|
-
walletMemberContext.walletMembersIDs,
|
|
223
|
-
msg.sender,
|
|
224
|
-
walletMemberContext.walletMemberIndex
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
require(
|
|
229
|
-
proposalSubmitter || walletMember,
|
|
230
|
-
"Caller is neither a proposal submitter nor a wallet member"
|
|
231
|
-
);
|
|
196
|
+
modifier onlyCoordinator() {
|
|
197
|
+
require(isCoordinator[msg.sender], "Caller is not a coordinator");
|
|
232
198
|
|
|
233
199
|
_;
|
|
234
200
|
}
|
|
@@ -251,9 +217,8 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
251
217
|
__Ownable_init();
|
|
252
218
|
|
|
253
219
|
bridge = _bridge;
|
|
254
|
-
// Pre-fetch
|
|
255
|
-
|
|
256
|
-
(, , walletRegistry, reimbursementPool) = _bridge.contractReferences();
|
|
220
|
+
// Pre-fetch addresses to save gas later.
|
|
221
|
+
(, , , reimbursementPool) = _bridge.contractReferences();
|
|
257
222
|
|
|
258
223
|
depositSweepProposalValidity = 4 hours;
|
|
259
224
|
depositMinAge = 2 hours;
|
|
@@ -262,38 +227,32 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
262
227
|
depositSweepProposalSubmissionGasOffset = 25000;
|
|
263
228
|
}
|
|
264
229
|
|
|
265
|
-
/// @notice Adds the given address to the
|
|
266
|
-
/// @param
|
|
230
|
+
/// @notice Adds the given address to the set of coordinator addresses.
|
|
231
|
+
/// @param coordinator Address of the new coordinator.
|
|
267
232
|
/// @dev Requirements:
|
|
268
233
|
/// - The caller must be the owner,
|
|
269
|
-
/// - The `
|
|
270
|
-
function
|
|
271
|
-
external
|
|
272
|
-
onlyOwner
|
|
273
|
-
{
|
|
234
|
+
/// - The `coordinator` must not be an existing coordinator.
|
|
235
|
+
function addCoordinator(address coordinator) external onlyOwner {
|
|
274
236
|
require(
|
|
275
|
-
!
|
|
276
|
-
"This address is already a
|
|
237
|
+
!isCoordinator[coordinator],
|
|
238
|
+
"This address is already a coordinator"
|
|
277
239
|
);
|
|
278
|
-
|
|
279
|
-
emit
|
|
240
|
+
isCoordinator[coordinator] = true;
|
|
241
|
+
emit CoordinatorAdded(coordinator);
|
|
280
242
|
}
|
|
281
243
|
|
|
282
|
-
/// @notice Removes the given address from the
|
|
283
|
-
/// @param
|
|
244
|
+
/// @notice Removes the given address from the set of coordinator addresses.
|
|
245
|
+
/// @param coordinator Address of the existing coordinator.
|
|
284
246
|
/// @dev Requirements:
|
|
285
247
|
/// - The caller must be the owner,
|
|
286
|
-
/// - The `
|
|
287
|
-
function
|
|
288
|
-
external
|
|
289
|
-
onlyOwner
|
|
290
|
-
{
|
|
248
|
+
/// - The `coordinator` must be an existing coordinator.
|
|
249
|
+
function removeCoordinator(address coordinator) external onlyOwner {
|
|
291
250
|
require(
|
|
292
|
-
|
|
293
|
-
"This address is not a
|
|
251
|
+
isCoordinator[coordinator],
|
|
252
|
+
"This address is not a coordinator"
|
|
294
253
|
);
|
|
295
|
-
delete
|
|
296
|
-
emit
|
|
254
|
+
delete isCoordinator[coordinator];
|
|
255
|
+
emit CoordinatorRemoved(coordinator);
|
|
297
256
|
}
|
|
298
257
|
|
|
299
258
|
/// @notice Allows to unlock the given wallet before their time lock expires.
|
|
@@ -374,23 +333,12 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
374
333
|
/// off-chain members. Wallet members are supposed to validate
|
|
375
334
|
/// the proposal on their own, before taking any action.
|
|
376
335
|
/// @param proposal The deposit sweep proposal
|
|
377
|
-
/// @param walletMemberContext Optional parameter holding some data allowing
|
|
378
|
-
/// to confirm the wallet membership of the caller. This parameter is
|
|
379
|
-
/// relevant only when the caller is not a registered proposal
|
|
380
|
-
/// submitter but claims to be a member of the target wallet.
|
|
381
336
|
/// @dev Requirements:
|
|
382
|
-
/// - The caller is
|
|
383
|
-
/// target wallet,
|
|
337
|
+
/// - The caller is a coordinator,
|
|
384
338
|
/// - The wallet is not time-locked.
|
|
385
|
-
function submitDepositSweepProposal(
|
|
386
|
-
DepositSweepProposal calldata proposal,
|
|
387
|
-
WalletMemberContext calldata walletMemberContext
|
|
388
|
-
)
|
|
339
|
+
function submitDepositSweepProposal(DepositSweepProposal calldata proposal)
|
|
389
340
|
public
|
|
390
|
-
|
|
391
|
-
proposal.walletPubKeyHash,
|
|
392
|
-
walletMemberContext
|
|
393
|
-
)
|
|
341
|
+
onlyCoordinator
|
|
394
342
|
onlyAfterWalletLock(proposal.walletPubKeyHash)
|
|
395
343
|
{
|
|
396
344
|
walletLock[proposal.walletPubKeyHash] = WalletLock(
|
|
@@ -406,12 +354,11 @@ contract WalletCoordinator is OwnableUpgradeable, Reimbursable {
|
|
|
406
354
|
/// caller's transaction cost.
|
|
407
355
|
/// @dev See `submitDepositSweepProposal` function documentation.
|
|
408
356
|
function submitDepositSweepProposalWithReimbursement(
|
|
409
|
-
DepositSweepProposal calldata proposal
|
|
410
|
-
WalletMemberContext calldata walletMemberContext
|
|
357
|
+
DepositSweepProposal calldata proposal
|
|
411
358
|
) external {
|
|
412
359
|
uint256 gasStart = gasleft();
|
|
413
360
|
|
|
414
|
-
submitDepositSweepProposal(proposal
|
|
361
|
+
submitDepositSweepProposal(proposal);
|
|
415
362
|
|
|
416
363
|
reimbursementPool.refund(
|
|
417
364
|
(gasStart - gasleft()) + depositSweepProposalSubmissionGasOffset,
|