@keep-network/tbtc-v2 0.1.1-dev.74 → 0.1.1-dev.77

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.
Files changed (76) hide show
  1. package/artifacts/Bank.json +17 -17
  2. package/artifacts/Bridge.json +91 -3
  3. package/artifacts/Deposit.json +10 -10
  4. package/artifacts/DepositSweep.json +10 -10
  5. package/artifacts/EcdsaDkgValidator.json +16 -17
  6. package/artifacts/EcdsaInactivity.json +6 -6
  7. package/artifacts/EcdsaSortitionPool.json +1004 -0
  8. package/artifacts/Fraud.json +10 -10
  9. package/artifacts/KeepRegistry.json +1 -1
  10. package/artifacts/KeepStake.json +2 -2
  11. package/artifacts/KeepToken.json +2 -2
  12. package/artifacts/KeepTokenStaking.json +1 -1
  13. package/artifacts/MovingFunds.json +13 -13
  14. package/artifacts/NuCypherStakingEscrow.json +1 -1
  15. package/artifacts/NuCypherToken.json +2 -2
  16. package/artifacts/RandomBeaconStub.json +6 -6
  17. package/artifacts/Redemption.json +12 -12
  18. package/artifacts/ReimbursementPool.json +24 -24
  19. package/artifacts/Relay.json +12 -12
  20. package/artifacts/T.json +2 -2
  21. package/artifacts/TBTC.json +19 -19
  22. package/artifacts/TBTCToken.json +19 -19
  23. package/artifacts/TokenStaking.json +1 -1
  24. package/artifacts/TokenholderGovernor.json +9 -9
  25. package/artifacts/TokenholderTimelock.json +8 -8
  26. package/artifacts/VendingMachine.json +24 -24
  27. package/artifacts/VendingMachineKeep.json +1 -1
  28. package/artifacts/VendingMachineNuCypher.json +1 -1
  29. package/artifacts/WalletRegistry.json +893 -1167
  30. package/artifacts/WalletRegistryGovernance.json +2754 -0
  31. package/artifacts/Wallets.json +10 -10
  32. package/artifacts/solcInputs/{3d39c8183330efd748c005f3c281bf2c.json → 490ffccc38e413544104a916bd6aa53c.json} +106 -70
  33. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
  34. package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
  35. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
  36. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +2 -2
  37. package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
  38. package/build/contracts/bridge/Bridge.sol/Bridge.json +58 -42
  39. package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
  40. package/build/contracts/bridge/BridgeState.sol/BridgeState.json +8 -2
  41. package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
  42. package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
  43. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
  44. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +2 -2
  45. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
  46. package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
  47. package/build/contracts/bridge/Fraud.sol/Fraud.json +2 -2
  48. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
  49. package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
  50. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
  51. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +2 -2
  52. package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
  53. package/build/contracts/bridge/Redemption.sol/OutboundTx.json +2 -2
  54. package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
  55. package/build/contracts/bridge/Redemption.sol/Redemption.json +2 -2
  56. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
  57. package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
  58. package/build/contracts/bridge/Wallets.sol/Wallets.json +2 -2
  59. package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
  60. package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +1 -1
  61. package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
  62. package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
  63. package/contracts/bridge/Bridge.sol +30 -6
  64. package/contracts/bridge/BridgeState.sol +33 -7
  65. package/contracts/bridge/MovingFunds.sol +10 -1
  66. package/contracts/hardhat-dependency-compiler/@keep-network/ecdsa/contracts/WalletRegistry.sol +3 -0
  67. package/deploy/05_deploy_bridge.ts +5 -1
  68. package/deploy/09_transfer_proxy_admin_ownership.ts +15 -8
  69. package/export.json +2539 -3070
  70. package/package.json +3 -3
  71. package/artifacts/DefaultProxyAdmin.json +0 -259
  72. package/artifacts/SortitionPool.json +0 -1005
  73. package/artifacts/WalletRegistry_Implementation.json +0 -2824
  74. package/artifacts/WalletRegistry_Proxy.json +0 -259
  75. package/artifacts/solcInputs/1635d55d57a0a2552952c0d22586ed23.json +0 -56
  76. package/deploy/00_resolve_wallet_registry.ts +0 -83
