Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 Fix TrueFiPool2 'tether flush' test and disable Certora in CI #1180

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ jobs:
- attach_workspace:
at: .
- run: yarn lint
verify:
docker:
- image: circleci/python:3-node
steps:
- attach_workspace:
at: .
- run: yarn verify
test-others:
docker:
- image: cimg/node:16.1.0
Expand Down Expand Up @@ -143,10 +136,6 @@ workflows:
- slither:
requires:
- setup
- verify:
context: main
requires:
- setup
- test-truefi:
requires:
- build
Expand Down
4 changes: 3 additions & 1 deletion test/integration/TrueFiPool2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('TrueFiPool2', () => {
const USDC_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
const TFUSDT_ADDRESS = '0x6002b1dcb26e7b1aa797a17551c6f487923299d7'
const TFUSDT_STRATEGY_ADDRESS = '0x8D162Caa649e981E2a0b0ba5908A77f2536B11A8'
const PROXY_ADDRESS = '0x0BA5908a77f2536b11a88d162CAa649E981E2a0b'
Copy link
Collaborator

@yuchenlintt yuchenlintt Jul 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this address come from? I don't see it on Etherscan:
https://etherscan.io/address/0x0BA5908a77f2536b11a88d162CAa649E981E2a0b

Copy link
Contributor Author

@pkuchtatt pkuchtatt Jul 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The address is made up. I didn't think it mattered what it was, I thought the test worked with locally running Ganache rather than Ethereum mainnet. The problem I was trying to address was that we used the same address for two different contracts, see lines number 48 and 49. It was:

    const usdtPool = TrueFiPool2__factory.connect(TFUSDT_ADDRESS, powner)
    const proxy = OwnedProxyWithReference__factory.connect(TFUSDT_ADDRESS, powner)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a perfect learning moment, since we also want to write one of these "integration" tests for the new TrueUSDNoDelegate. (You can also see a minimal example in PR #1177, which also should be reviewed + merged at some point -- the action for which we wrote that test has already been queued and executed on the multisig.)

We use Ganache locally to run the test on a mainnet fork. We fork mainnet in the forkChain() call in line 27. You can optionally specify:

  • unlocked account addresses with particular properties (e.g., the owner() or proxyOwner() of the contract, or ETH_HOLDER is just a mainnet address that has a bunch of tokens), and
  • the block number to fork, in case there's some specific past contract state that we want to test.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the same address is a hacky workaround meant specifically for proxies. A proxy only supports a couple native functions, like proxyOwner(), transferProxyOwnership(), upgradeTo(), etc. Every other selector is forwarded on-chain to the implementation address's ABI.

Unfortunately Ganache and Ethers don't know this, so they complain whenever we issue a tx to a proxy that doesn't match its native ABI.

To work around this limitation when we need to make both upgrade and impl calls in the same test, we can connect to the same proxy address with its proxy ABI and its impl ABI as "separate" contracts.

const TRU_HOLDER = '0x23696914ca9737466d8553a2d619948f548ee424'
const ETH_HOLDER = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
const OWNER = '0x52bc44d5378309EE2abF1539BF71dE1b7d7bE3b5'
Expand Down Expand Up @@ -46,12 +47,13 @@ describe('TrueFiPool2', () => {

it('tether flush', async () => {
const usdtPool = TrueFiPool2__factory.connect(TFUSDT_ADDRESS, powner)
const proxy = OwnedProxyWithReference__factory.connect(TFUSDT_ADDRESS, powner)
const proxy = OwnedProxyWithReference__factory.connect(PROXY_ADDRESS, powner)
const strategyProxy = OwnedUpgradeabilityProxy__factory.connect(TFUSDT_STRATEGY_ADDRESS, powner)
await proxy.changeImplementationReference(implementationReference.address)
const newStrategy = await deployContract(CurveYearnStrategy__factory)
await strategyProxy.upgradeTo(newStrategy.address)
await holder.sendTransaction({ value: parseEth(100), to: CONFIG_GNOSIS_SAFE })
await usdtPool.connect(configGnosis).switchStrategy(strategyProxy.address)

await expect(usdtPool.connect(configGnosis).flush(10000000)).not.to.be.reverted
})
Expand Down