Skip to content

Commit ca48b2c

Browse files
authoredMar 29, 2024
Fix pr-scan workflow and flaky tests
1 parent c582e58 commit ca48b2c

11 files changed

+134
-34
lines changed
 

‎.env.example

+3
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,8 @@ GAS_MULTIPLIER=110
7474
################################
7575
# Miscellaneous Configurations #
7676
################################
77+
# The file name from which to read the list of addresses to blacklist
78+
BLACKLIST_FILE_NAME=blacklist.remote.json
79+
7780
# [OPTIONAL] The API key to an Etherscan flavor block explorer.
7881
# ETHERSCAN_KEY=

‎.github/workflows/ci.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
run: yarn contract-size
4141

4242
- name: Run forge tests
43-
run: forge test
43+
run: forge test -vvv
4444

4545
- name: Generate gas report
4646
run: yarn gas-report
@@ -97,7 +97,9 @@ jobs:
9797

9898
scan:
9999
if: github.event_name == 'pull_request'
100-
uses: circlefin/circle-public-github-workflows/.github/workflows/pr-scan.yaml@v1
100+
uses: circlefin/circle-public-github-workflows/.github/workflows/pr-scan.yaml@v1.2.0
101+
with:
102+
allow-reciprocal-licenses: false
101103

102104
release-sbom:
103105
if: github.event_name == 'push'

‎.licenseignore

+33
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
11
pkg:npm/pako
22
pkg:npm/highlightjs-solidity
33
pkg:npm/ethereum-ens
4+
pkg:npm/%40ethereumjs/rlp@4.0.1
5+
pkg:npm/%40ethereumjs/util@8.1.0
6+
pkg:npm/%40nomicfoundation/ethereumjs-block@5.0.2
7+
pkg:npm/%40nomicfoundation/ethereumjs-blockchain@7.0.2
8+
pkg:npm/%40nomicfoundation/ethereumjs-ethash@3.0.2
9+
pkg:npm/%40nomicfoundation/ethereumjs-evm@2.0.2
10+
pkg:npm/%40nomicfoundation/ethereumjs-rlp@5.0.2
11+
pkg:npm/%40nomicfoundation/ethereumjs-statemanager@2.0.2
12+
pkg:npm/%40nomicfoundation/ethereumjs-trie@6.0.2
13+
pkg:npm/%40nomicfoundation/ethereumjs-tx@5.0.2
14+
pkg:npm/%40nomicfoundation/ethereumjs-util@9.0.2
15+
pkg:npm/%40nomicfoundation/ethereumjs-vm@7.0.2
16+
pkg:npm/web3@1.10.1
17+
pkg:npm/web3-bzz@1.10.1
18+
pkg:npm/web3-core@1.10.1
19+
pkg:npm/web3-core-helpers@1.10.1
20+
pkg:npm/web3-core-method@1.10.1
21+
pkg:npm/web3-core-promievent@1.10.1
22+
pkg:npm/web3-core-requestmanager@1.10.1
23+
pkg:npm/web3-core-subscriptions@1.10.1
24+
pkg:npm/web3-eth@1.10.1
25+
pkg:npm/web3-eth-abi@1.10.1
26+
pkg:npm/web3-eth-accounts@1.10.1
27+
pkg:npm/web3-eth-contract@1.10.1
28+
pkg:npm/web3-eth-ens@1.10.1
29+
pkg:npm/web3-eth-iban@1.10.1
30+
pkg:npm/web3-eth-personal@1.10.1
31+
pkg:npm/web3-net@1.10.1
32+
pkg:npm/web3-providers-http@1.10.1
33+
pkg:npm/web3-providers-ipc@1.10.1
34+
pkg:npm/web3-providers-ws@1.10.1
35+
pkg:npm/web3-shh@1.10.1
36+
pkg:npm/web3-utils@1.10.1

‎foundry.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ remappings = [
2828
"forge-std/=lib/forge-std/src",
2929
"@openzeppelin/=node_modules/@openzeppelin/",
3030
]
31-
fs_permissions = [{ access = "read-write", path = "blacklist.remote.json"}] # https://book.getfoundry.sh/cheatcodes/fs
31+
fs_permissions = [
32+
{ access = "read-write", path = "blacklist.remote.json"},
33+
{ access = "read-write", path = "test.blacklist.remote.json"}
34+
] # https://book.getfoundry.sh/cheatcodes/fs
3235

3336
[rpc_endpoints]
3437
testnet = "${TESTNET_RPC_URL}"

