Commit 406d4d3
authored
Allowlist for Wallet Registry (#3826)
The allowlist contract replaces the Threshold `TokenStaking` contract
and is as an outcome of TIP-092 and TIP-100 governance decisions.
Staking tokens is no longer required to operate nodes. Beta stakers are
selected by the DAO and operate the network based on the allowlist
maintained by the DAO. The contract will be integrated with the
`WalletRegistry` and replace calls to `TokenStaking`.
I have been experimenting with various approaches, and the most extreme
one was to remove most of the `EcdsaAuthorization` logic as well as all
`TokenStaking.seize` calls. This would have cascading effects on tBTC
Bridge contracts as they rely on `WalletRegistry.seize`. That would also
require implementing weight decrease delays in the `Allowlist,` so
essentially doing work that is already done in `WalletRegistry`.
Considering the pros and cons, I decided on the least invasive option.
The `WalletRegistry` still thinks in terms of stake authorization, but
everything is based on the staking provider's weight as set in the
`Allowlist`, and weight decrease delays are enforced by the existing
mechanism in `EcdsaAuthorization`. The `seize` function does nothing
except of emitting an event about detecting beta staker misbehavior.
# To be done
## Deployment script
We need to capture all existing beta stakers along with their current
authorizations and initialize the `Allowlist` contract. We can do it by
either replicating the existing weights or giving them all the same
weight.
## Integrate with `WalletRegistry` and tests
There are two approaches to achieve it. The first one is to get rid of
all references to `TokenStaking` from tests and update them to work with
`Allowlist`. Another approach is to let them work with `TokenStaking`
but introduce another integration test for those two contracts. In this
option, we could use in `WalletRegistry` something like:
```
modifier onlyStakingContract() {
address _allowlist = address(allowlist);
require(
// If the allowlist is set, accept calls only from the allowlist.
// This is post-TIP-98 scenario. If the allowlist is not set, accept
// calls only from the staking contract. This is pre-TIP-98 scenario.
(_allowlist != address(0) && msg.sender == _allowlist) ||
(_allowlist == address(0) && msg.sender == address(staking)),
"Caller is not the staking contract"
);
_;
}
/// @notice Initializes V2 version of the WalletRegistry operating with the
/// Allowlist contract, as a result of TIP-098 and TIP-100 governance
/// decisions.
function initializeV2(address _allowlist) external reinitializer(2) {
allowlist = Allowlist(_allowlist);
}
/// @dev Provides the expected IStaking reference. If the allowlist is set,
/// it acts as the staking contract. If it is not set, the TokenStaking
/// acts as the staking contract.
function _staking() internal returns (IStaking) {
if (address(allowlist) != address(0)) {
return IStaking(allowlist);
}
return staking;
}
```
Note that the `WalletRegistry` is close to the maximum allowed contract
size and - surprise! - adding the logic above makes it exceed the
allowed size. This could potentially be alleviated by removing some of
the functionality. For example, in the `challengeDkgResult` function we
have a try catch as well as a call to `dkg.requireChallengeExtraGas()`.
This could potentially be eliminated as a no-op `seize` in `Allowlist`
is guaranteed to always succeed. Also, post
[EIP-7702](https://eips.ethereum.org/EIPS/eip-7702), the
`require(msg.sender == tx.origin, "Not EOA")` check is no longer
guaranteed to work as expected.52 files changed
Lines changed: 42875 additions & 3257 deletions
File tree
- .github/workflows
- solidity/ecdsa
- .openzeppelin
- contracts
- libraries
- test/upgrades
- deploy-data
- deployments/mainnet
- deploy
- docs
- external/sepolia
- scripts
- test
- fixtures
- utils
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments