Skip to content

Commit 3fe9696

Browse files
committed
Fix CI failures: restore stake() test util, fix V2 storage layout,
update Dockerfile to Node 18, fix deploy data paths, fix Allowlist tests - operators.ts: Restore TokenStaking.stake() and increaseAuthorization() calls that were incorrectly replaced with a throw. These methods are still needed by the test harness for setting up operator fixtures. - WalletRegistryV2.sol: Add missing `allowlist` storage slot and import to match WalletRegistry V1 layout. Without this, OZ upgrade validation rejects the V2 contract as storage-incompatible. - Dockerfile: Bump base image from node:16-alpine to node:18-alpine. Transitive dependency cbor@10.0.3 requires Node >= 18, matching the project's .nvmrc (lts/hydrogen) and CI workflow (18.15.0). - 16_initialize_allowlist_weights.ts: Update JSON data file paths from deploy/data/ to ../deploy-data/ to match the relocated files. - Allowlist.test.ts: Deploy Allowlist through upgrades.deployProxy() since the contract uses _disableInitializers() in its constructor, preventing direct deployment + initialize() calls.
1 parent 29f56c2 commit 3fe9696

5 files changed

Lines changed: 40 additions & 36 deletions

File tree

solidity/ecdsa/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:16-alpine
1+
FROM node:18-alpine
22

33
RUN apk add --update --no-cache \
44
git \

solidity/ecdsa/contracts/test/upgrades/WalletRegistryV2.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import "@keep-network/random-beacon/contracts/Governable.sol";
3434

3535
import "@threshold-network/solidity-contracts/contracts/staking/IApplication.sol";
3636
import "@threshold-network/solidity-contracts/contracts/staking/IStaking.sol";
37+
import "../../Allowlist.sol";
3738

3839
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
3940

@@ -122,6 +123,7 @@ contract WalletRegistryV2 is
122123
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
123124
IStaking public immutable staking;
124125
IRandomBeacon public randomBeacon;
126+
Allowlist public allowlist;
125127

126128
// TEST: New variable
127129
string public newVar;

solidity/ecdsa/deploy/16_initialize_allowlist_weights.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,20 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
5050
// Use network-specific file if available
5151
const networkSpecificPath = path.join(
5252
__dirname,
53-
`data/allowlist-weights-${hre.network.name}.json`
53+
`../deploy-data/allowlist-weights-${hre.network.name}.json`
54+
)
55+
const defaultPath = path.join(
56+
__dirname,
57+
"../deploy-data/allowlist-weights.json"
5458
)
55-
const defaultPath = path.join(__dirname, "data/allowlist-weights.json")
5659
const weightsPath = fs.existsSync(networkSpecificPath)
5760
? networkSpecificPath
5861
: defaultPath
5962

6063
if (!fs.existsSync(weightsPath)) {
6164
throw new Error(
6265
`Weights file not found at ${weightsPath}. ` +
63-
"Please ensure allowlist-weights.json exists in deploy/data/"
66+
"Please ensure allowlist-weights.json exists in deploy-data/"
6467
)
6568
}
6669

solidity/ecdsa/test/Allowlist.test.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-unused-expressions, no-restricted-syntax, no-await-in-loop */
2-
import { ethers } from "hardhat"
2+
import { ethers, upgrades } from "hardhat"
33
import { smock } from "@defi-wonderland/smock"
44
import { expect } from "chai"
55

@@ -18,10 +18,6 @@ describe("Allowlist", () => {
1818
let thirdParty: SignerWithAddress
1919

2020
beforeEach(async () => {
21-
// Deploy Allowlist contract
22-
const AllowlistFactory = await ethers.getContractFactory("Allowlist")
23-
allowlist = await AllowlistFactory.deploy()
24-
2521
// Create fake WalletRegistry
2622
walletRegistry = await smock.fake<WalletRegistry>("WalletRegistry")
2723

@@ -32,8 +28,15 @@ describe("Allowlist", () => {
3228
stakingProvider2 = sp2
3329
thirdParty = tp
3430

35-
// Initialize the Allowlist contract - this sets deployer as the owner
36-
await allowlist.initialize(walletRegistry.address)
31+
// Deploy Allowlist as upgradeable proxy (has _disableInitializers in constructor)
32+
const AllowlistFactory = await ethers.getContractFactory("Allowlist")
33+
const proxy = await upgrades.deployProxy(
34+
AllowlistFactory,
35+
[walletRegistry.address],
36+
{ kind: "transparent" }
37+
)
38+
await proxy.deployed()
39+
allowlist = proxy as Allowlist
3740
})
3841

3942
describe("initialization", () => {
@@ -53,11 +56,12 @@ describe("Allowlist", () => {
5356

5457
it("should revert if initialized with zero address", async () => {
5558
const AllowlistFactory = await ethers.getContractFactory("Allowlist")
56-
const newAllowlist = await AllowlistFactory.deploy()
5759

58-
await expect(newAllowlist.initialize(ZERO_ADDRESS)).to.be.revertedWith(
59-
"ZeroAddress"
60-
)
60+
await expect(
61+
upgrades.deployProxy(AllowlistFactory, [ZERO_ADDRESS], {
62+
kind: "transparent",
63+
})
64+
).to.be.reverted
6165
})
6266
})
6367

solidity/ecdsa/test/utils/operators.ts

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -229,25 +229,20 @@ export async function stake(
229229
await t.connect(deployer).mint(owner.address, stakeAmount)
230230
await t.connect(owner).approve(staking.address, stakeAmount)
231231

232-
// NOTE: These methods no longer exist in TokenStaking interface
233-
// await staking
234-
// .connect(owner)
235-
// .stake(
236-
// stakingProvider.address,
237-
// beneficiary.address,
238-
// authorizer.address,
239-
// stakeAmount
240-
// )
241-
242-
// await staking
243-
// .connect(authorizer)
244-
// .increaseAuthorization(
245-
// stakingProvider.address,
246-
// randomBeacon.address,
247-
// stakeAmount
248-
// )
249-
250-
throw new Error(
251-
"stake() function is deprecated - TokenStaking.stake() and increaseAuthorization() no longer exist. Use Allowlist.addStakingProvider() instead."
252-
)
232+
await staking
233+
.connect(owner)
234+
.stake(
235+
stakingProvider.address,
236+
beneficiary.address,
237+
authorizer.address,
238+
stakeAmount
239+
)
240+
241+
await staking
242+
.connect(authorizer)
243+
.increaseAuthorization(
244+
stakingProvider.address,
245+
randomBeacon.address,
246+
stakeAmount
247+
)
253248
}

0 commit comments

Comments
 (0)