‎scripts/deploy/ScriptUtils.sol

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Copyright 2024 Circle Internet Financial, LTD. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
pragma solidity 0.6.12;
20+
pragma experimental ABIEncoderV2; // needed for compiling older solc versions: https://github.com/foundry-rs/foundry/issues/4376
21+
22+
import { Script } from "forge-std/Script.sol";
23+
24+
/**
25+
* Shared utilities for scripts. It inherits the Script contract in order
26+
* to access vm cheatcodes.
27+
*/
28+
contract ScriptUtils is Script {
29+
/**
30+
* @notice helper function that loads local json
31+
*/
32+
function _loadAccountsToBlacklist(string memory blacklistFileName)
33+
internal
34+
view
35+
returns (address[] memory)
36+
{
37+
string memory json = vm.readFile(blacklistFileName);
38+
return vm.parseJsonAddressArray(json, "");
39+
}
40+
}

‎scripts/deploy/deploy-impl-and-upgrader.s.sol

+6-15
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pragma solidity 0.6.12;
2020

2121
import "forge-std/console.sol"; // solhint-disable no-global-import, no-console
2222
import { Script } from "forge-std/Script.sol";
23+
import { ScriptUtils } from "./ScriptUtils.sol";
2324
import { DeployImpl } from "./DeployImpl.sol";
2425
import { FiatTokenProxy } from "../../contracts/v1/FiatTokenProxy.sol";
2526
import { FiatTokenV2_2 } from "../../contracts/v2/FiatTokenV2_2.sol";
@@ -29,8 +30,9 @@ import { V2_2Upgrader } from "../../contracts/v2/upgrader/V2_2Upgrader.sol";
2930
* A utility script to deploy the latest fiat token implementation and
3031
* an upgrader contract that updates fiat token use the latest implementation
3132
*/
32-
contract DeployImplAndUpgrader is Script, DeployImpl {
33+
contract DeployImplAndUpgrader is Script, DeployImpl, ScriptUtils {
3334
string private newTokenSymbol;
35+
string private blacklistFileName;
3436
address private impl;
3537
address payable private proxyContractAddress;
3638
address private proxyAdmin;
@@ -55,7 +57,8 @@ contract DeployImplAndUpgrader is Script, DeployImpl {
5557
vm.envAddress("OWNER_ADDRESS")
5658
);
5759

58-
accountsToBlacklist = loadAccountsToBlacklist();
60+
blacklistFileName = vm.envString("BLACKLIST_FILE_NAME");
61+
accountsToBlacklist = _loadAccountsToBlacklist(blacklistFileName);
5962

6063
deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");
6164

@@ -64,19 +67,7 @@ contract DeployImplAndUpgrader is Script, DeployImpl {
6467
console.log("FIAT_TOKEN_PROXY_ADDRESS: '%s'", proxyContractAddress);
6568
console.log("PROXY_ADMIN_ADDRESS: '%s'", proxyAdmin);
6669
console.log("LOST_AND_FOUND_ADDRESS: '%s'", lostAndFound);
67-
}
68-
69-
/**
70-
* @notice helper function that loads local json
71-
*/
72-
function loadAccountsToBlacklist()
73-
internal
74-
view
75-
returns (address[] memory)
76-
{
77-
string memory path = "blacklist.remote.json";
78-
string memory json = vm.readFile(path);
79-
return vm.parseJsonAddressArray(json, "");
70+
console.log("BLACKLIST_FILE_NAME: '%s'", blacklistFileName);
8071
}
8172

8273
/**

‎test.blacklist.remote.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
"0x04DBA1194ee10112fE6C3207C0687DEf0e78baCf",
3+
"0xb6f5ec1A0a9cd1526536D3F0426c429529471F40"
4+
]

‎test/scripts/deploy/TestUtils.sol

+26-9
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,31 @@ import {
2929

3030
contract TestUtils is Test {
3131
uint256 internal deployerPrivateKey = 1;
32+
uint256 internal proxyAdminPrivateKey = 2;
33+
uint256 internal masterMinterOwnerPrivateKey = 3;
34+
uint256 internal ownerPrivateKey = 4;
35+
uint256 internal pauserPrivateKey = 5;
36+
uint256 internal blacklisterPrivateKey = 6;
37+
uint256 internal lostAndFoundPrivateKey = 7;
38+
39+
address internal deployer = vm.addr(deployerPrivateKey);
40+
address internal proxyAdmin = vm.addr(proxyAdminPrivateKey);
41+
address internal masterMinterOwner = vm.addr(masterMinterOwnerPrivateKey);
42+
address internal owner = vm.addr(ownerPrivateKey);
43+
address internal pauser = vm.addr(pauserPrivateKey);
44+
address internal blacklister = vm.addr(blacklisterPrivateKey);
45+
address internal lostAndFound = vm.addr(lostAndFoundPrivateKey);
46+
47+
uint8 internal decimals = 6;
3248
string internal tokenName = "USDC";
3349
string internal tokenSymbol = "USDC";
34-
address internal proxyAdmin = vm.addr(2);
35-
address internal masterMinterOwner = vm.addr(3);
36-
address internal owner = vm.addr(4);
37-
address internal pauser = vm.addr(5);
38-
address internal blacklister = vm.addr(6);
39-
address internal lostAndFound = vm.addr(7);
40-
address[] internal accountsToBlacklist = new address[](0);
50+
51+
string internal blacklistFileName = "test.blacklist.remote.json";
52+
53+
address[] internal accountsToBlacklist = [
54+
0x04DBA1194ee10112fE6C3207C0687DEf0e78baCf,
55+
0xb6f5ec1A0a9cd1526536D3F0426c429529471F40
56+
];
4157

4258
function setUp() public virtual {
4359
vm.setEnv("TOKEN_NAME", tokenName);
@@ -56,12 +72,13 @@ contract TestUtils is Test {
5672
vm.setEnv("LOST_AND_FOUND_ADDRESS", vm.toString(lostAndFound));
5773

5874
// Deploy an instance of proxy contract to configure contract address in env
75+
vm.startPrank(deployer);
5976
FiatTokenV1 v1 = new FiatTokenV1();
6077
FiatTokenProxy proxy = new FiatTokenProxy(address(v1));
78+
vm.stopPrank();
6179
vm.setEnv("FIAT_TOKEN_PROXY_ADDRESS", vm.toString(address(proxy)));
6280

63-
// Write accountsToBlacklist to local blacklist.remote.json
64-
vm.writeJson("[]", "blacklist.remote.json");
81+
vm.setEnv("BLACKLIST_FILE_NAME", blacklistFileName);
6582
}
6683

6784
function validateImpl(FiatTokenV1 impl) internal {

‎test/scripts/deploy/deploy-fiat-token.t.sol

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ contract DeployFiatTokenTest is TestUtils {
3434

3535
function setUp() public override {
3636
TestUtils.setUp();
37+
38+
vm.prank(deployer);
3739
deployScript = new DeployFiatToken();
3840
deployScript.setUp();
3941
}
@@ -51,6 +53,7 @@ contract DeployFiatTokenTest is TestUtils {
5153
}
5254

5355
function test_deployFiatTokenWithPredeployedImpl() public {
56+
vm.prank(deployer);
5457
FiatTokenV2_2 predeployedImpl = new FiatTokenV2_2();
5558

5659
(, MasterMinter masterMinter, FiatTokenProxy proxy) = deployScript

‎test/scripts/deploy/deploy-impl-and-upgrader.t.sol

+7-5
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@ import { V2_2Upgrader } from "../../../contracts/v2/upgrader/V2_2Upgrader.sol";
2929
// solhint-disable func-name-mixedcase
3030

3131
contract DeployImplAndUpgraderTest is TestUtils {
32+
DeployImplAndUpgrader private deployScript;
33+
3234
function setUp() public override {
3335
TestUtils.setUp();
34-
}
3536

36-
function test_DeployImplAndUpgraderWithAllEnvConfigured() public {
37-
DeployImplAndUpgrader deployScript = new DeployImplAndUpgrader();
37+
vm.prank(deployer);
38+
deployScript = new DeployImplAndUpgrader();
3839
deployScript.setUp();
40+
}
3941

42+
function test_DeployImplAndUpgraderWithAllEnvConfigured() public {
4043
(FiatTokenV2_2 v2_2, V2_2Upgrader upgrader) = deployScript.run();
4144

4245
validateImpl(v2_2);
@@ -48,9 +51,8 @@ contract DeployImplAndUpgraderTest is TestUtils {
4851
}
4952

5053
function test_DeployImplAndUpgraderWithPredeployedImpl() public {
54+
vm.prank(deployer);
5155
FiatTokenV2_2 predeployedImpl = new FiatTokenV2_2();
52-
DeployImplAndUpgrader deployScript = new DeployImplAndUpgrader();
53-
deployScript.setUp();
5456

5557
(, V2_2Upgrader upgrader) = deployScript.deploy(
5658
address(predeployedImpl)

‎test/scripts/deploy/deploy-master-minter.t.sol

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ contract DeployMasterMinterTest is TestUtils {
3232

3333
function setUp() public override {
3434
TestUtils.setUp();
35-
}
3635

37-
function test_deployMasterMinter() public {
36+
vm.prank(deployer);
3837
deployScript = new DeployMasterMinter();
3938
deployScript.setUp();
39+
}
40+
41+
function test_deployMasterMinter() public {
4042
MasterMinter masterMinter = deployScript.run();
4143

4244
validateMasterMinter(

0 commit comments

Comments
 (0)
Please sign in to comment.