@keep-network/tbtc-v2 0.1.1-dev.53 → 0.1.1-dev.56
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 +3 -3
- package/artifacts/Bridge.json +626 -254
- package/artifacts/Deposit.json +7 -7
- package/artifacts/DepositSweep.json +76 -0
- package/artifacts/EcdsaDkgValidator.json +1 -1
- package/artifacts/EcdsaInactivity.json +1 -1
- package/artifacts/Fraud.json +8 -8
- 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 +44 -13
- package/artifacts/NuCypherStakingEscrow.json +1 -1
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeaconStub.json +1 -1
- package/artifacts/Redemption.json +11 -11
- package/artifacts/ReimbursementPool.json +2 -2
- package/artifacts/Relay.json +9 -9
- package/artifacts/SortitionPool.json +2 -2
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +3 -3
- package/artifacts/TBTCToken.json +3 -3
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +10 -10
- 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 +7 -7
- package/artifacts/solcInputs/{fa22a04615b4037761340d27e55c86ee.json → 5dd2a7c685770548b7ea9ce25e179326.json} +11 -11
- 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 +328 -128
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.json +29 -11
- 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/DepositSweep.sol/DepositSweep.dbg.json +4 -0
- package/build/contracts/bridge/{Sweep.sol/Sweep.json → DepositSweep.sol/DepositSweep.json} +4 -4
- 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 +21 -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/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/BitcoinTx.sol +69 -0
- package/contracts/bridge/Bridge.sol +176 -55
- package/contracts/bridge/BridgeState.sol +107 -44
- package/contracts/bridge/{Sweep.sol → DepositSweep.sol} +30 -18
- package/contracts/bridge/Fraud.sol +1 -1
- package/contracts/bridge/MovingFunds.sol +485 -79
- package/contracts/bridge/Redemption.sol +4 -4
- package/deploy/05_deploy_bridge.ts +5 -2
- package/export.json +375 -94
- package/package.json +1 -1
- package/artifacts/Sweep.json +0 -76
- package/build/contracts/bridge/Sweep.sol/Sweep.dbg.json +0 -4
|
@@ -22,7 +22,7 @@ import {IWalletOwner as EcdsaWalletOwner} from "@keep-network/ecdsa/contracts/ap
|
|
|
22
22
|
import "./IRelay.sol";
|
|
23
23
|
import "./BridgeState.sol";
|
|
24
24
|
import "./Deposit.sol";
|
|
25
|
-
import "./
|
|
25
|
+
import "./DepositSweep.sol";
|
|
26
26
|
import "./Redemption.sol";
|
|
27
27
|
import "./BitcoinTx.sol";
|
|
28
28
|
import "./EcdsaLib.sol";
|
|
@@ -60,7 +60,7 @@ import "../bank/Bank.sol";
|
|
|
60
60
|
contract Bridge is Governable, EcdsaWalletOwner {
|
|
61
61
|
using BridgeState for BridgeState.Storage;
|
|
62
62
|
using Deposit for BridgeState.Storage;
|
|
63
|
-
using
|
|
63
|
+
using DepositSweep for BridgeState.Storage;
|
|
64
64
|
using Redemption for BridgeState.Storage;
|
|
65
65
|
using MovingFunds for BridgeState.Storage;
|
|
66
66
|
using Wallets for BridgeState.Storage;
|
|
@@ -121,6 +121,8 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
121
121
|
|
|
122
122
|
event MovingFundsBelowDustReported(bytes20 walletPubKeyHash);
|
|
123
123
|
|
|
124
|
+
event MovedFundsSwept(bytes20 walletPubKeyHash, bytes32 sweepTxHash);
|
|
125
|
+
|
|
124
126
|
event NewWalletRequested();
|
|
125
127
|
|
|
126
128
|
event NewWalletRegistered(
|
|
@@ -177,8 +179,11 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
177
179
|
|
|
178
180
|
event MovingFundsParametersUpdated(
|
|
179
181
|
uint64 movingFundsTxMaxTotalFee,
|
|
182
|
+
uint64 movingFundsDustThreshold,
|
|
180
183
|
uint32 movingFundsTimeout,
|
|
181
|
-
|
|
184
|
+
uint96 movingFundsTimeoutSlashingAmount,
|
|
185
|
+
uint256 movingFundsTimeoutNotifierRewardMultiplier,
|
|
186
|
+
uint64 movedFundsSweepTxMaxTotalFee
|
|
182
187
|
);
|
|
183
188
|
|
|
184
189
|
event WalletParametersUpdated(
|
|
@@ -192,10 +197,10 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
192
197
|
);
|
|
193
198
|
|
|
194
199
|
event FraudParametersUpdated(
|
|
195
|
-
|
|
196
|
-
uint256 fraudNotifierRewardMultiplier,
|
|
200
|
+
uint256 fraudChallengeDepositAmount,
|
|
197
201
|
uint256 fraudChallengeDefeatTimeout,
|
|
198
|
-
|
|
202
|
+
uint96 fraudSlashingAmount,
|
|
203
|
+
uint256 fraudNotifierRewardMultiplier
|
|
199
204
|
);
|
|
200
205
|
|
|
201
206
|
constructor(
|
|
@@ -233,12 +238,15 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
233
238
|
self.redemptionTimeoutSlashingAmount = 10000 * 1e18; // 10000 T
|
|
234
239
|
self.redemptionTimeoutNotifierRewardMultiplier = 100; // 100%
|
|
235
240
|
self.movingFundsTxMaxTotalFee = 10000; // 10000 satoshi
|
|
236
|
-
self.movingFundsTimeout = 7 days;
|
|
237
241
|
self.movingFundsDustThreshold = 20000; // 20000 satoshi
|
|
242
|
+
self.movingFundsTimeout = 7 days;
|
|
243
|
+
self.movingFundsTimeoutSlashingAmount = 10000 * 1e18; // 10000 T
|
|
244
|
+
self.movingFundsTimeoutNotifierRewardMultiplier = 100; //100%
|
|
245
|
+
self.movedFundsSweepTxMaxTotalFee = 10000; // 10000 satoshi
|
|
246
|
+
self.fraudChallengeDepositAmount = 2 ether;
|
|
247
|
+
self.fraudChallengeDefeatTimeout = 7 days;
|
|
238
248
|
self.fraudSlashingAmount = 10000 * 1e18; // 10000 T
|
|
239
249
|
self.fraudNotifierRewardMultiplier = 100; // 100%
|
|
240
|
-
self.fraudChallengeDefeatTimeout = 7 days;
|
|
241
|
-
self.fraudChallengeDepositAmount = 2 ether;
|
|
242
250
|
self.walletCreationPeriod = 1 weeks;
|
|
243
251
|
self.walletCreationMinBtcBalance = 1e8; // 1 BTC
|
|
244
252
|
self.walletCreationMaxBtcBalance = 100e8; // 100 BTC
|
|
@@ -327,12 +335,12 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
327
335
|
/// - `mainUtxo` components must point to the recent main UTXO
|
|
328
336
|
/// of the given wallet, as currently known on the Ethereum chain.
|
|
329
337
|
/// If there is no main UTXO, this parameter is ignored.
|
|
330
|
-
function
|
|
338
|
+
function submitDepositSweepProof(
|
|
331
339
|
BitcoinTx.Info calldata sweepTx,
|
|
332
340
|
BitcoinTx.Proof calldata sweepProof,
|
|
333
341
|
BitcoinTx.UTXO calldata mainUtxo
|
|
334
342
|
) external {
|
|
335
|
-
self.
|
|
343
|
+
self.submitDepositSweepProof(sweepTx, sweepProof, mainUtxo);
|
|
336
344
|
}
|
|
337
345
|
|
|
338
346
|
/// @notice Requests redemption of the given amount from the specified
|
|
@@ -446,10 +454,10 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
446
454
|
/// - the tokens taken from the redeemer on redemption request will
|
|
447
455
|
/// be returned to the redeemer,
|
|
448
456
|
/// - the request will be moved from pending redemptions to
|
|
449
|
-
/// timed-out redemptions
|
|
457
|
+
/// timed-out redemptions,
|
|
450
458
|
/// - if the state of the wallet is `Live` or `MovingFunds`, the
|
|
451
459
|
/// wallet operators will be slashed and the notifier will be
|
|
452
|
-
/// rewarded
|
|
460
|
+
/// rewarded,
|
|
453
461
|
/// - if the state of wallet is `Live`, the wallet will be closed or
|
|
454
462
|
/// marked as `MovingFunds` (depending on the presence or absence
|
|
455
463
|
/// of the wallet's main UTXO) and the wallet will no longer be
|
|
@@ -467,10 +475,10 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
467
475
|
/// for the given `walletID`. Those IDs are not directly stored
|
|
468
476
|
/// in the contract for gas efficiency purposes but they can be
|
|
469
477
|
/// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
|
|
470
|
-
/// events
|
|
478
|
+
/// events of the `WalletRegistry` contract
|
|
471
479
|
/// - The amount of time defined by `redemptionTimeout` must have
|
|
472
480
|
/// passed since the redemption was requested (the request must be
|
|
473
|
-
/// timed-out)
|
|
481
|
+
/// timed-out)
|
|
474
482
|
function notifyRedemptionTimeout(
|
|
475
483
|
bytes20 walletPubKeyHash,
|
|
476
484
|
uint32[] calldata walletMembersIDs,
|
|
@@ -600,11 +608,21 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
600
608
|
/// @notice Notifies about a timed out moving funds process. Terminates
|
|
601
609
|
/// the wallet and slashes signing group members as a result.
|
|
602
610
|
/// @param walletPubKeyHash 20-byte public key hash of the wallet
|
|
611
|
+
/// @param walletMembersIDs Identifiers of the wallet signing group members
|
|
603
612
|
/// @dev Requirements:
|
|
604
613
|
/// - The wallet must be in the MovingFunds state
|
|
605
614
|
/// - The moving funds timeout must be actually exceeded
|
|
606
|
-
|
|
607
|
-
|
|
615
|
+
/// - The expression `keccak256(abi.encode(walletMembersIDs))` must
|
|
616
|
+
/// be exactly the same as the hash stored under `membersIdsHash`
|
|
617
|
+
/// for the given `walletID`. Those IDs are not directly stored
|
|
618
|
+
/// in the contract for gas efficiency purposes but they can be
|
|
619
|
+
/// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
|
|
620
|
+
/// events of the `WalletRegistry` contract
|
|
621
|
+
function notifyMovingFundsTimeout(
|
|
622
|
+
bytes20 walletPubKeyHash,
|
|
623
|
+
uint32[] calldata walletMembersIDs
|
|
624
|
+
) external {
|
|
625
|
+
self.notifyMovingFundsTimeout(walletPubKeyHash, walletMembersIDs);
|
|
608
626
|
}
|
|
609
627
|
|
|
610
628
|
/// @notice Notifies about a moving funds wallet whose BTC balance is
|
|
@@ -627,6 +645,53 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
627
645
|
self.notifyMovingFundsBelowDust(walletPubKeyHash, mainUtxo);
|
|
628
646
|
}
|
|
629
647
|
|
|
648
|
+
/// @notice Used by the wallet to prove the BTC moved funds sweep
|
|
649
|
+
/// transaction and to make the necessary state changes. Moved
|
|
650
|
+
/// funds sweep is only accepted if it satisfies SPV proof.
|
|
651
|
+
///
|
|
652
|
+
/// The function validates the sweep transaction structure by
|
|
653
|
+
/// checking if it actually spends the moved funds UTXO and the
|
|
654
|
+
/// sweeping wallet's main UTXO (optionally), and if it locks the
|
|
655
|
+
/// value on the sweeping wallet's 20-byte public key hash using a
|
|
656
|
+
/// reasonable transaction fee. If all preconditions are
|
|
657
|
+
/// met, this function updates the sweeping wallet main UTXO, thus
|
|
658
|
+
/// their BTC balance.
|
|
659
|
+
///
|
|
660
|
+
/// It is possible to prove the given sweep transaction only
|
|
661
|
+
/// one time.
|
|
662
|
+
/// @param sweepTx Bitcoin sweep funds transaction data
|
|
663
|
+
/// @param sweepProof Bitcoin sweep funds proof data
|
|
664
|
+
/// @param mainUtxo Data of the sweeping wallet's main UTXO, as currently
|
|
665
|
+
/// known on the Ethereum chain
|
|
666
|
+
/// @dev Requirements:
|
|
667
|
+
/// - `sweepTx` components must match the expected structure. See
|
|
668
|
+
/// `BitcoinTx.Info` docs for reference. Their values must exactly
|
|
669
|
+
/// correspond to appropriate Bitcoin transaction fields to produce
|
|
670
|
+
/// a provable transaction hash.
|
|
671
|
+
/// - The `sweepTx` should represent a Bitcoin transaction with
|
|
672
|
+
/// the first input pointing to a moved funds sweep request targeted
|
|
673
|
+
/// to the wallet, and optionally, the second input pointing to the
|
|
674
|
+
/// wallet's main UTXO, if the sweeping wallet has a main UTXO set.
|
|
675
|
+
/// There should be only one output locking funds on the sweeping
|
|
676
|
+
/// wallet 20-byte public key hash.
|
|
677
|
+
/// - `sweepProof` components must match the expected structure.
|
|
678
|
+
/// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
|
|
679
|
+
/// field must contain a valid number of block headers, not less
|
|
680
|
+
/// than the `txProofDifficultyFactor` contract constant.
|
|
681
|
+
/// - `mainUtxo` components must point to the recent main UTXO
|
|
682
|
+
/// of the sweeping wallet, as currently known on the Ethereum chain.
|
|
683
|
+
/// If there is no main UTXO, this parameter is ignored.
|
|
684
|
+
/// - The sweeping wallet must be in the Live or MovingFunds state.
|
|
685
|
+
/// - The total Bitcoin transaction fee must be lesser or equal
|
|
686
|
+
/// to `movedFundsSweepTxMaxTotalFee` governable parameter.
|
|
687
|
+
function submitMovedFundsSweepProof(
|
|
688
|
+
BitcoinTx.Info calldata sweepTx,
|
|
689
|
+
BitcoinTx.Proof calldata sweepProof,
|
|
690
|
+
BitcoinTx.UTXO calldata mainUtxo
|
|
691
|
+
) external {
|
|
692
|
+
self.submitMovedFundsSweepProof(sweepTx, sweepProof, mainUtxo);
|
|
693
|
+
}
|
|
694
|
+
|
|
630
695
|
/// @notice Requests creation of a new wallet. This function just
|
|
631
696
|
/// forms a request and the creation process is performed
|
|
632
697
|
/// asynchronously. Once a wallet is created, the ECDSA Wallet
|
|
@@ -824,7 +889,7 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
824
889
|
/// for the given `walletID`. Those IDs are not directly stored
|
|
825
890
|
/// in the contract for gas efficiency purposes but they can be
|
|
826
891
|
/// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
|
|
827
|
-
/// events
|
|
892
|
+
/// events of the `WalletRegistry` contract
|
|
828
893
|
/// - The amount of time indicated by `challengeDefeatTimeout` must pass
|
|
829
894
|
/// after the challenge was reported
|
|
830
895
|
function notifyFraudChallengeDefeatTimeout(
|
|
@@ -965,30 +1030,52 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
965
1030
|
/// BTC transaction fee that is acceptable in a single moving funds
|
|
966
1031
|
/// transaction. This is a _total_ max fee for the entire moving
|
|
967
1032
|
/// funds transaction.
|
|
968
|
-
/// @param movingFundsTimeout New value of the moving funds timeout in
|
|
969
|
-
/// seconds. It is the time after which the moving funds process can
|
|
970
|
-
/// be reported as timed out. It is counted from the moment when the
|
|
971
|
-
/// wallet was requested to move their funds and switched to the
|
|
972
|
-
/// MovingFunds state.
|
|
973
1033
|
/// @param movingFundsDustThreshold New value of the moving funds dust
|
|
974
1034
|
/// threshold. It is the minimal satoshi amount that makes sense to
|
|
975
1035
|
// be transferred during the moving funds process. Moving funds
|
|
976
1036
|
// wallets having their BTC balance below that value can begin
|
|
977
1037
|
// closing immediately as transferring such a low value may not be
|
|
978
1038
|
// possible due to BTC network fees.
|
|
1039
|
+
/// @param movingFundsTimeout New value of the moving funds timeout in
|
|
1040
|
+
/// seconds. It is the time after which the moving funds process can
|
|
1041
|
+
/// be reported as timed out. It is counted from the moment when the
|
|
1042
|
+
/// wallet was requested to move their funds and switched to the
|
|
1043
|
+
/// MovingFunds state.
|
|
1044
|
+
/// @param movingFundsTimeoutSlashingAmount New value of the moving funds
|
|
1045
|
+
/// timeout slashing amount in T, it is the amount slashed from each
|
|
1046
|
+
/// wallet member for moving funds timeout
|
|
1047
|
+
/// @param movingFundsTimeoutNotifierRewardMultiplier New value of the
|
|
1048
|
+
/// moving funds timeout notifier reward multiplier as percentage,
|
|
1049
|
+
/// it determines the percentage of the notifier reward from the
|
|
1050
|
+
/// staking contact the notifier of a moving funds timeout receives.
|
|
1051
|
+
/// The value must be in the range [0, 100]
|
|
1052
|
+
/// @param movedFundsSweepTxMaxTotalFee New value of the moved funds sweep
|
|
1053
|
+
/// transaction max total fee in satoshis. It is the maximum amount
|
|
1054
|
+
/// of the total BTC transaction fee that is acceptable in a single
|
|
1055
|
+
/// moved funds sweep transaction. This is a _total_ max fee for the
|
|
1056
|
+
/// entire moved funds sweep transaction.
|
|
979
1057
|
/// @dev Requirements:
|
|
980
1058
|
/// - Moving funds transaction max total fee must be greater than zero
|
|
981
|
-
/// - Moving funds timeout must be greater than zero
|
|
982
1059
|
/// - Moving funds dust threshold must be greater than zero
|
|
1060
|
+
/// - Moving funds timeout must be greater than zero
|
|
1061
|
+
/// - Moving funds timeout notifier reward multiplier must be in the
|
|
1062
|
+
/// range [0, 100]
|
|
1063
|
+
/// - Moved funds sweep transaction max total fee must be greater than zero
|
|
983
1064
|
function updateMovingFundsParameters(
|
|
984
1065
|
uint64 movingFundsTxMaxTotalFee,
|
|
1066
|
+
uint64 movingFundsDustThreshold,
|
|
985
1067
|
uint32 movingFundsTimeout,
|
|
986
|
-
|
|
1068
|
+
uint96 movingFundsTimeoutSlashingAmount,
|
|
1069
|
+
uint256 movingFundsTimeoutNotifierRewardMultiplier,
|
|
1070
|
+
uint64 movedFundsSweepTxMaxTotalFee
|
|
987
1071
|
) external onlyGovernance {
|
|
988
1072
|
self.updateMovingFundsParameters(
|
|
989
1073
|
movingFundsTxMaxTotalFee,
|
|
1074
|
+
movingFundsDustThreshold,
|
|
990
1075
|
movingFundsTimeout,
|
|
991
|
-
|
|
1076
|
+
movingFundsTimeoutSlashingAmount,
|
|
1077
|
+
movingFundsTimeoutNotifierRewardMultiplier,
|
|
1078
|
+
movedFundsSweepTxMaxTotalFee
|
|
992
1079
|
);
|
|
993
1080
|
}
|
|
994
1081
|
|
|
@@ -1039,6 +1126,12 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
1039
1126
|
}
|
|
1040
1127
|
|
|
1041
1128
|
/// @notice Updates parameters related to frauds.
|
|
1129
|
+
/// @param fraudChallengeDepositAmount New value of the fraud challenge
|
|
1130
|
+
/// deposit amount in wei, it is the amount of ETH the party
|
|
1131
|
+
/// challenging the wallet for fraud needs to deposit
|
|
1132
|
+
/// @param fraudChallengeDefeatTimeout New value of the challenge defeat
|
|
1133
|
+
/// timeout in seconds, it is the amount of time the wallet has to
|
|
1134
|
+
/// defeat a fraud challenge. The value must be greater than zero
|
|
1042
1135
|
/// @param fraudSlashingAmount New value of the fraud slashing amount in T,
|
|
1043
1136
|
/// it is the amount slashed from each wallet member for committing
|
|
1044
1137
|
/// a fraud
|
|
@@ -1046,26 +1139,20 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
1046
1139
|
/// reward multiplier as percentage, it determines the percentage of
|
|
1047
1140
|
/// the notifier reward from the staking contact the notifier of
|
|
1048
1141
|
/// a fraud receives. The value must be in the range [0, 100]
|
|
1049
|
-
/// @param fraudChallengeDefeatTimeout New value of the challenge defeat
|
|
1050
|
-
/// timeout in seconds, it is the amount of time the wallet has to
|
|
1051
|
-
/// defeat a fraud challenge. The value must be greater than zero
|
|
1052
|
-
/// @param fraudChallengeDepositAmount New value of the fraud challenge
|
|
1053
|
-
/// deposit amount in wei, it is the amount of ETH the party
|
|
1054
|
-
/// challenging the wallet for fraud needs to deposit
|
|
1055
1142
|
/// @dev Requirements:
|
|
1056
|
-
/// - Fraud notifier reward multiplier must be in the range [0, 100]
|
|
1057
1143
|
/// - Fraud challenge defeat timeout must be greater than 0
|
|
1144
|
+
/// - Fraud notifier reward multiplier must be in the range [0, 100]
|
|
1058
1145
|
function updateFraudParameters(
|
|
1059
|
-
|
|
1060
|
-
uint256 fraudNotifierRewardMultiplier,
|
|
1146
|
+
uint256 fraudChallengeDepositAmount,
|
|
1061
1147
|
uint256 fraudChallengeDefeatTimeout,
|
|
1062
|
-
|
|
1148
|
+
uint96 fraudSlashingAmount,
|
|
1149
|
+
uint256 fraudNotifierRewardMultiplier
|
|
1063
1150
|
) external onlyGovernance {
|
|
1064
1151
|
self.updateFraudParameters(
|
|
1065
|
-
|
|
1066
|
-
fraudNotifierRewardMultiplier,
|
|
1152
|
+
fraudChallengeDepositAmount,
|
|
1067
1153
|
fraudChallengeDefeatTimeout,
|
|
1068
|
-
|
|
1154
|
+
fraudSlashingAmount,
|
|
1155
|
+
fraudNotifierRewardMultiplier
|
|
1069
1156
|
);
|
|
1070
1157
|
}
|
|
1071
1158
|
|
|
@@ -1172,6 +1259,23 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
1172
1259
|
return self.fraudChallenges[challengeKey];
|
|
1173
1260
|
}
|
|
1174
1261
|
|
|
1262
|
+
/// @notice Collection of all moved funds sweep requests indexed by
|
|
1263
|
+
/// `keccak256(movingFundsTxHash | movingFundsOutputIndex)`.
|
|
1264
|
+
/// The `movingFundsTxHash` is `bytes32` (ordered as in Bitcoin
|
|
1265
|
+
/// internally) and `movingFundsOutputIndex` an `uint32`. Each entry
|
|
1266
|
+
/// is actually an UTXO representing the moved funds and is supposed
|
|
1267
|
+
/// to be swept with the current main UTXO of the recipient wallet.
|
|
1268
|
+
/// @param requestKey Request key built as
|
|
1269
|
+
/// `keccak256(movingFundsTxHash | movingFundsOutputIndex)`
|
|
1270
|
+
/// @return Details of the moved funds sweep request.
|
|
1271
|
+
function movedFundsSweepRequests(uint256 requestKey)
|
|
1272
|
+
external
|
|
1273
|
+
view
|
|
1274
|
+
returns (MovingFunds.MovedFundsSweepRequest memory)
|
|
1275
|
+
{
|
|
1276
|
+
return self.movedFundsSweepRequests[requestKey];
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1175
1279
|
/// @notice Indicates if the vault with the given address is trusted or not.
|
|
1176
1280
|
/// Depositors can route their revealed deposits only to trusted
|
|
1177
1281
|
/// vaults and have trusted vaults notified about new deposits as
|
|
@@ -1271,27 +1375,44 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
1271
1375
|
/// transaction fee that is acceptable in a single moving funds
|
|
1272
1376
|
/// transaction. This is a _total_ max fee for the entire moving
|
|
1273
1377
|
/// funds transaction.
|
|
1378
|
+
/// @return movingFundsDustThreshold The minimal satoshi amount that makes
|
|
1379
|
+
/// sense to be transferred during the moving funds process. Moving
|
|
1380
|
+
/// funds wallets having their BTC balance below that value can
|
|
1381
|
+
/// begin closing immediately as transferring such a low value may
|
|
1382
|
+
/// not be possible due to BTC network fees.
|
|
1274
1383
|
/// @return movingFundsTimeout Time after which the moving funds process
|
|
1275
1384
|
/// can be reported as timed out. It is counted from the moment
|
|
1276
1385
|
/// when the wallet was requested to move their funds and switched
|
|
1277
1386
|
/// to the MovingFunds state. Value in seconds.
|
|
1278
|
-
/// @return
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1387
|
+
/// @return movingFundsTimeoutSlashingAmount The amount of stake slashed
|
|
1388
|
+
/// from each member of a wallet for a moving funds timeout.
|
|
1389
|
+
/// @return movingFundsTimeoutNotifierRewardMultiplier The percentage of the
|
|
1390
|
+
/// notifier reward from the staking contract the notifier of a
|
|
1391
|
+
/// moving funds timeout receives. The value is in the range [0, 100].
|
|
1392
|
+
/// @return movedFundsSweepTxMaxTotalFee Maximum amount of the total BTC
|
|
1393
|
+
/// transaction fee that is acceptable in a single moved funds
|
|
1394
|
+
/// sweep transaction. This is a _total_ max fee for the entire
|
|
1395
|
+
/// moved funds sweep transaction.
|
|
1283
1396
|
function movingFundsParameters()
|
|
1284
1397
|
external
|
|
1285
1398
|
view
|
|
1286
1399
|
returns (
|
|
1287
1400
|
uint64 movingFundsTxMaxTotalFee,
|
|
1401
|
+
uint64 movingFundsDustThreshold,
|
|
1288
1402
|
uint32 movingFundsTimeout,
|
|
1289
|
-
|
|
1403
|
+
uint96 movingFundsTimeoutSlashingAmount,
|
|
1404
|
+
uint256 movingFundsTimeoutNotifierRewardMultiplier,
|
|
1405
|
+
uint64 movedFundsSweepTxMaxTotalFee
|
|
1290
1406
|
)
|
|
1291
1407
|
{
|
|
1292
1408
|
movingFundsTxMaxTotalFee = self.movingFundsTxMaxTotalFee;
|
|
1293
|
-
movingFundsTimeout = self.movingFundsTimeout;
|
|
1294
1409
|
movingFundsDustThreshold = self.movingFundsDustThreshold;
|
|
1410
|
+
movingFundsTimeout = self.movingFundsTimeout;
|
|
1411
|
+
movingFundsTimeoutSlashingAmount = self
|
|
1412
|
+
.movingFundsTimeoutSlashingAmount;
|
|
1413
|
+
movingFundsTimeoutNotifierRewardMultiplier = self
|
|
1414
|
+
.movingFundsTimeoutNotifierRewardMultiplier;
|
|
1415
|
+
movedFundsSweepTxMaxTotalFee = self.movedFundsSweepTxMaxTotalFee;
|
|
1295
1416
|
}
|
|
1296
1417
|
|
|
1297
1418
|
/// @return walletCreationPeriod Determines how frequently a new wallet
|
|
@@ -1334,29 +1455,29 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
1334
1455
|
}
|
|
1335
1456
|
|
|
1336
1457
|
/// @notice Returns the current values of Bridge fraud parameters.
|
|
1458
|
+
/// @return fraudChallengeDepositAmount The amount of ETH in wei the party
|
|
1459
|
+
/// challenging the wallet for fraud needs to deposit.
|
|
1460
|
+
/// @return fraudChallengeDefeatTimeout The amount of time the wallet has to
|
|
1461
|
+
/// defeat a fraud challenge.
|
|
1337
1462
|
/// @return fraudSlashingAmount The amount slashed from each wallet member
|
|
1338
1463
|
/// for committing a fraud.
|
|
1339
1464
|
/// @return fraudNotifierRewardMultiplier The percentage of the notifier
|
|
1340
1465
|
/// reward from the staking contract the notifier of a fraud
|
|
1341
1466
|
/// receives. The value is in the range [0, 100].
|
|
1342
|
-
/// @return fraudChallengeDefeatTimeout The amount of time the wallet has to
|
|
1343
|
-
/// defeat a fraud challenge.
|
|
1344
|
-
/// @return fraudChallengeDepositAmount The amount of ETH in wei the party
|
|
1345
|
-
/// challenging the wallet for fraud needs to deposit.
|
|
1346
1467
|
function fraudParameters()
|
|
1347
1468
|
external
|
|
1348
1469
|
view
|
|
1349
1470
|
returns (
|
|
1350
|
-
|
|
1351
|
-
uint256 fraudNotifierRewardMultiplier,
|
|
1471
|
+
uint256 fraudChallengeDepositAmount,
|
|
1352
1472
|
uint256 fraudChallengeDefeatTimeout,
|
|
1353
|
-
|
|
1473
|
+
uint96 fraudSlashingAmount,
|
|
1474
|
+
uint256 fraudNotifierRewardMultiplier
|
|
1354
1475
|
)
|
|
1355
1476
|
{
|
|
1477
|
+
fraudChallengeDepositAmount = self.fraudChallengeDepositAmount;
|
|
1478
|
+
fraudChallengeDefeatTimeout = self.fraudChallengeDefeatTimeout;
|
|
1356
1479
|
fraudSlashingAmount = self.fraudSlashingAmount;
|
|
1357
1480
|
fraudNotifierRewardMultiplier = self.fraudNotifierRewardMultiplier;
|
|
1358
|
-
fraudChallengeDefeatTimeout = self.fraudChallengeDefeatTimeout;
|
|
1359
|
-
fraudChallengeDepositAmount = self.fraudChallengeDepositAmount;
|
|
1360
1481
|
}
|
|
1361
1482
|
|
|
1362
1483
|
/// @notice Returns the addresses of contracts Bridge is interacting with.
|