@keep-network/tbtc-v2 0.1.1-dev.50 → 0.1.1-dev.53
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/Bank.json +6 -6
- package/artifacts/Bridge.json +235 -141
- package/artifacts/Deposit.json +9 -9
- package/artifacts/EcdsaDkgValidator.json +1 -1
- package/artifacts/EcdsaInactivity.json +1 -1
- package/artifacts/Fraud.json +13 -12
- 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/MovingFunds.json +9 -9
- package/artifacts/NuCypherStakingEscrow.json +1 -1
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeaconStub.json +1 -1
- package/artifacts/Redemption.json +14 -13
- package/artifacts/ReimbursementPool.json +2 -2
- package/artifacts/Relay.json +11 -11
- package/artifacts/SortitionPool.json +2 -2
- package/artifacts/Sweep.json +7 -7
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +6 -6
- package/artifacts/TBTCToken.json +6 -6
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +13 -13
- package/artifacts/VendingMachineKeep.json +1 -1
- package/artifacts/VendingMachineNuCypher.json +1 -1
- package/artifacts/WalletRegistry.json +2 -2
- package/artifacts/WalletRegistryGovernance.json +2 -2
- package/artifacts/Wallets.json +9 -9
- package/artifacts/solcInputs/{b0c3ed0992bd570aaaee717425c37538.json → fa22a04615b4037761340d27e55c86ee.json} +5 -5
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +2 -2
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
- package/build/contracts/bridge/Bridge.sol/Bridge.json +104 -46
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.json +24 -6
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
- package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
- 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/Fraud.sol/Fraud.json +2 -2
- 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/MovingFunds.sol/MovingFunds.json +2 -2
- package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/OutboundTx.json +2 -2
- package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/Redemption.json +2 -2
- package/build/contracts/bridge/Sweep.sol/Sweep.dbg.json +1 -1
- package/build/contracts/bridge/Sweep.sol/Sweep.json +2 -2
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
- package/build/contracts/bridge/Wallets.sol/Wallets.json +2 -2
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
- package/contracts/bridge/Bridge.sol +111 -43
- package/contracts/bridge/BridgeState.sol +72 -26
- package/contracts/bridge/Fraud.sol +21 -5
- package/contracts/bridge/Redemption.sol +33 -11
- package/contracts/bridge/Wallets.sol +9 -12
- package/export.json +70 -12
- package/package.json +1 -1
|
@@ -765,29 +765,41 @@ library Redemption {
|
|
|
765
765
|
/// with the given wallet, that has timed out. The redemption
|
|
766
766
|
/// request is identified by the key built as
|
|
767
767
|
/// `keccak256(walletPubKeyHash | redeemerOutputScript)`.
|
|
768
|
-
/// The results of calling this function:
|
|
769
|
-
/// value for the wallet will be decreased
|
|
770
|
-
///
|
|
771
|
-
///
|
|
772
|
-
///
|
|
773
|
-
///
|
|
774
|
-
///
|
|
775
|
-
///
|
|
776
|
-
///
|
|
777
|
-
///
|
|
778
|
-
///
|
|
768
|
+
/// The results of calling this function:
|
|
769
|
+
/// - the pending redemptions value for the wallet will be decreased
|
|
770
|
+
/// by the requested amount (minus treasury fee),
|
|
771
|
+
/// - the tokens taken from the redeemer on redemption request will
|
|
772
|
+
/// be returned to the redeemer,
|
|
773
|
+
/// - the request will be moved from pending redemptions to
|
|
774
|
+
/// timed-out redemptions.
|
|
775
|
+
/// - if the state of the wallet is `Live` or `MovingFunds`, the
|
|
776
|
+
/// wallet operators will be slashed and the notifier will be
|
|
777
|
+
/// rewarded
|
|
778
|
+
/// - if the state of wallet is `Live`, the wallet will be closed or
|
|
779
|
+
/// marked as `MovingFunds` (depending on the presence or absence
|
|
780
|
+
/// of the wallet's main UTXO) and the wallet will no longer be
|
|
781
|
+
/// marked as the active wallet (if it was marked as such).
|
|
779
782
|
/// @param walletPubKeyHash 20-byte public key hash of the wallet
|
|
783
|
+
/// @param walletMembersIDs Identifiers of the wallet signing group members
|
|
780
784
|
/// @param redeemerOutputScript The redeemer's length-prefixed output
|
|
781
785
|
/// script (P2PKH, P2WPKH, P2SH or P2WSH)
|
|
782
786
|
/// @dev Requirements:
|
|
787
|
+
/// - The wallet must be in the Live or MovingFunds or Terminated state
|
|
783
788
|
/// - The redemption request identified by `walletPubKeyHash` and
|
|
784
789
|
/// `redeemerOutputScript` must exist
|
|
790
|
+
/// - The expression `keccak256(abi.encode(walletMembersIDs))` must
|
|
791
|
+
/// be exactly the same as the hash stored under `membersIdsHash`
|
|
792
|
+
/// for the given `walletID`. Those IDs are not directly stored
|
|
793
|
+
/// in the contract for gas efficiency purposes but they can be
|
|
794
|
+
/// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
|
|
795
|
+
/// events.
|
|
785
796
|
/// - The amount of time defined by `redemptionTimeout` must have
|
|
786
797
|
/// passed since the redemption was requested (the request must be
|
|
787
798
|
/// timed-out).
|
|
788
799
|
function notifyRedemptionTimeout(
|
|
789
800
|
BridgeState.Storage storage self,
|
|
790
801
|
bytes20 walletPubKeyHash,
|
|
802
|
+
uint32[] calldata walletMembersIDs,
|
|
791
803
|
bytes calldata redeemerOutputScript
|
|
792
804
|
) external {
|
|
793
805
|
uint256 redemptionKey = uint256(
|
|
@@ -836,7 +848,17 @@ library Redemption {
|
|
|
836
848
|
) {
|
|
837
849
|
// Propagate timeout consequences to the wallet
|
|
838
850
|
self.notifyWalletTimedOutRedemption(walletPubKeyHash);
|
|
851
|
+
|
|
852
|
+
// Slash the wallet operators and reward the notifier
|
|
853
|
+
self.ecdsaWalletRegistry.seize(
|
|
854
|
+
self.redemptionTimeoutSlashingAmount,
|
|
855
|
+
self.redemptionTimeoutNotifierRewardMultiplier,
|
|
856
|
+
msg.sender,
|
|
857
|
+
wallet.ecdsaWalletID,
|
|
858
|
+
walletMembersIDs
|
|
859
|
+
);
|
|
839
860
|
}
|
|
861
|
+
|
|
840
862
|
// slither-disable-next-line reentrancy-events
|
|
841
863
|
emit RedemptionTimedOut(walletPubKeyHash, redeemerOutputScript);
|
|
842
864
|
|
|
@@ -163,8 +163,9 @@ library Wallets {
|
|
|
163
163
|
|
|
164
164
|
require(
|
|
165
165
|
(activeWalletOldEnough &&
|
|
166
|
-
activeWalletBtcBalance >=
|
|
167
|
-
|
|
166
|
+
activeWalletBtcBalance >=
|
|
167
|
+
self.walletCreationMinBtcBalance) ||
|
|
168
|
+
activeWalletBtcBalance >= self.walletCreationMaxBtcBalance,
|
|
168
169
|
"Wallet creation conditions are not met"
|
|
169
170
|
);
|
|
170
171
|
}
|
|
@@ -287,12 +288,11 @@ library Wallets {
|
|
|
287
288
|
moveFunds(self, walletPubKeyHash);
|
|
288
289
|
}
|
|
289
290
|
|
|
290
|
-
/// @notice Handles a notification about a wallet redemption timeout
|
|
291
|
-
///
|
|
292
|
-
///
|
|
293
|
-
///
|
|
294
|
-
///
|
|
295
|
-
/// wallet to move their funds.
|
|
291
|
+
/// @notice Handles a notification about a wallet redemption timeout.
|
|
292
|
+
/// Triggers the wallet moving funds process only if the wallet is
|
|
293
|
+
/// still in the Live state. That means multiple action timeouts can
|
|
294
|
+
/// be reported for the same wallet but only the first report
|
|
295
|
+
/// requests the wallet to move their funds.
|
|
296
296
|
/// @param walletPubKeyHash 20-byte public key hash of the wallet
|
|
297
297
|
/// @dev Requirements:
|
|
298
298
|
/// - The wallet must be in the `Live` or `MovingFunds` state
|
|
@@ -313,9 +313,6 @@ library Wallets {
|
|
|
313
313
|
if (walletState == WalletState.Live) {
|
|
314
314
|
moveFunds(self, walletPubKeyHash);
|
|
315
315
|
}
|
|
316
|
-
|
|
317
|
-
// TODO: Perform slashing of wallet operators and transfer some of the
|
|
318
|
-
// slashed tokens to the caller of this function.
|
|
319
316
|
}
|
|
320
317
|
|
|
321
318
|
/// @notice Notifies that the wallet is either old enough or has too few
|
|
@@ -356,7 +353,7 @@ library Wallets {
|
|
|
356
353
|
require(
|
|
357
354
|
walletOldEnough ||
|
|
358
355
|
getWalletBtcBalance(self, walletPubKeyHash, walletMainUtxo) <
|
|
359
|
-
self.
|
|
356
|
+
self.walletClosureMinBtcBalance,
|
|
360
357
|
"Wallet needs to be old enough or have too few satoshis"
|
|
361
358
|
);
|
|
362
359
|
|
package/export.json
CHANGED
|
@@ -14209,9 +14209,9 @@
|
|
|
14209
14209
|
"inputs": [
|
|
14210
14210
|
{
|
|
14211
14211
|
"indexed": false,
|
|
14212
|
-
"internalType": "
|
|
14212
|
+
"internalType": "uint96",
|
|
14213
14213
|
"name": "fraudSlashingAmount",
|
|
14214
|
-
"type": "
|
|
14214
|
+
"type": "uint96"
|
|
14215
14215
|
},
|
|
14216
14216
|
{
|
|
14217
14217
|
"indexed": false,
|
|
@@ -14400,6 +14400,18 @@
|
|
|
14400
14400
|
"internalType": "uint256",
|
|
14401
14401
|
"name": "redemptionTimeout",
|
|
14402
14402
|
"type": "uint256"
|
|
14403
|
+
},
|
|
14404
|
+
{
|
|
14405
|
+
"indexed": false,
|
|
14406
|
+
"internalType": "uint96",
|
|
14407
|
+
"name": "redemptionTimeoutSlashingAmount",
|
|
14408
|
+
"type": "uint96"
|
|
14409
|
+
},
|
|
14410
|
+
{
|
|
14411
|
+
"indexed": false,
|
|
14412
|
+
"internalType": "uint256",
|
|
14413
|
+
"name": "redemptionTimeoutNotifierRewardMultiplier",
|
|
14414
|
+
"type": "uint256"
|
|
14403
14415
|
}
|
|
14404
14416
|
],
|
|
14405
14417
|
"name": "RedemptionParametersUpdated",
|
|
@@ -14574,13 +14586,19 @@
|
|
|
14574
14586
|
{
|
|
14575
14587
|
"indexed": false,
|
|
14576
14588
|
"internalType": "uint64",
|
|
14577
|
-
"name": "
|
|
14589
|
+
"name": "walletCreationMinBtcBalance",
|
|
14578
14590
|
"type": "uint64"
|
|
14579
14591
|
},
|
|
14580
14592
|
{
|
|
14581
14593
|
"indexed": false,
|
|
14582
14594
|
"internalType": "uint64",
|
|
14583
|
-
"name": "
|
|
14595
|
+
"name": "walletCreationMaxBtcBalance",
|
|
14596
|
+
"type": "uint64"
|
|
14597
|
+
},
|
|
14598
|
+
{
|
|
14599
|
+
"indexed": false,
|
|
14600
|
+
"internalType": "uint64",
|
|
14601
|
+
"name": "walletClosureMinBtcBalance",
|
|
14584
14602
|
"type": "uint64"
|
|
14585
14603
|
},
|
|
14586
14604
|
{
|
|
@@ -14849,9 +14867,9 @@
|
|
|
14849
14867
|
"name": "fraudParameters",
|
|
14850
14868
|
"outputs": [
|
|
14851
14869
|
{
|
|
14852
|
-
"internalType": "
|
|
14870
|
+
"internalType": "uint96",
|
|
14853
14871
|
"name": "fraudSlashingAmount",
|
|
14854
|
-
"type": "
|
|
14872
|
+
"type": "uint96"
|
|
14855
14873
|
},
|
|
14856
14874
|
{
|
|
14857
14875
|
"internalType": "uint256",
|
|
@@ -14982,6 +15000,11 @@
|
|
|
14982
15000
|
"name": "walletPublicKey",
|
|
14983
15001
|
"type": "bytes"
|
|
14984
15002
|
},
|
|
15003
|
+
{
|
|
15004
|
+
"internalType": "uint32[]",
|
|
15005
|
+
"name": "walletMembersIDs",
|
|
15006
|
+
"type": "uint32[]"
|
|
15007
|
+
},
|
|
14985
15008
|
{
|
|
14986
15009
|
"internalType": "bytes32",
|
|
14987
15010
|
"name": "sighash",
|
|
@@ -15048,6 +15071,11 @@
|
|
|
15048
15071
|
"name": "walletPubKeyHash",
|
|
15049
15072
|
"type": "bytes20"
|
|
15050
15073
|
},
|
|
15074
|
+
{
|
|
15075
|
+
"internalType": "uint32[]",
|
|
15076
|
+
"name": "walletMembersIDs",
|
|
15077
|
+
"type": "uint32[]"
|
|
15078
|
+
},
|
|
15051
15079
|
{
|
|
15052
15080
|
"internalType": "bytes",
|
|
15053
15081
|
"name": "redeemerOutputScript",
|
|
@@ -15141,6 +15169,16 @@
|
|
|
15141
15169
|
"internalType": "uint256",
|
|
15142
15170
|
"name": "redemptionTimeout",
|
|
15143
15171
|
"type": "uint256"
|
|
15172
|
+
},
|
|
15173
|
+
{
|
|
15174
|
+
"internalType": "uint96",
|
|
15175
|
+
"name": "redemptionTimeoutSlashingAmount",
|
|
15176
|
+
"type": "uint96"
|
|
15177
|
+
},
|
|
15178
|
+
{
|
|
15179
|
+
"internalType": "uint256",
|
|
15180
|
+
"name": "redemptionTimeoutNotifierRewardMultiplier",
|
|
15181
|
+
"type": "uint256"
|
|
15144
15182
|
}
|
|
15145
15183
|
],
|
|
15146
15184
|
"stateMutability": "view",
|
|
@@ -16029,9 +16067,9 @@
|
|
|
16029
16067
|
{
|
|
16030
16068
|
"inputs": [
|
|
16031
16069
|
{
|
|
16032
|
-
"internalType": "
|
|
16070
|
+
"internalType": "uint96",
|
|
16033
16071
|
"name": "fraudSlashingAmount",
|
|
16034
|
-
"type": "
|
|
16072
|
+
"type": "uint96"
|
|
16035
16073
|
},
|
|
16036
16074
|
{
|
|
16037
16075
|
"internalType": "uint256",
|
|
@@ -16098,6 +16136,16 @@
|
|
|
16098
16136
|
"internalType": "uint256",
|
|
16099
16137
|
"name": "redemptionTimeout",
|
|
16100
16138
|
"type": "uint256"
|
|
16139
|
+
},
|
|
16140
|
+
{
|
|
16141
|
+
"internalType": "uint96",
|
|
16142
|
+
"name": "redemptionTimeoutSlashingAmount",
|
|
16143
|
+
"type": "uint96"
|
|
16144
|
+
},
|
|
16145
|
+
{
|
|
16146
|
+
"internalType": "uint256",
|
|
16147
|
+
"name": "redemptionTimeoutNotifierRewardMultiplier",
|
|
16148
|
+
"type": "uint256"
|
|
16101
16149
|
}
|
|
16102
16150
|
],
|
|
16103
16151
|
"name": "updateRedemptionParameters",
|
|
@@ -16114,12 +16162,17 @@
|
|
|
16114
16162
|
},
|
|
16115
16163
|
{
|
|
16116
16164
|
"internalType": "uint64",
|
|
16117
|
-
"name": "
|
|
16165
|
+
"name": "walletCreationMinBtcBalance",
|
|
16118
16166
|
"type": "uint64"
|
|
16119
16167
|
},
|
|
16120
16168
|
{
|
|
16121
16169
|
"internalType": "uint64",
|
|
16122
|
-
"name": "
|
|
16170
|
+
"name": "walletCreationMaxBtcBalance",
|
|
16171
|
+
"type": "uint64"
|
|
16172
|
+
},
|
|
16173
|
+
{
|
|
16174
|
+
"internalType": "uint64",
|
|
16175
|
+
"name": "walletClosureMinBtcBalance",
|
|
16123
16176
|
"type": "uint64"
|
|
16124
16177
|
},
|
|
16125
16178
|
{
|
|
@@ -16154,12 +16207,17 @@
|
|
|
16154
16207
|
},
|
|
16155
16208
|
{
|
|
16156
16209
|
"internalType": "uint64",
|
|
16157
|
-
"name": "
|
|
16210
|
+
"name": "walletCreationMinBtcBalance",
|
|
16211
|
+
"type": "uint64"
|
|
16212
|
+
},
|
|
16213
|
+
{
|
|
16214
|
+
"internalType": "uint64",
|
|
16215
|
+
"name": "walletCreationMaxBtcBalance",
|
|
16158
16216
|
"type": "uint64"
|
|
16159
16217
|
},
|
|
16160
16218
|
{
|
|
16161
16219
|
"internalType": "uint64",
|
|
16162
|
-
"name": "
|
|
16220
|
+
"name": "walletClosureMinBtcBalance",
|
|
16163
16221
|
"type": "uint64"
|
|
16164
16222
|
},
|
|
16165
16223
|
{
|