@keep-network/tbtc-v2 0.1.1-dev.43 → 0.1.1-dev.44
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 +742 -0
- package/artifacts/Bridge.json +2914 -0
- package/artifacts/Deposit.json +117 -0
- package/artifacts/EcdsaDkgValidator.json +532 -0
- package/artifacts/EcdsaInactivity.json +156 -0
- package/artifacts/Fraud.json +153 -0
- package/artifacts/KeepRegistry.json +99 -0
- package/artifacts/KeepStake.json +286 -0
- package/artifacts/KeepToken.json +711 -0
- package/artifacts/KeepTokenStaking.json +483 -0
- package/artifacts/MovingFunds.json +137 -0
- package/artifacts/NuCypherStakingEscrow.json +256 -0
- package/artifacts/NuCypherToken.json +711 -0
- package/artifacts/RandomBeaconStub.json +141 -0
- package/artifacts/Redemption.json +161 -0
- package/artifacts/ReimbursementPool.json +509 -0
- package/artifacts/Relay.json +123 -0
- package/artifacts/SortitionPool.json +944 -0
- package/artifacts/Sweep.json +76 -0
- package/artifacts/T.json +1148 -0
- package/artifacts/TBTC.json +21 -21
- package/artifacts/TBTCToken.json +21 -21
- package/artifacts/TokenStaking.json +2288 -0
- package/artifacts/TokenholderGovernor.json +1795 -0
- package/artifacts/TokenholderTimelock.json +1058 -0
- package/artifacts/VendingMachine.json +24 -24
- package/artifacts/VendingMachineKeep.json +400 -0
- package/artifacts/VendingMachineNuCypher.json +400 -0
- package/artifacts/WalletRegistry.json +2709 -0
- package/artifacts/WalletRegistryGovernance.json +2364 -0
- package/artifacts/Wallets.json +186 -0
- package/artifacts/solcInputs/{f2c15d3cf1bd9566483f595c5ed30ccc.json → bbe44823ec28554a9429cce5cafee035.json} +19 -19
- 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 +409 -31
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.json +114 -2
- 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 +5 -5
- 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 +40 -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 +21 -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 +276 -18
- package/contracts/bridge/BridgeState.sol +238 -5
- package/contracts/bridge/Deposit.sol +2 -2
- package/contracts/bridge/Fraud.sol +47 -17
- package/contracts/bridge/MovingFunds.sol +181 -1
- package/contracts/bridge/Redemption.sol +7 -12
- package/contracts/bridge/Sweep.sol +0 -3
- package/contracts/bridge/Wallets.sol +53 -35
- package/deploy/00_resolve_relay.ts +28 -0
- package/deploy/04_deploy_bank.ts +25 -0
- package/deploy/05_deploy_bridge.ts +60 -0
- package/deploy/06_bank_update_bridge.ts +19 -0
- package/deploy/07_transfer_ownership.ts +17 -0
- package/export.json +14797 -459
- package/package.json +2 -2
|
@@ -53,6 +53,10 @@ import "../bank/Bank.sol";
|
|
|
53
53
|
/// @dev Bridge is an upgradeable component of the Bank. The order of
|
|
54
54
|
/// functionalities in this contract is: deposit, sweep, redemption,
|
|
55
55
|
/// moving funds, wallet lifecycle, frauds, parameters.
|
|
56
|
+
///
|
|
57
|
+
/// TODO: Revisit all events and look which parameters should be indexed.
|
|
58
|
+
/// TODO: Align the convention around `param` and `dev` endings. They should
|
|
59
|
+
/// not have a punctuation mark.
|
|
56
60
|
contract Bridge is Ownable, EcdsaWalletOwner {
|
|
57
61
|
using BridgeState for BridgeState.Storage;
|
|
58
62
|
using Deposit for BridgeState.Storage;
|
|
@@ -102,11 +106,19 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
102
106
|
bytes20 indexed walletPubKeyHash
|
|
103
107
|
);
|
|
104
108
|
|
|
109
|
+
event MovingFundsCommitmentSubmitted(
|
|
110
|
+
bytes20 walletPubKeyHash,
|
|
111
|
+
bytes20[] targetWallets,
|
|
112
|
+
address submitter
|
|
113
|
+
);
|
|
114
|
+
|
|
105
115
|
event MovingFundsCompleted(
|
|
106
116
|
bytes20 walletPubKeyHash,
|
|
107
117
|
bytes32 movingFundsTxHash
|
|
108
118
|
);
|
|
109
119
|
|
|
120
|
+
event MovingFundsTimedOut(bytes20 walletPubKeyHash);
|
|
121
|
+
|
|
110
122
|
event NewWalletRequested();
|
|
111
123
|
|
|
112
124
|
event NewWalletRegistered(
|
|
@@ -114,6 +126,11 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
114
126
|
bytes20 indexed walletPubKeyHash
|
|
115
127
|
);
|
|
116
128
|
|
|
129
|
+
event WalletClosing(
|
|
130
|
+
bytes32 indexed ecdsaWalletID,
|
|
131
|
+
bytes20 indexed walletPubKeyHash
|
|
132
|
+
);
|
|
133
|
+
|
|
117
134
|
event WalletClosed(
|
|
118
135
|
bytes32 indexed ecdsaWalletID,
|
|
119
136
|
bytes20 indexed walletPubKeyHash
|
|
@@ -125,27 +142,53 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
125
142
|
);
|
|
126
143
|
|
|
127
144
|
event FraudChallengeSubmitted(
|
|
128
|
-
bytes20
|
|
145
|
+
bytes20 walletPubKeyHash,
|
|
129
146
|
bytes32 sighash,
|
|
130
147
|
uint8 v,
|
|
131
148
|
bytes32 r,
|
|
132
149
|
bytes32 s
|
|
133
150
|
);
|
|
134
151
|
|
|
135
|
-
event FraudChallengeDefeated(bytes20
|
|
152
|
+
event FraudChallengeDefeated(bytes20 walletPubKeyHash, bytes32 sighash);
|
|
136
153
|
|
|
137
154
|
event FraudChallengeDefeatTimedOut(
|
|
138
|
-
bytes20
|
|
155
|
+
bytes20 walletPubKeyHash,
|
|
139
156
|
bytes32 sighash
|
|
140
157
|
);
|
|
141
158
|
|
|
142
159
|
event VaultStatusUpdated(address indexed vault, bool isTrusted);
|
|
143
160
|
|
|
161
|
+
event DepositParametersUpdated(
|
|
162
|
+
uint64 depositDustThreshold,
|
|
163
|
+
uint64 depositTreasuryFeeDivisor,
|
|
164
|
+
uint64 depositTxMaxFee
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
event RedemptionParametersUpdated(
|
|
168
|
+
uint64 redemptionDustThreshold,
|
|
169
|
+
uint64 redemptionTreasuryFeeDivisor,
|
|
170
|
+
uint64 redemptionTxMaxFee,
|
|
171
|
+
uint256 redemptionTimeout
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
event MovingFundsParametersUpdated(
|
|
175
|
+
uint64 movingFundsTxMaxTotalFee,
|
|
176
|
+
uint32 movingFundsTimeout
|
|
177
|
+
);
|
|
178
|
+
|
|
144
179
|
event WalletParametersUpdated(
|
|
145
180
|
uint32 walletCreationPeriod,
|
|
146
181
|
uint64 walletMinBtcBalance,
|
|
147
182
|
uint64 walletMaxBtcBalance,
|
|
148
|
-
uint32 walletMaxAge
|
|
183
|
+
uint32 walletMaxAge,
|
|
184
|
+
uint64 walletMaxBtcTransfer
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
event FraudParametersUpdated(
|
|
188
|
+
uint256 fraudSlashingAmount,
|
|
189
|
+
uint256 fraudNotifierRewardMultiplier,
|
|
190
|
+
uint256 fraudChallengeDefeatTimeout,
|
|
191
|
+
uint256 fraudChallengeDepositAmount
|
|
149
192
|
);
|
|
150
193
|
|
|
151
194
|
constructor(
|
|
@@ -181,6 +224,7 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
181
224
|
self.redemptionTxMaxFee = 10000; // 10000 satoshi
|
|
182
225
|
self.redemptionTimeout = 172800; // 48 hours
|
|
183
226
|
self.movingFundsTxMaxTotalFee = 10000; // 10000 satoshi
|
|
227
|
+
self.movingFundsTimeout = 7 days;
|
|
184
228
|
self.fraudSlashingAmount = 10000 * 1e18; // 10000 T
|
|
185
229
|
self.fraudNotifierRewardMultiplier = 100; // 100%
|
|
186
230
|
self.fraudChallengeDefeatTimeout = 7 days;
|
|
@@ -189,6 +233,7 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
189
233
|
self.walletMinBtcBalance = 1e8; // 1 BTC
|
|
190
234
|
self.walletMaxBtcBalance = 10e8; // 10 BTC
|
|
191
235
|
self.walletMaxAge = 26 weeks; // ~6 months
|
|
236
|
+
self.walletMaxBtcTransfer = 10e8; // 10 BTC
|
|
192
237
|
}
|
|
193
238
|
|
|
194
239
|
/// @notice Used by the depositor to reveal information about their P2(W)SH
|
|
@@ -408,6 +453,61 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
408
453
|
self.notifyRedemptionTimeout(walletPubKeyHash, redeemerOutputScript);
|
|
409
454
|
}
|
|
410
455
|
|
|
456
|
+
/// @notice Submits the moving funds target wallets commitment.
|
|
457
|
+
/// Once all requirements are met, that function registers the
|
|
458
|
+
/// target wallets commitment and opens the way for moving funds
|
|
459
|
+
/// proof submission.
|
|
460
|
+
/// @param walletPubKeyHash 20-byte public key hash of the source wallet
|
|
461
|
+
/// @param walletMainUtxo Data of the source wallet's main UTXO, as
|
|
462
|
+
/// currently known on the Ethereum chain
|
|
463
|
+
/// @param walletMembersIDs Identifiers of the source wallet signing group
|
|
464
|
+
/// members
|
|
465
|
+
/// @param walletMemberIndex Position of the caller in the source wallet
|
|
466
|
+
/// signing group members list
|
|
467
|
+
/// @param targetWallets List of 20-byte public key hashes of the target
|
|
468
|
+
/// wallets that the source wallet commits to move the funds to
|
|
469
|
+
/// @dev Requirements:
|
|
470
|
+
/// - The source wallet must be in the MovingFunds state
|
|
471
|
+
/// - The source wallet must not have pending redemption requests
|
|
472
|
+
/// - The source wallet must not have submitted its commitment already
|
|
473
|
+
/// - The expression `keccak256(abi.encode(walletMembersIDs))` must
|
|
474
|
+
/// be exactly the same as the hash stored under `membersIdsHash`
|
|
475
|
+
/// for the given source wallet in the ECDSA registry. Those IDs are
|
|
476
|
+
/// not directly stored in the contract for gas efficiency purposes
|
|
477
|
+
/// but they can be read from appropriate `DkgResultSubmitted`
|
|
478
|
+
/// and `DkgResultApproved` events.
|
|
479
|
+
/// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length]
|
|
480
|
+
/// - The caller must be the member of the source wallet signing group
|
|
481
|
+
/// at the position indicated by `walletMemberIndex` parameter
|
|
482
|
+
/// - The `walletMainUtxo` components must point to the recent main
|
|
483
|
+
/// UTXO of the source wallet, as currently known on the Ethereum
|
|
484
|
+
/// chain.
|
|
485
|
+
/// - Source wallet BTC balance must be greater than zero
|
|
486
|
+
/// - At least one Live wallet must exist in the system
|
|
487
|
+
/// - Submitted target wallets count must match the expected count
|
|
488
|
+
/// `N = min(liveWalletsCount, ceil(walletBtcBalance / walletMaxBtcTransfer))`
|
|
489
|
+
/// where `N > 0`
|
|
490
|
+
/// - Each target wallet must be not equal to the source wallet
|
|
491
|
+
/// - Each target wallet must follow the expected order i.e. all
|
|
492
|
+
/// target wallets 20-byte public key hashes represented as numbers
|
|
493
|
+
/// must form a strictly increasing sequence without duplicates.
|
|
494
|
+
/// - Each target wallet must be in Live state
|
|
495
|
+
function submitMovingFundsCommitment(
|
|
496
|
+
bytes20 walletPubKeyHash,
|
|
497
|
+
BitcoinTx.UTXO calldata walletMainUtxo,
|
|
498
|
+
uint32[] calldata walletMembersIDs,
|
|
499
|
+
uint256 walletMemberIndex,
|
|
500
|
+
bytes20[] calldata targetWallets
|
|
501
|
+
) external {
|
|
502
|
+
self.submitMovingFundsCommitment(
|
|
503
|
+
walletPubKeyHash,
|
|
504
|
+
walletMainUtxo,
|
|
505
|
+
walletMembersIDs,
|
|
506
|
+
walletMemberIndex,
|
|
507
|
+
targetWallets
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
|
|
411
511
|
/// @notice Used by the wallet to prove the BTC moving funds transaction
|
|
412
512
|
/// and to make the necessary state changes. Moving funds is only
|
|
413
513
|
/// accepted if it satisfies SPV proof.
|
|
@@ -467,6 +567,16 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
467
567
|
);
|
|
468
568
|
}
|
|
469
569
|
|
|
570
|
+
/// @notice Notifies about a timed out moving funds process. Terminates
|
|
571
|
+
/// the wallet and slashes signing group members as a result.
|
|
572
|
+
/// @param walletPubKeyHash 20-byte public key hash of the wallet
|
|
573
|
+
/// @dev Requirements:
|
|
574
|
+
/// - The wallet must be in the MovingFunds state
|
|
575
|
+
/// - The moving funds timeout must be actually exceeded
|
|
576
|
+
function notifyMovingFundsTimeout(bytes20 walletPubKeyHash) external {
|
|
577
|
+
self.notifyMovingFundsTimeout(walletPubKeyHash);
|
|
578
|
+
}
|
|
579
|
+
|
|
470
580
|
/// @notice Requests creation of a new wallet. This function just
|
|
471
581
|
/// forms a request and the creation process is performed
|
|
472
582
|
/// asynchronously. Once a wallet is created, the ECDSA Wallet
|
|
@@ -525,7 +635,7 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
525
635
|
}
|
|
526
636
|
|
|
527
637
|
/// @notice Notifies that the wallet is either old enough or has too few
|
|
528
|
-
///
|
|
638
|
+
/// satoshi left and qualifies to be closed.
|
|
529
639
|
/// @param walletPubKeyHash 20-byte public key hash of the wallet
|
|
530
640
|
/// @param walletMainUtxo Data of the wallet's main UTXO, as currently
|
|
531
641
|
/// known on the Ethereum chain.
|
|
@@ -571,8 +681,8 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
571
681
|
/// for reference
|
|
572
682
|
/// @param signature Bitcoin signature in the R/S/V format
|
|
573
683
|
/// @dev Requirements:
|
|
574
|
-
/// - Wallet behind `
|
|
575
|
-
/// state
|
|
684
|
+
/// - Wallet behind `walletPublicKey` must be in Live or MovingFunds
|
|
685
|
+
/// or Closing state
|
|
576
686
|
/// - The challenger must send appropriate amount of ETH used as
|
|
577
687
|
/// fraud challenge deposit
|
|
578
688
|
/// - The signature (represented by r, s and v) must be generated by
|
|
@@ -670,40 +780,173 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
670
780
|
emit VaultStatusUpdated(vault, isTrusted);
|
|
671
781
|
}
|
|
672
782
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
783
|
+
/// @notice Updates parameters of deposits.
|
|
784
|
+
/// @param depositDustThreshold New value of the deposit dust threshold in
|
|
785
|
+
/// satoshis. It is the minimal amount that can be requested to
|
|
786
|
+
//// deposit. Value of this parameter must take into account the value
|
|
787
|
+
/// of `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters
|
|
788
|
+
/// in order to make requests that can incur the treasury and
|
|
789
|
+
/// transaction fee and still satisfy the depositor
|
|
790
|
+
/// @param depositTreasuryFeeDivisor New value of the treasury fee divisor.
|
|
791
|
+
/// It is the divisor used to compute the treasury fee taken from
|
|
792
|
+
/// each deposit and transferred to the treasury upon sweep proof
|
|
793
|
+
/// submission. That fee is computed as follows:
|
|
794
|
+
/// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`
|
|
795
|
+
/// For example, if the treasury fee needs to be 2% of each deposit,
|
|
796
|
+
/// the `depositTreasuryFeeDivisor` should be set to `50`
|
|
797
|
+
/// because `1/50 = 0.02 = 2%`
|
|
798
|
+
/// @param depositTxMaxFee New value of the deposit tx max fee in satoshis.
|
|
799
|
+
/// It is the maximum amount of BTC transaction fee that can
|
|
800
|
+
/// be incurred by each swept deposit being part of the given sweep
|
|
801
|
+
/// transaction. If the maximum BTC transaction fee is exceeded,
|
|
802
|
+
/// such transaction is considered a fraud
|
|
803
|
+
/// @dev Requirements:
|
|
804
|
+
/// - Deposit treasury fee divisor must be greater than zero
|
|
805
|
+
function updateDepositParameters(
|
|
806
|
+
uint64 depositDustThreshold,
|
|
807
|
+
uint64 depositTreasuryFeeDivisor,
|
|
808
|
+
uint64 depositTxMaxFee
|
|
809
|
+
) external onlyOwner {
|
|
810
|
+
self.updateDepositParameters(
|
|
811
|
+
depositDustThreshold,
|
|
812
|
+
depositTreasuryFeeDivisor,
|
|
813
|
+
depositTxMaxFee
|
|
814
|
+
);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/// @notice Updates parameters of redemptions.
|
|
818
|
+
/// @param redemptionDustThreshold New value of the redemption dust
|
|
819
|
+
/// threshold in satoshis. It is the minimal amount that can be
|
|
820
|
+
/// requested for redemption. Value of this parameter must take into
|
|
821
|
+
/// account the value of `redemptionTreasuryFeeDivisor` and
|
|
822
|
+
/// `redemptionTxMaxFee` parameters in order to make requests that
|
|
823
|
+
/// can incur the treasury and transaction fee and still satisfy the
|
|
824
|
+
/// redeemer.
|
|
825
|
+
/// @param redemptionTreasuryFeeDivisor New value of the redemption
|
|
826
|
+
/// treasury fee divisor. It is the divisor used to compute the
|
|
827
|
+
/// treasury fee taken from each redemption request and transferred
|
|
828
|
+
/// to the treasury upon successful request finalization. That fee is
|
|
829
|
+
/// computed as follows:
|
|
830
|
+
/// `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`
|
|
831
|
+
/// For example, if the treasury fee needs to be 2% of each
|
|
832
|
+
/// redemption request, the `redemptionTreasuryFeeDivisor` should
|
|
833
|
+
/// be set to `50` because `1/50 = 0.02 = 2%`.
|
|
834
|
+
/// @param redemptionTxMaxFee New value of the redemption transaction max
|
|
835
|
+
/// fee in satoshis. It is the maximum amount of BTC transaction fee
|
|
836
|
+
/// that can be incurred by each redemption request being part of the
|
|
837
|
+
/// given redemption transaction. If the maximum BTC transaction fee
|
|
838
|
+
/// is exceeded, such transaction is considered a fraud.
|
|
839
|
+
/// @param redemptionTimeout New value of the redemption timeout in seconds.
|
|
840
|
+
/// It is the time after which the redemption request can be reported
|
|
841
|
+
/// as timed out. It is counted from the moment when the redemption
|
|
842
|
+
/// request was created via `requestRedemption` call. Reported timed
|
|
843
|
+
/// out requests are cancelled and locked TBTC is returned to the
|
|
844
|
+
/// redeemer in full amount.
|
|
845
|
+
/// @dev Requirements:
|
|
846
|
+
/// - Redemption treasury fee divisor must be greater than zero
|
|
847
|
+
/// - Redemption timeout must be greater than zero
|
|
848
|
+
function updateRedemptionParameters(
|
|
849
|
+
uint64 redemptionDustThreshold,
|
|
850
|
+
uint64 redemptionTreasuryFeeDivisor,
|
|
851
|
+
uint64 redemptionTxMaxFee,
|
|
852
|
+
uint256 redemptionTimeout
|
|
853
|
+
) external onlyOwner {
|
|
854
|
+
self.updateRedemptionParameters(
|
|
855
|
+
redemptionDustThreshold,
|
|
856
|
+
redemptionTreasuryFeeDivisor,
|
|
857
|
+
redemptionTxMaxFee,
|
|
858
|
+
redemptionTimeout
|
|
859
|
+
);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/// @notice Updates parameters of moving funds.
|
|
863
|
+
/// @param movingFundsTxMaxTotalFee New value of the moving funds transaction
|
|
864
|
+
/// max total fee in satoshis. It is the maximum amount of the total
|
|
865
|
+
/// BTC transaction fee that is acceptable in a single moving funds
|
|
866
|
+
/// transaction. This is a _total_ max fee for the entire moving
|
|
867
|
+
/// funds transaction.
|
|
868
|
+
/// @param movingFundsTimeout New value of the moving funds timeout in
|
|
869
|
+
/// seconds. It is the time after which the moving funds process can
|
|
870
|
+
/// be reported as timed out. It is counted from the moment when the
|
|
871
|
+
/// wallet was requested to move their funds and switched to the
|
|
872
|
+
/// MovingFunds state.
|
|
873
|
+
/// @dev Requirements:
|
|
874
|
+
/// - Moving funds timeout must be greater than zero
|
|
875
|
+
function updateMovingFundsParameters(
|
|
876
|
+
uint64 movingFundsTxMaxTotalFee,
|
|
877
|
+
uint32 movingFundsTimeout
|
|
878
|
+
) external onlyOwner {
|
|
879
|
+
self.updateMovingFundsParameters(
|
|
880
|
+
movingFundsTxMaxTotalFee,
|
|
881
|
+
movingFundsTimeout
|
|
882
|
+
);
|
|
883
|
+
}
|
|
676
884
|
|
|
677
885
|
/// @notice Updates parameters of wallets.
|
|
678
886
|
/// @param walletCreationPeriod New value of the wallet creation period in
|
|
679
887
|
/// seconds, determines how frequently a new wallet creation can be
|
|
680
888
|
/// requested
|
|
681
889
|
/// @param walletMinBtcBalance New value of the wallet minimum BTC balance
|
|
682
|
-
/// in
|
|
890
|
+
/// in satoshi, used to decide about wallet creation or closing
|
|
683
891
|
/// @param walletMaxBtcBalance New value of the wallet maximum BTC balance
|
|
684
|
-
/// in
|
|
892
|
+
/// in satoshi, used to decide about wallet creation
|
|
685
893
|
/// @param walletMaxAge New value of the wallet maximum age in seconds,
|
|
686
894
|
/// indicates the maximum age of a wallet in seconds, after which
|
|
687
895
|
/// the wallet moving funds process can be requested
|
|
896
|
+
/// @param walletMaxBtcTransfer New value of the wallet maximum BTC transfer
|
|
897
|
+
/// in satoshi, determines the maximum amount that can be transferred
|
|
898
|
+
// to a single target wallet during the moving funds process
|
|
688
899
|
/// @dev Requirements:
|
|
689
900
|
/// - Wallet minimum BTC balance must be greater than zero
|
|
690
901
|
/// - Wallet maximum BTC balance must be greater than the wallet
|
|
691
902
|
/// minimum BTC balance
|
|
903
|
+
/// - Wallet maximum BTC transfer must be greater than zero
|
|
692
904
|
function updateWalletParameters(
|
|
693
905
|
uint32 walletCreationPeriod,
|
|
694
906
|
uint64 walletMinBtcBalance,
|
|
695
907
|
uint64 walletMaxBtcBalance,
|
|
696
|
-
uint32 walletMaxAge
|
|
908
|
+
uint32 walletMaxAge,
|
|
909
|
+
uint64 walletMaxBtcTransfer
|
|
697
910
|
) external onlyOwner {
|
|
698
911
|
self.updateWalletParameters(
|
|
699
912
|
walletCreationPeriod,
|
|
700
913
|
walletMinBtcBalance,
|
|
701
914
|
walletMaxBtcBalance,
|
|
702
|
-
walletMaxAge
|
|
915
|
+
walletMaxAge,
|
|
916
|
+
walletMaxBtcTransfer
|
|
703
917
|
);
|
|
704
918
|
}
|
|
705
919
|
|
|
706
|
-
|
|
920
|
+
/// @notice Updates parameters related to frauds.
|
|
921
|
+
/// @param fraudSlashingAmount New value of the fraud slashing amount in T,
|
|
922
|
+
/// it is the amount slashed from each wallet member for committing
|
|
923
|
+
/// a fraud
|
|
924
|
+
/// @param fraudNotifierRewardMultiplier New value of the fraud notifier
|
|
925
|
+
/// reward multiplier as percentage, it determines the percentage of
|
|
926
|
+
/// the notifier reward from the staking contact the notifier of
|
|
927
|
+
/// a fraud receives. The value must be in the range [0, 100]
|
|
928
|
+
/// @param fraudChallengeDefeatTimeout New value of the challenge defeat
|
|
929
|
+
/// timeout in seconds, it is the amount of time the wallet has to
|
|
930
|
+
/// defeat a fraud challenge. The value must be greater than zero
|
|
931
|
+
/// @param fraudChallengeDepositAmount New value of the fraud challenge
|
|
932
|
+
/// deposit amount in wei, it is the amount of ETH the party
|
|
933
|
+
/// challenging the wallet for fraud needs to deposit
|
|
934
|
+
/// @dev Requirements:
|
|
935
|
+
/// - Fraud notifier reward multiplier must be in the range [0, 100]
|
|
936
|
+
/// - Fraud challenge defeat timeout must be greater than 0
|
|
937
|
+
function updateFraudParameters(
|
|
938
|
+
uint256 fraudSlashingAmount,
|
|
939
|
+
uint256 fraudNotifierRewardMultiplier,
|
|
940
|
+
uint256 fraudChallengeDefeatTimeout,
|
|
941
|
+
uint256 fraudChallengeDepositAmount
|
|
942
|
+
) external onlyOwner {
|
|
943
|
+
self.updateFraudParameters(
|
|
944
|
+
fraudSlashingAmount,
|
|
945
|
+
fraudNotifierRewardMultiplier,
|
|
946
|
+
fraudChallengeDefeatTimeout,
|
|
947
|
+
fraudChallengeDepositAmount
|
|
948
|
+
);
|
|
949
|
+
}
|
|
707
950
|
|
|
708
951
|
/// @notice Collection of all revealed deposits indexed by
|
|
709
952
|
/// keccak256(fundingTxHash | fundingOutputIndex).
|
|
@@ -792,6 +1035,12 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
792
1035
|
return self.activeWalletPubKeyHash;
|
|
793
1036
|
}
|
|
794
1037
|
|
|
1038
|
+
/// @notice Gets the live wallets count.
|
|
1039
|
+
/// @return The current count of wallets being in the Live state.
|
|
1040
|
+
function liveWalletsCount() external view returns (uint32) {
|
|
1041
|
+
return self.liveWalletsCount;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
795
1044
|
/// @notice Returns the fraud challenge identified by the given key built
|
|
796
1045
|
/// as keccak256(walletPublicKey|sighash).
|
|
797
1046
|
function fraudChallenges(uint256 challengeKey)
|
|
@@ -889,13 +1138,17 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
889
1138
|
/// transaction fee that is acceptable in a single moving funds
|
|
890
1139
|
/// transaction. This is a _total_ max fee for the entire moving
|
|
891
1140
|
/// funds transaction.
|
|
1141
|
+
/// @return movingFundsTimeout Time after which the moving funds process
|
|
1142
|
+
/// can be reported as timed out. It is counted from the moment
|
|
1143
|
+
/// when the wallet was requested to move their funds and switched
|
|
1144
|
+
/// to the MovingFunds state. Value in seconds.
|
|
892
1145
|
function movingFundsParameters()
|
|
893
1146
|
external
|
|
894
1147
|
view
|
|
895
|
-
returns (uint64 movingFundsTxMaxTotalFee)
|
|
1148
|
+
returns (uint64 movingFundsTxMaxTotalFee, uint32 movingFundsTimeout)
|
|
896
1149
|
{
|
|
897
|
-
// TODO: we will have more parameters here, for example moving funds timeout
|
|
898
1150
|
movingFundsTxMaxTotalFee = self.movingFundsTxMaxTotalFee;
|
|
1151
|
+
movingFundsTimeout = self.movingFundsTimeout;
|
|
899
1152
|
}
|
|
900
1153
|
|
|
901
1154
|
/// @return walletCreationPeriod Determines how frequently a new wallet
|
|
@@ -906,6 +1159,9 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
906
1159
|
/// used to decide about wallet creation.
|
|
907
1160
|
/// @return walletMaxAge The maximum age of a wallet in seconds, after which
|
|
908
1161
|
/// the wallet moving funds process can be requested.
|
|
1162
|
+
/// @return walletMaxBtcTransfer The maximum BTC amount in satoshi than
|
|
1163
|
+
/// can be transferred to a single target wallet during the moving
|
|
1164
|
+
/// funds process.
|
|
909
1165
|
function walletParameters()
|
|
910
1166
|
external
|
|
911
1167
|
view
|
|
@@ -913,13 +1169,15 @@ contract Bridge is Ownable, EcdsaWalletOwner {
|
|
|
913
1169
|
uint32 walletCreationPeriod,
|
|
914
1170
|
uint64 walletMinBtcBalance,
|
|
915
1171
|
uint64 walletMaxBtcBalance,
|
|
916
|
-
uint32 walletMaxAge
|
|
1172
|
+
uint32 walletMaxAge,
|
|
1173
|
+
uint64 walletMaxBtcTransfer
|
|
917
1174
|
)
|
|
918
1175
|
{
|
|
919
1176
|
walletCreationPeriod = self.walletCreationPeriod;
|
|
920
1177
|
walletMinBtcBalance = self.walletMinBtcBalance;
|
|
921
1178
|
walletMaxBtcBalance = self.walletMaxBtcBalance;
|
|
922
1179
|
walletMaxAge = self.walletMaxAge;
|
|
1180
|
+
walletMaxBtcTransfer = self.walletMaxBtcTransfer;
|
|
923
1181
|
}
|
|
924
1182
|
|
|
925
1183
|
/// @notice Returns the current values of Bridge fraud parameters.
|