@@ -91,6 +91,14 @@ library BridgeState {
91
91
  // than `redemptionDustThreshold` in order to prevent redemption requests
92
92
  // with values lower or equal to `movingFundsDustThreshold`.
93
93
  uint64 movingFundsDustThreshold;
94
+ // Time after which the moving funds timeout can be reset in case the
95
+ // target wallet commitment cannot be submitted due to a lack of live
96
+ // wallets in the system. It is counted from the moment when the wallet
97
+ // was requested to move their funds and switched to the MovingFunds
98
+ // state or from the moment the timeout was reset the last time.
99
+ // Value in seconds. This value should be lower than the value
100
+ // of the `movingFundsTimeout`.
101
+ uint32 movingFundsTimeoutResetDelay;
94
102
  // Time after which the moving funds process can be reported as
95
103
  // timed out. It is counted from the moment when the wallet
96
104
  // was requested to move their funds and switched to the MovingFunds
@@ -283,6 +291,7 @@ library BridgeState {
283
291
  event MovingFundsParametersUpdated(
284
292
  uint64 movingFundsTxMaxTotalFee,
285
293
  uint64 movingFundsDustThreshold,
294
+ uint32 movingFundsTimeoutResetDelay,
286
295
  uint32 movingFundsTimeout,
287
296
  uint96 movingFundsTimeoutSlashingAmount,
288
297
  uint256 movingFundsTimeoutNotifierRewardMultiplier,
@@ -471,10 +480,17 @@ library BridgeState {
471
480
  /// funds transaction.
472
481
  /// @param _movingFundsDustThreshold New value of the moving funds dust
473
482
  /// threshold. It is the minimal satoshi amount that makes sense to
474
- // be transferred during the moving funds process. Moving funds
475
- // wallets having their BTC balance below that value can begin
476
- // closing immediately as transferring such a low value may not be
477
- // possible due to BTC network fees.
483
+ /// be transferred during the moving funds process. Moving funds
484
+ /// wallets having their BTC balance below that value can begin
485
+ /// closing immediately as transferring such a low value may not be
486
+ /// possible due to BTC network fees.
487
+ /// @param _movingFundsTimeoutResetDelay New value of the moving funds
488
+ /// timeout reset delay in seconds. It is the time after which the
489
+ /// moving funds timeout can be reset in case the target wallet
490
+ /// commitment cannot be submitted due to a lack of live wallets
491
+ /// in the system. It is counted from the moment when the wallet
492
+ /// was requested to move their funds and switched to the MovingFunds
493
+ /// state or from the moment the timeout was reset the last time.
478
494
  /// @param _movingFundsTimeout New value of the moving funds timeout in
479
495
  /// seconds. It is the time after which the moving funds process can
480
496
  /// be reported as timed out. It is counted from the moment when the
@@ -510,7 +526,9 @@ library BridgeState {
510
526
  /// - Moving funds transaction max total fee must be greater than zero,
511
527
  /// - Moving funds dust threshold must be greater than zero and lower
512
528
  /// than the redemption dust threshold,
513
- /// - Moving funds timeout must be greater than zero,
529
+ /// - Moving funds timeout reset delay must be greater than zero,
530
+ /// - Moving funds timeout must be greater than the moving funds
531
+ /// timeout reset delay,
514
532
  /// - Moving funds timeout notifier reward multiplier must be in the
515
533
  /// range [0, 100],
516
534
  /// - Moved funds sweep transaction max total fee must be greater than zero,
@@ -521,6 +539,7 @@ library BridgeState {
521
539
  Storage storage self,
522
540
  uint64 _movingFundsTxMaxTotalFee,
523
541
  uint64 _movingFundsDustThreshold,
542
+ uint32 _movingFundsTimeoutResetDelay,
524
543
  uint32 _movingFundsTimeout,
525
544
  uint96 _movingFundsTimeoutSlashingAmount,
526
545
  uint256 _movingFundsTimeoutNotifierRewardMultiplier,
@@ -541,8 +560,13 @@ library BridgeState {
541
560
  );
542
561
 
543
562
  require(
544
- _movingFundsTimeout > 0,
545
- "Moving funds timeout must be greater than zero"
563
+ _movingFundsTimeoutResetDelay > 0,
564
+ "Moving funds timeout reset delay must be greater than zero"
565
+ );
566
+
567
+ require(
568
+ _movingFundsTimeout > _movingFundsTimeoutResetDelay,
569
+ "Moving funds timeout must be greater than its reset delay"
546
570
  );
547
571
 
548
572
  require(
@@ -567,6 +591,7 @@ library BridgeState {
567
591
 
568
592
  self.movingFundsTxMaxTotalFee = _movingFundsTxMaxTotalFee;
569
593
  self.movingFundsDustThreshold = _movingFundsDustThreshold;
594
+ self.movingFundsTimeoutResetDelay = _movingFundsTimeoutResetDelay;
570
595
  self.movingFundsTimeout = _movingFundsTimeout;
571
596
  self
572
597
  .movingFundsTimeoutSlashingAmount = _movingFundsTimeoutSlashingAmount;
@@ -582,6 +607,7 @@ library BridgeState {
582
607
  emit MovingFundsParametersUpdated(
583
608
  _movingFundsTxMaxTotalFee,
584
609
  _movingFundsDustThreshold,
610
+ _movingFundsTimeoutResetDelay,
585
611
  _movingFundsTimeout,
586
612
  _movingFundsTimeoutSlashingAmount,
587
613
  _movingFundsTimeoutNotifierRewardMultiplier,
@@ -268,7 +268,8 @@ library MovingFunds {
268
268
  /// - The wallet must be in the MovingFunds state,
269
269
  /// - The target wallets commitment must not be already submitted for
270
270
  /// the given moving funds wallet,
271
- /// - Live wallets count must be zero.
271
+ /// - Live wallets count must be zero,
272
+ /// - The moving funds timeout reset delay must be elapsed.
272
273
  function resetMovingFundsTimeout(
273
274
  BridgeState.Storage storage self,
274
275
  bytes20 walletPubKeyHash
@@ -292,6 +293,14 @@ library MovingFunds {
292
293
 
293
294
  require(self.liveWalletsCount == 0, "Live wallets count must be zero");
294
295
 
296
+ require(
297
+ /* solhint-disable-next-line not-rely-on-time */
298
+ block.timestamp >
299
+ wallet.movingFundsRequestedAt +
300
+ self.movingFundsTimeoutResetDelay,
301
+ "Moving funds timeout cannot be reset yet"
302
+ );
303
+
295
304
  /* solhint-disable-next-line not-rely-on-time */
296
305
  wallet.movingFundsRequestedAt = uint32(block.timestamp);
297
306
 
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: UNLICENSED
2
+ pragma solidity >0.0.0;
3
+ import '@keep-network/ecdsa/contracts/WalletRegistry.sol';
@@ -24,7 +24,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
24
24
  log: true,
25
25
  })
26
26
  const Redemption = await deploy("Redemption", { from: deployer, log: true })
27
- const Wallets = await deploy("Wallets", { from: deployer, log: true })
27
+ const Wallets = await deploy("Wallets", {
28
+ contract: "contracts/bridge/Wallets.sol:Wallets",
29
+ from: deployer,
30
+ log: true,
31
+ })
28
32
  const Fraud = await deploy("Fraud", { from: deployer, log: true })
29
33
  const MovingFunds = await deploy("MovingFunds", {
30
34
  from: deployer,
@@ -2,19 +2,26 @@ import type { HardhatRuntimeEnvironment } from "hardhat/types"
2
2
  import type { DeployFunction } from "hardhat-deploy/types"
3
3
 
4
4
  const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
5
- const { ethers, getNamedAccounts, upgrades, deployments } = hre
6
- const { esdm } = await getNamedAccounts()
7
- const { deployer } = await ethers.getNamedSigners()
5
+ const { helpers, upgrades, deployments } = hre
6
+ const { esdm, deployer } = await helpers.signers.getNamedSigners()
7
+ const { log } = deployments
8
8
 
9
9
  // TODO: Once a DAO is established we want to switch to ProxyAdminWithDeputy and
10
10
  // use the DAO as the proxy admin owner and ESDM as the deputy. Until then we
11
- // use governance as the owner of ProxyAdmin contract.
12
- const newProxyAdminOwner = esdm
13
-
14
- deployments.log(`transferring ProxyAdmin ownership to ${newProxyAdminOwner}`)
11
+ // use ESDM as the owner of ProxyAdmin contract.
12
+ const newProxyAdminOwner = esdm.address
15
13
 
16
14
  const proxyAdmin = await upgrades.admin.getInstance()
17
- await proxyAdmin.connect(deployer).transferOwnership(newProxyAdminOwner)
15
+
16
+ const currentOwner = await proxyAdmin.owner()
17
+
18
+ // The `@openzeppelin/hardhat-upgrades` plugin deploys a single ProxyAdmin
19
+ // per network. We don't want to transfer the ownership if the owner is already
20
+ // set to the desired address.
21
+ if (!helpers.address.equal(currentOwner, newProxyAdminOwner)) {
22
+ log(`transferring ownership of ProxyAdmin to ${newProxyAdminOwner}`)
23
+ await proxyAdmin.connect(deployer).transferOwnership(newProxyAdminOwner)
24
+ }
18
25
  }
19
26
 
20
27
  export default func