@keep-network/tbtc-v2 0.1.1-dev.66 → 0.1.1-dev.69
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 +17 -17
- package/artifacts/Bridge.json +1293 -2768
- package/artifacts/DefaultProxyAdmin.json +259 -0
- package/artifacts/Deposit.json +14 -14
- package/artifacts/DepositSweep.json +10 -10
- package/artifacts/EcdsaDkgValidator.json +17 -16
- package/artifacts/EcdsaInactivity.json +11 -11
- package/artifacts/Fraud.json +15 -15
- 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 +19 -19
- package/artifacts/NuCypherStakingEscrow.json +1 -1
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeaconStub.json +18 -18
- package/artifacts/Redemption.json +16 -16
- package/artifacts/ReimbursementPool.json +17 -17
- package/artifacts/Relay.json +12 -12
- package/artifacts/SortitionPool.json +99 -38
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +19 -19
- package/artifacts/TBTCToken.json +19 -19
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +24 -24
- package/artifacts/VendingMachineKeep.json +1 -1
- package/artifacts/VendingMachineNuCypher.json +1 -1
- package/artifacts/WalletRegistry.json +310 -902
- package/artifacts/WalletRegistry_Implementation.json +2824 -0
- package/artifacts/WalletRegistry_Proxy.json +259 -0
- package/artifacts/Wallets.json +12 -12
- package/artifacts/solcInputs/1635d55d57a0a2552952c0d22586ed23.json +56 -0
- package/artifacts/solcInputs/eb507899925af50d85171e90b51ddf5f.json +269 -0
- 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 +103 -88
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.json +2 -2
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
- package/build/contracts/bridge/Deposit.sol/Deposit.json +4 -4
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.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/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/MovingFunds.sol/MovingFunds.json +9 -9
- 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 +6 -6
- 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/DonationVault.sol/DonationVault.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 +8 -0
- package/contracts/bridge/Bridge.sol +39 -20
- package/contracts/bridge/BridgeState.sol +8 -0
- package/contracts/bridge/Deposit.sol +7 -2
- package/contracts/bridge/DepositSweep.sol +4 -0
- package/contracts/bridge/Fraud.sol +9 -3
- package/contracts/bridge/MovingFunds.sol +15 -7
- package/contracts/bridge/Redemption.sol +11 -4
- package/contracts/bridge/Wallets.sol +3 -0
- package/contracts/hardhat-dependency-compiler/.hardhat-dependency-compiler +1 -0
- package/contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol +3 -0
- package/contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +3 -0
- package/deploy/00_resolve_wallet_registry.ts +83 -0
- package/deploy/05_deploy_bridge.ts +23 -14
- package/deploy/09_transfer_proxy_admin_ownership.ts +23 -0
- package/deploy/10_deploy_proxy_admin_with_deputy.ts +33 -0
- package/export.json +4824 -4354
- package/package.json +6 -2
- package/artifacts/WalletRegistryGovernance.json +0 -2364
- package/artifacts/solcInputs/496e626b61d332140d7f8662b25cbc03.json +0 -227
|
@@ -19,6 +19,11 @@ import "@keep-network/random-beacon/contracts/Governable.sol";
|
|
|
19
19
|
|
|
20
20
|
import {IWalletOwner as EcdsaWalletOwner} from "@keep-network/ecdsa/contracts/api/IWalletOwner.sol";
|
|
21
21
|
|
|
22
|
+
// TODO: We used RC version of @openzeppelin/contracts-upgradeable to use `reinitializer`
|
|
23
|
+
// in upgrades. We should revisit this part before mainnet deployment and use
|
|
24
|
+
// a final release package if it's ready.
|
|
25
|
+
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
26
|
+
|
|
22
27
|
import "./IRelay.sol";
|
|
23
28
|
import "./BridgeState.sol";
|
|
24
29
|
import "./Deposit.sol";
|
|
@@ -54,10 +59,9 @@ import "../bank/Bank.sol";
|
|
|
54
59
|
/// functionalities in this contract is: deposit, sweep, redemption,
|
|
55
60
|
/// moving funds, wallet lifecycle, frauds, parameters.
|
|
56
61
|
///
|
|
57
|
-
/// TODO: Revisit all events and look which parameters should be indexed.
|
|
58
62
|
/// TODO: Align the convention around `param` and `dev` endings. They should
|
|
59
63
|
/// not have a punctuation mark.
|
|
60
|
-
contract Bridge is Governable, EcdsaWalletOwner {
|
|
64
|
+
contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
61
65
|
using BridgeState for BridgeState.Storage;
|
|
62
66
|
using Deposit for BridgeState.Storage;
|
|
63
67
|
using DepositSweep for BridgeState.Storage;
|
|
@@ -71,10 +75,10 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
71
75
|
event DepositRevealed(
|
|
72
76
|
bytes32 fundingTxHash,
|
|
73
77
|
uint32 fundingOutputIndex,
|
|
74
|
-
address depositor,
|
|
78
|
+
address indexed depositor,
|
|
75
79
|
uint64 amount,
|
|
76
80
|
bytes8 blindingFactor,
|
|
77
|
-
bytes20 walletPubKeyHash,
|
|
81
|
+
bytes20 indexed walletPubKeyHash,
|
|
78
82
|
bytes20 refundPubKeyHash,
|
|
79
83
|
bytes4 refundLocktime,
|
|
80
84
|
address vault
|
|
@@ -83,21 +87,21 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
83
87
|
event DepositsSwept(bytes20 walletPubKeyHash, bytes32 sweepTxHash);
|
|
84
88
|
|
|
85
89
|
event RedemptionRequested(
|
|
86
|
-
bytes20 walletPubKeyHash,
|
|
90
|
+
bytes20 indexed walletPubKeyHash,
|
|
87
91
|
bytes redeemerOutputScript,
|
|
88
|
-
address redeemer,
|
|
92
|
+
address indexed redeemer,
|
|
89
93
|
uint64 requestedAmount,
|
|
90
94
|
uint64 treasuryFee,
|
|
91
95
|
uint64 txMaxFee
|
|
92
96
|
);
|
|
93
97
|
|
|
94
98
|
event RedemptionsCompleted(
|
|
95
|
-
bytes20 walletPubKeyHash,
|
|
99
|
+
bytes20 indexed walletPubKeyHash,
|
|
96
100
|
bytes32 redemptionTxHash
|
|
97
101
|
);
|
|
98
102
|
|
|
99
103
|
event RedemptionTimedOut(
|
|
100
|
-
bytes20 walletPubKeyHash,
|
|
104
|
+
bytes20 indexed walletPubKeyHash,
|
|
101
105
|
bytes redeemerOutputScript
|
|
102
106
|
);
|
|
103
107
|
|
|
@@ -107,26 +111,29 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
107
111
|
);
|
|
108
112
|
|
|
109
113
|
event MovingFundsCommitmentSubmitted(
|
|
110
|
-
bytes20 walletPubKeyHash,
|
|
114
|
+
bytes20 indexed walletPubKeyHash,
|
|
111
115
|
bytes20[] targetWallets,
|
|
112
116
|
address submitter
|
|
113
117
|
);
|
|
114
118
|
|
|
115
|
-
event MovingFundsTimeoutReset(bytes20 walletPubKeyHash);
|
|
119
|
+
event MovingFundsTimeoutReset(bytes20 indexed walletPubKeyHash);
|
|
116
120
|
|
|
117
121
|
event MovingFundsCompleted(
|
|
118
|
-
bytes20 walletPubKeyHash,
|
|
122
|
+
bytes20 indexed walletPubKeyHash,
|
|
119
123
|
bytes32 movingFundsTxHash
|
|
120
124
|
);
|
|
121
125
|
|
|
122
|
-
event MovingFundsTimedOut(bytes20 walletPubKeyHash);
|
|
126
|
+
event MovingFundsTimedOut(bytes20 indexed walletPubKeyHash);
|
|
123
127
|
|
|
124
|
-
event MovingFundsBelowDustReported(bytes20 walletPubKeyHash);
|
|
128
|
+
event MovingFundsBelowDustReported(bytes20 indexed walletPubKeyHash);
|
|
125
129
|
|
|
126
|
-
event MovedFundsSwept(
|
|
130
|
+
event MovedFundsSwept(
|
|
131
|
+
bytes20 indexed walletPubKeyHash,
|
|
132
|
+
bytes32 sweepTxHash
|
|
133
|
+
);
|
|
127
134
|
|
|
128
135
|
event MovedFundsSweepTimedOut(
|
|
129
|
-
bytes20 walletPubKeyHash,
|
|
136
|
+
bytes20 indexed walletPubKeyHash,
|
|
130
137
|
bytes32 movingFundsTxHash,
|
|
131
138
|
uint32 movingFundsTxOutputIndex
|
|
132
139
|
);
|
|
@@ -154,17 +161,20 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
154
161
|
);
|
|
155
162
|
|
|
156
163
|
event FraudChallengeSubmitted(
|
|
157
|
-
bytes20 walletPubKeyHash,
|
|
164
|
+
bytes20 indexed walletPubKeyHash,
|
|
158
165
|
bytes32 sighash,
|
|
159
166
|
uint8 v,
|
|
160
167
|
bytes32 r,
|
|
161
168
|
bytes32 s
|
|
162
169
|
);
|
|
163
170
|
|
|
164
|
-
event FraudChallengeDefeated(
|
|
171
|
+
event FraudChallengeDefeated(
|
|
172
|
+
bytes20 indexed walletPubKeyHash,
|
|
173
|
+
bytes32 sighash
|
|
174
|
+
);
|
|
165
175
|
|
|
166
176
|
event FraudChallengeDefeatTimedOut(
|
|
167
|
-
bytes20 walletPubKeyHash,
|
|
177
|
+
bytes20 indexed walletPubKeyHash,
|
|
168
178
|
bytes32 sighash
|
|
169
179
|
);
|
|
170
180
|
|
|
@@ -214,13 +224,22 @@ contract Bridge is Governable, EcdsaWalletOwner {
|
|
|
214
224
|
uint256 fraudNotifierRewardMultiplier
|
|
215
225
|
);
|
|
216
226
|
|
|
217
|
-
|
|
227
|
+
/// @dev Initializes upgradable contract on deployment.
|
|
228
|
+
/// @param _bank Address of the Bank the Bridge belongs to
|
|
229
|
+
/// @param _relay Address of the Bitcoin relay providing the current Bitcoin
|
|
230
|
+
/// network difficulty
|
|
231
|
+
/// @param _treasury Address where the deposit and redemption treasury fees
|
|
232
|
+
/// will be sent to
|
|
233
|
+
/// @param _ecdsaWalletRegistry Address of the ECDSA Wallet Registry contract
|
|
234
|
+
/// @param _txProofDifficultyFactor The number of confirmations on the Bitcoin
|
|
235
|
+
/// chain required to successfully evaluate an SPV proof
|
|
236
|
+
function initialize(
|
|
218
237
|
address _bank,
|
|
219
238
|
address _relay,
|
|
220
239
|
address _treasury,
|
|
221
240
|
address _ecdsaWalletRegistry,
|
|
222
241
|
uint256 _txProofDifficultyFactor
|
|
223
|
-
) {
|
|
242
|
+
) external initializer {
|
|
224
243
|
require(_bank != address(0), "Bank address cannot be zero");
|
|
225
244
|
self.bank = Bank(_bank);
|
|
226
245
|
|
|
@@ -256,6 +256,14 @@ library BridgeState {
|
|
|
256
256
|
// HASH160 over the compressed ECDSA public key) to the basic wallet
|
|
257
257
|
// information like state and pending redemptions value.
|
|
258
258
|
mapping(bytes20 => Wallets.Wallet) registeredWallets;
|
|
259
|
+
// Reserved storage space in case we need to add more variables.
|
|
260
|
+
// The convention from OpenZeppelin suggests the storage space should
|
|
261
|
+
// add up to 50 slots. Here we want to have more slots as there are
|
|
262
|
+
// planned upgrades of the Bridge contract. If more entires are added to
|
|
263
|
+
// the struct in the upcoming versions we need to reduce the array size.
|
|
264
|
+
// See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
|
|
265
|
+
// slither-disable-next-line unused-state
|
|
266
|
+
uint256[50] __gap;
|
|
259
267
|
}
|
|
260
268
|
|
|
261
269
|
event DepositParametersUpdated(
|
|
@@ -74,6 +74,8 @@ library Deposit {
|
|
|
74
74
|
// Address of the Bank vault to which the deposit is routed to.
|
|
75
75
|
// Optional, can be 0x0. The vault must be trusted by the Bridge.
|
|
76
76
|
address vault;
|
|
77
|
+
// This struct doesn't contain `__gap` property as the structure is not
|
|
78
|
+
// stored, it is used as a function's calldata argument.
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
/// @notice Represents tBTC deposit request data.
|
|
@@ -93,15 +95,18 @@ library Deposit {
|
|
|
93
95
|
// time when the deposit was swept on the Bitcoin chain but actually
|
|
94
96
|
// the time when the sweep proof was delivered to the Ethereum chain.
|
|
95
97
|
uint32 sweptAt;
|
|
98
|
+
// This struct doesn't contain `__gap` property as the structure is stored
|
|
99
|
+
// in a mapping, mappings store values in different slots and they are
|
|
100
|
+
// not contiguous with other values.
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
event DepositRevealed(
|
|
99
104
|
bytes32 fundingTxHash,
|
|
100
105
|
uint32 fundingOutputIndex,
|
|
101
|
-
address depositor,
|
|
106
|
+
address indexed depositor,
|
|
102
107
|
uint64 amount,
|
|
103
108
|
bytes8 blindingFactor,
|
|
104
|
-
bytes20 walletPubKeyHash,
|
|
109
|
+
bytes20 indexed walletPubKeyHash,
|
|
105
110
|
bytes20 refundPubKeyHash,
|
|
106
111
|
bytes4 refundLocktime,
|
|
107
112
|
address vault
|
|
@@ -60,6 +60,8 @@ library DepositSweep {
|
|
|
60
60
|
// with the same `vault` parameter. It is an optional parameter.
|
|
61
61
|
// Set to zero address if deposits are not routed to a vault.
|
|
62
62
|
address vault;
|
|
63
|
+
// This struct doesn't contain `__gap` property as the structure is not
|
|
64
|
+
// stored, it is used as a function's memory argument.
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
/// @notice Represents an outcome of the sweep Bitcoin transaction
|
|
@@ -86,6 +88,8 @@ library DepositSweep {
|
|
|
86
88
|
// UTXO doesn't exist) or less by one (main UTXO exists and is pointed
|
|
87
89
|
// by one of the inputs).
|
|
88
90
|
uint256[] treasuryFees;
|
|
91
|
+
// This struct doesn't contain `__gap` property as the structure is not
|
|
92
|
+
// stored, it is used as a function's memory argument.
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
event DepositsSwept(bytes20 walletPubKeyHash, bytes32 sweepTxHash);
|
|
@@ -68,20 +68,26 @@ library Fraud {
|
|
|
68
68
|
uint32 reportedAt;
|
|
69
69
|
// The flag indicating whether the challenge has been resolved.
|
|
70
70
|
bool resolved;
|
|
71
|
+
// This struct doesn't contain `__gap` property as the structure is stored
|
|
72
|
+
// in a mapping, mappings store values in different slots and they are
|
|
73
|
+
// not contiguous with other values.
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
event FraudChallengeSubmitted(
|
|
74
|
-
bytes20 walletPubKeyHash,
|
|
77
|
+
bytes20 indexed walletPubKeyHash,
|
|
75
78
|
bytes32 sighash,
|
|
76
79
|
uint8 v,
|
|
77
80
|
bytes32 r,
|
|
78
81
|
bytes32 s
|
|
79
82
|
);
|
|
80
83
|
|
|
81
|
-
event FraudChallengeDefeated(
|
|
84
|
+
event FraudChallengeDefeated(
|
|
85
|
+
bytes20 indexed walletPubKeyHash,
|
|
86
|
+
bytes32 sighash
|
|
87
|
+
);
|
|
82
88
|
|
|
83
89
|
event FraudChallengeDefeatTimedOut(
|
|
84
|
-
bytes20 walletPubKeyHash,
|
|
90
|
+
bytes20 indexed walletPubKeyHash,
|
|
85
91
|
// Sighash calculated as a Bitcoin's hash256 (double sha2) of:
|
|
86
92
|
// - a preimage of a transaction spending UTXO according to the protocol
|
|
87
93
|
// rules OR
|
|
@@ -56,6 +56,8 @@ library MovingFunds {
|
|
|
56
56
|
// during the processing. The validation is usually done as part
|
|
57
57
|
// of the `BitcoinTx.validateProof` call that checks the SPV proof.
|
|
58
58
|
bytes movingFundsTxOutputVector;
|
|
59
|
+
// This struct doesn't contain `__gap` property as the structure is not
|
|
60
|
+
// stored, it is used as a function's memory argument.
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
/// @notice Represents moved funds sweep request state.
|
|
@@ -85,29 +87,35 @@ library MovingFunds {
|
|
|
85
87
|
uint32 createdAt;
|
|
86
88
|
// The current state of the request.
|
|
87
89
|
MovedFundsSweepRequestState state;
|
|
90
|
+
// This struct doesn't contain `__gap` property as the structure is stored
|
|
91
|
+
// in a mapping, mappings store values in different slots and they are
|
|
92
|
+
// not contiguous with other values.
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
event MovingFundsCommitmentSubmitted(
|
|
91
|
-
bytes20 walletPubKeyHash,
|
|
96
|
+
bytes20 indexed walletPubKeyHash,
|
|
92
97
|
bytes20[] targetWallets,
|
|
93
98
|
address submitter
|
|
94
99
|
);
|
|
95
100
|
|
|
96
|
-
event MovingFundsTimeoutReset(bytes20 walletPubKeyHash);
|
|
101
|
+
event MovingFundsTimeoutReset(bytes20 indexed walletPubKeyHash);
|
|
97
102
|
|
|
98
103
|
event MovingFundsCompleted(
|
|
99
|
-
bytes20 walletPubKeyHash,
|
|
104
|
+
bytes20 indexed walletPubKeyHash,
|
|
100
105
|
bytes32 movingFundsTxHash
|
|
101
106
|
);
|
|
102
107
|
|
|
103
|
-
event MovingFundsTimedOut(bytes20 walletPubKeyHash);
|
|
108
|
+
event MovingFundsTimedOut(bytes20 indexed walletPubKeyHash);
|
|
104
109
|
|
|
105
|
-
event MovingFundsBelowDustReported(bytes20 walletPubKeyHash);
|
|
110
|
+
event MovingFundsBelowDustReported(bytes20 indexed walletPubKeyHash);
|
|
106
111
|
|
|
107
|
-
event MovedFundsSwept(
|
|
112
|
+
event MovedFundsSwept(
|
|
113
|
+
bytes20 indexed walletPubKeyHash,
|
|
114
|
+
bytes32 sweepTxHash
|
|
115
|
+
);
|
|
108
116
|
|
|
109
117
|
event MovedFundsSweepTimedOut(
|
|
110
|
-
bytes20 walletPubKeyHash,
|
|
118
|
+
bytes20 indexed walletPubKeyHash,
|
|
111
119
|
bytes32 movingFundsTxHash,
|
|
112
120
|
uint32 movingFundsTxOutputIndex
|
|
113
121
|
);
|
|
@@ -169,6 +169,9 @@ library Redemption {
|
|
|
169
169
|
uint64 txMaxFee;
|
|
170
170
|
// UNIX timestamp the request was created at.
|
|
171
171
|
uint32 requestedAt;
|
|
172
|
+
// This struct doesn't contain `__gap` property as the structure is stored
|
|
173
|
+
// in a mapping, mappings store values in different slots and they are
|
|
174
|
+
// not contiguous with other values.
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
/// @notice Represents an outcome of the redemption Bitcoin transaction
|
|
@@ -187,6 +190,8 @@ library Redemption {
|
|
|
187
190
|
uint32 changeIndex;
|
|
188
191
|
// Value in satoshi of the change output.
|
|
189
192
|
uint64 changeValue;
|
|
193
|
+
// This struct doesn't contain `__gap` property as the structure is not
|
|
194
|
+
// stored, it is used as a function's memory argument.
|
|
190
195
|
}
|
|
191
196
|
|
|
192
197
|
/// @notice Represents temporary information needed during the processing of
|
|
@@ -203,24 +208,26 @@ library Redemption {
|
|
|
203
208
|
bytes32 walletP2PKHScriptKeccak;
|
|
204
209
|
// P2WPKH script for the wallet. Needed to determine the change output.
|
|
205
210
|
bytes32 walletP2WPKHScriptKeccak;
|
|
211
|
+
// This struct doesn't contain `__gap` property as the structure is not
|
|
212
|
+
// stored, it is used as a function's memory argument.
|
|
206
213
|
}
|
|
207
214
|
|
|
208
215
|
event RedemptionRequested(
|
|
209
|
-
bytes20 walletPubKeyHash,
|
|
216
|
+
bytes20 indexed walletPubKeyHash,
|
|
210
217
|
bytes redeemerOutputScript,
|
|
211
|
-
address redeemer,
|
|
218
|
+
address indexed redeemer,
|
|
212
219
|
uint64 requestedAmount,
|
|
213
220
|
uint64 treasuryFee,
|
|
214
221
|
uint64 txMaxFee
|
|
215
222
|
);
|
|
216
223
|
|
|
217
224
|
event RedemptionsCompleted(
|
|
218
|
-
bytes20 walletPubKeyHash,
|
|
225
|
+
bytes20 indexed walletPubKeyHash,
|
|
219
226
|
bytes32 redemptionTxHash
|
|
220
227
|
);
|
|
221
228
|
|
|
222
229
|
event RedemptionTimedOut(
|
|
223
|
-
bytes20 walletPubKeyHash,
|
|
230
|
+
bytes20 indexed walletPubKeyHash,
|
|
224
231
|
bytes redeemerOutputScript
|
|
225
232
|
);
|
|
226
233
|
|
|
@@ -86,6 +86,9 @@ library Wallets {
|
|
|
86
86
|
// is built by applying the keccak256 hash over the list of 20-byte
|
|
87
87
|
// public key hashes of the target wallets.
|
|
88
88
|
bytes32 movingFundsTargetWalletsCommitmentHash;
|
|
89
|
+
// This struct doesn't contain `__gap` property as the structure is stored
|
|
90
|
+
// in a mapping, mappings store values in different slots and they are
|
|
91
|
+
// not contiguous with other values.
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
event NewWalletRequested();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
directory approved for write access by hardhat-dependency-compiler
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { HardhatRuntimeEnvironment } from "hardhat/types"
|
|
2
|
+
|
|
3
|
+
import { DeployFunction } from "hardhat-deploy/types"
|
|
4
|
+
|
|
5
|
+
import deploySortitionPool from "@keep-network/ecdsa/export/deploy/01_deploy_sortition_pool"
|
|
6
|
+
import deployReimbursementPool from "@keep-network/ecdsa/export/deploy/02_deploy_reimbursement_pool"
|
|
7
|
+
import deployDkgValidator from "@keep-network/ecdsa/export/deploy/03_deploy_dkg_validator"
|
|
8
|
+
|
|
9
|
+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|
10
|
+
const { getNamedAccounts, deployments, helpers } = hre
|
|
11
|
+
const { log } = deployments
|
|
12
|
+
const { deployer } = await getNamedAccounts()
|
|
13
|
+
|
|
14
|
+
const WalletRegistry = await deployments.getOrNull("WalletRegistry")
|
|
15
|
+
|
|
16
|
+
if (WalletRegistry && helpers.address.isValid(WalletRegistry.address)) {
|
|
17
|
+
log(`using external WalletRegistry at ${WalletRegistry.address}`)
|
|
18
|
+
} else if (hre.network.name !== "hardhat") {
|
|
19
|
+
throw new Error("deployed WalletRegistry contract not found")
|
|
20
|
+
} else {
|
|
21
|
+
// FIXME: This is a workaround deployment. We expect that the `WalletRegistry`
|
|
22
|
+
// contract deployment will be imported from `@keep-network/ecdsa` deployment
|
|
23
|
+
// scripts. But due to some bug or incompatibility of the plugins we use
|
|
24
|
+
// the deployment fails. We need to investigate it further nad get working
|
|
25
|
+
// properly.
|
|
26
|
+
// https://github.com/keep-network/tbtc-v2/issues/267
|
|
27
|
+
log("deploying WalletRegistry")
|
|
28
|
+
|
|
29
|
+
await deploySortitionPool(hre)
|
|
30
|
+
await deployReimbursementPool(hre)
|
|
31
|
+
await deployDkgValidator(hre)
|
|
32
|
+
|
|
33
|
+
const SortitionPool = await deployments.get("SortitionPool")
|
|
34
|
+
const TokenStaking = await deployments.get("TokenStaking")
|
|
35
|
+
const ReimbursementPool = await deployments.get("ReimbursementPool")
|
|
36
|
+
const EcdsaDkgValidator = await deployments.get("EcdsaDkgValidator")
|
|
37
|
+
|
|
38
|
+
// TODO: RandomBeaconStub contract should be replaced by actual implementation of
|
|
39
|
+
// RandomBeacon contract, once @keep-network/random-beacon hardhat deployments
|
|
40
|
+
// scripts are implemented.
|
|
41
|
+
log("deploying RandomBeaconStub contract instead of RandomBeacon")
|
|
42
|
+
const RandomBeacon = await deployments.deploy("RandomBeaconStub", {
|
|
43
|
+
from: deployer,
|
|
44
|
+
log: true,
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const EcdsaInactivity = await deployments.deploy("EcdsaInactivity", {
|
|
48
|
+
from: deployer,
|
|
49
|
+
log: true,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
// Use `deployments.deploy` instead of `helpers.upgrades.deployProxy` as
|
|
53
|
+
// to workaround problem with a hardhat-gas-reporter problem described in
|
|
54
|
+
// https://github.com/keep-network/keep-core/pull/2970.
|
|
55
|
+
await deployments.deploy("WalletRegistry", {
|
|
56
|
+
from: deployer,
|
|
57
|
+
args: [SortitionPool.address, TokenStaking.address],
|
|
58
|
+
libraries: {
|
|
59
|
+
EcdsaInactivity: EcdsaInactivity.address,
|
|
60
|
+
},
|
|
61
|
+
proxy: {
|
|
62
|
+
proxyContract: "TransparentUpgradeableProxy",
|
|
63
|
+
viaAdminContract: "DefaultProxyAdmin",
|
|
64
|
+
owner: deployer,
|
|
65
|
+
execute: {
|
|
66
|
+
init: {
|
|
67
|
+
methodName: "initialize",
|
|
68
|
+
args: [
|
|
69
|
+
EcdsaDkgValidator.address,
|
|
70
|
+
RandomBeacon.address,
|
|
71
|
+
ReimbursementPool.address,
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
log: true,
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default func
|
|
82
|
+
|
|
83
|
+
func.tags = ["WalletRegistry"]
|
|
@@ -2,7 +2,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"
|
|
|
2
2
|
import { DeployFunction } from "hardhat-deploy/types"
|
|
3
3
|
|
|
4
4
|
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|
5
|
-
const { deployments, getNamedAccounts } = hre
|
|
5
|
+
const { ethers, helpers, deployments, getNamedAccounts } = hre
|
|
6
6
|
const { deploy } = deployments
|
|
7
7
|
const { deployer, treasury } = await getNamedAccounts()
|
|
8
8
|
|
|
@@ -31,32 +31,41 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|
|
31
31
|
log: true,
|
|
32
32
|
})
|
|
33
33
|
|
|
34
|
-
const
|
|
35
|
-
|
|
34
|
+
const bridge = await helpers.upgrades.deployProxy("Bridge", {
|
|
35
|
+
contractName:
|
|
36
36
|
deployments.getNetworkName() === "hardhat" ? "BridgeStub" : undefined,
|
|
37
|
-
|
|
38
|
-
args: [
|
|
37
|
+
initializerArgs: [
|
|
39
38
|
Bank.address,
|
|
40
39
|
Relay.address,
|
|
41
40
|
treasury,
|
|
42
41
|
WalletRegistry.address,
|
|
43
42
|
txProofDifficultyFactor,
|
|
44
43
|
],
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
factoryOpts: {
|
|
45
|
+
signer: await ethers.getSigner(deployer),
|
|
46
|
+
libraries: {
|
|
47
|
+
Deposit: Deposit.address,
|
|
48
|
+
DepositSweep: DepositSweep.address,
|
|
49
|
+
Redemption: Redemption.address,
|
|
50
|
+
Wallets: Wallets.address,
|
|
51
|
+
Fraud: Fraud.address,
|
|
52
|
+
MovingFunds: MovingFunds.address,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
proxyOpts: {
|
|
56
|
+
kind: "transparent",
|
|
57
|
+
// Allow external libraries linking. We need to ensure manually that the
|
|
58
|
+
// external libraries we link are upgrade safe, as the OpenZeppelin plugin
|
|
59
|
+
// doesn't perform such a validation yet.
|
|
60
|
+
// See: https://docs.openzeppelin.com/upgrades-plugins/1.x/faq#why-cant-i-use-external-libraries
|
|
61
|
+
unsafeAllow: ["external-library-linking"],
|
|
52
62
|
},
|
|
53
|
-
log: true,
|
|
54
63
|
})
|
|
55
64
|
|
|
56
65
|
if (hre.network.tags.tenderly) {
|
|
57
66
|
await hre.tenderly.verify({
|
|
58
67
|
name: "Bridge",
|
|
59
|
-
address:
|
|
68
|
+
address: bridge.address,
|
|
60
69
|
})
|
|
61
70
|
}
|
|
62
71
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HardhatRuntimeEnvironment } from "hardhat/types"
|
|
2
|
+
import type { DeployFunction } from "hardhat-deploy/types"
|
|
3
|
+
|
|
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()
|
|
8
|
+
|
|
9
|
+
// TODO: Once a DAO is established we want to switch to ProxyAdminWithDeputy and
|
|
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}`)
|
|
15
|
+
|
|
16
|
+
const proxyAdmin = await upgrades.admin.getInstance()
|
|
17
|
+
await proxyAdmin.connect(deployer).transferOwnership(newProxyAdminOwner)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default func
|
|
21
|
+
|
|
22
|
+
func.tags = ["TransferProxyAdminOwnership"]
|
|
23
|
+
func.dependencies = ["Bridge"]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HardhatRuntimeEnvironment } from "hardhat/types"
|
|
2
|
+
import type { DeployFunction } from "hardhat-deploy/types"
|
|
3
|
+
|
|
4
|
+
const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
|
|
5
|
+
const { ethers, getNamedAccounts, upgrades, deployments } = hre
|
|
6
|
+
const { deployer, dao, esdm } = await getNamedAccounts()
|
|
7
|
+
|
|
8
|
+
const BridgeProxyAdminWithDeputy = await deployments.deploy(
|
|
9
|
+
"BridgeProxyAdminWithDeputy",
|
|
10
|
+
{
|
|
11
|
+
contract: "ProxyAdminWithDeputy",
|
|
12
|
+
from: deployer,
|
|
13
|
+
args: [dao, esdm],
|
|
14
|
+
log: true,
|
|
15
|
+
}
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const Bridge = await deployments.get("Bridge")
|
|
19
|
+
|
|
20
|
+
const proxyAdmin = await upgrades.admin.getInstance()
|
|
21
|
+
|
|
22
|
+
await proxyAdmin
|
|
23
|
+
.connect(await ethers.getSigner(esdm))
|
|
24
|
+
.changeProxyAdmin(Bridge.address, BridgeProxyAdminWithDeputy.address)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default func
|
|
28
|
+
|
|
29
|
+
func.tags = ["BridgeProxyAdminWithDeputy"]
|
|
30
|
+
func.dependencies = ["Bridge"]
|
|
31
|
+
|
|
32
|
+
// TODO: For now we skip this script as DAO is not yet established.
|
|
33
|
+
func.skip = async () => true
|