Skip to content

Commit 6d65f2e

Browse files
OmegaPoker: skip adding if pip is address(0) (#38)
* skip adding if pip is address(0) * deployment addresses * add omegapoker pip 0 test * improve omegapoker 0 pip test * add osm check to test Co-authored-by: Brian L. McMichael <[email protected]> * add forge * match optimizer settings from dapp * fix env variables Co-authored-by: Chris Smith <[email protected]>
1 parent 22e4c95 commit 6d65f2e

File tree

7 files changed

+66
-12
lines changed

7 files changed

+66
-12
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/out
2+
/cache

Makefile

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
all :; DAPP_BUILD_OPTIMIZE=1 DAPP_BUILD_OPTIMIZE_RUNS=1000 dapp --use solc:0.6.12 build
2-
clean :; dapp clean
3-
test :; ./test.sh
4-
deploy :; make && dapp create MegaPoker
1+
all :; DAPP_BUILD_OPTIMIZE=1 DAPP_BUILD_OPTIMIZE_RUNS=1000 dapp --use solc:0.6.12 build
2+
clean :; dapp clean
3+
test :; ./scripts/test.sh
4+
test-forge :; ./scripts/test-forge.sh match="$(match)" match-test="$(match-test)" match-contract="$(match-contract)"
5+
deploy :; make && dapp create MegaPoker

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ Extensible Poker for Goerli, Kovan and **Backup** for Mainnet.
1313

1414
The OmegaPoker will gather PIP Addresses from the [Ilk Registry](https://github.com/makerdao/ilk-registry) and Poke ALL Collaterals Without a Redeployment, at the expense of a little gas.
1515

16-
OmegaPoker Goerli Address: [0x091971A1DdDF12450D0D7003A29cD9fb94f8e54c](https://goerli.etherscan.io/address/0x091971a1dddf12450d0d7003a29cd9fb94f8e54c#code)
16+
OmegaPoker Goerli Address: [0xD47850BB4Dd0E1ae4D362399f577a47D675cC830](https://goerli.etherscan.io/address/0xD47850BB4Dd0E1ae4D362399f577a47D675cC830#code)
1717

18-
OmegaPoker Kovan Address: [0xB73c7D82956C9DFd17F8D212b9Cc9062ac04799e](https://kovan.etherscan.io/address/0xB73c7D82956C9DFd17F8D212b9Cc9062ac04799e#code)
19-
20-
OmegaPoker Mainnet Address: [0xAD0c5607d62b4003D70A5eA55893E23d7E2D3f0C](https://etherscan.io/address/0xAD0c5607d62b4003D70A5eA55893E23d7E2D3f0C#code)
18+
OmegaPoker Mainnet Address: [0xDd538C362dF996727054AC8Fb67ef5394eC9b8b9](https://etherscan.io/address/0xDd538C362dF996727054AC8Fb67ef5394eC9b8b9#code)
2119

2220
## `OmegaPoker.refresh()`
2321

scripts/test-forge.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
[[ "$(cast chain --rpc-url="$ETH_RPC_URL")" == "ethlive" ]] || { echo "Please set a Mainnet ETH_RPC_URL"; exit 1; }
5+
6+
for ARGUMENT in "$@"
7+
do
8+
KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
9+
VALUE=$(echo "$ARGUMENT" | cut -f2 -d=)
10+
11+
case "$KEY" in
12+
match) MATCH="$VALUE" ;;
13+
match-test) MATCH_TEST="$VALUE" ;;
14+
match-contract) MATCH_CONTRACT="$VALUE" ;;
15+
*)
16+
esac
17+
done
18+
19+
export DAPP_BUILD_OPTIMIZE=1
20+
export FOUNDRY_OPTIMIZER_RUNS=1000
21+
22+
if [[ -z "$MATCH" && -z "$BLOCK" ]]; then
23+
forge test --fork-url "$ETH_RPC_URL" --force
24+
elif [[ -n "$MATCH" ]]; then
25+
forge test --fork-url "$ETH_RPC_URL" --match "$MATCH" -vvv --force
26+
elif [[ -n "$MATCH_TEST" ]]; then
27+
forge test --fork-url "$ETH_RPC_URL" --match-test "$MATCH_TEST" -vvv --force
28+
else
29+
forge test --fork-url "$ETH_RPC_URL" --match-contract "$MATCH_CONTRACT" -vvv --force
30+
fi

test.sh scripts/test.sh

File renamed without changes.

src/OmegaPoker.sol

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ contract OmegaPoker {
6565

6666
address _pip = registry.pip(_ilks[i]);
6767

68+
if (_pip == address(0)) { continue; }
69+
6870
// OSM's and LP oracles have src() function
6971
(bool ok,) = _pip.call(abi.encodeWithSelector(srcselector));
7072

src/OmegaPoker.t.sol

+26-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ interface OsmLike {
6262
function pass() external view returns (bool);
6363
}
6464

65-
interface RegistryEdit {
65+
interface RegistryLike {
66+
function pip(bytes32) external returns (address);
67+
function file(bytes32,bytes32,address) external;
6668
function removeAuth(bytes32) external;
6769
}
6870

@@ -170,28 +172,48 @@ contract OmegaPokerTest is DSTest {
170172
assertTrue(ilkcount > 1);
171173
assertTrue(osmcount > 1);
172174

173-
RegistryEdit(registry).removeAuth("BAT-A"); // Remove Ilk + OSM
175+
RegistryLike(registry).removeAuth("BAT-A"); // Remove Ilk + OSM
174176

175177
omegaPoker.refresh();
176178

177179
assertEq(omegaPoker.ilkCount(), --ilkcount); // Remove BAT-A ilk from spot call
178180
assertEq(omegaPoker.osmCount(), --osmcount); // Remove bat osm
179181

180-
RegistryEdit(registry).removeAuth("ETH-A"); // Remove Ilk but leave OSM
182+
RegistryLike(registry).removeAuth("ETH-A"); // Remove Ilk but leave OSM
181183

182184
omegaPoker.refresh();
183185

184186
assertEq(omegaPoker.ilkCount(), --ilkcount); // Remove ETH-A ilk from spotter call
185187
assertEq(omegaPoker.osmCount(), osmcount); // Do not remove osm because it's used by ETH-B, etc.
186188

187-
RegistryEdit(registry).removeAuth("USDC-A"); // Remove ilk without OSM
189+
RegistryLike(registry).removeAuth("USDC-A"); // Remove ilk without OSM
188190

189191
omegaPoker.refresh();
190192

191193
assertEq(omegaPoker.ilkCount(), ilkcount); // Ilk should not have been poked because no OSM
192194
assertEq(omegaPoker.osmCount(), osmcount); // No osm to remove
193195
}
194196

197+
function testRefreshZeroPip() public {
198+
// grant ourselves authority on the ilk registry
199+
address registry = address(omegaPoker.registry());
200+
hevm.store(registry, keccak256(abi.encode(address(this), uint(0))), bytes32(uint(1)));
201+
202+
// Ensure we can refresh and poke
203+
omegaPoker.refresh();
204+
205+
RegistryLike(registry).file("ETH-A", "pip", address(0)); // Remove PIP
206+
assertEq(RegistryLike(registry).pip("ETH-A"), address(0));
207+
208+
// Ensure we can still refresh and poke
209+
omegaPoker.refresh();
210+
211+
for (uint i = 0; i < omegaPoker.osmCount(); i++) {
212+
address osm = omegaPoker.osms(i);
213+
assertTrue(osm != address(0));
214+
}
215+
}
216+
195217
function testPoke() public {
196218
for (uint i = 0; i < omegaPoker.osmCount(); i++) {
197219
OsmLike osm = OsmLike(omegaPoker.osms(i));

0 commit comments

Comments
 (0)