-
Notifications
You must be signed in to change notification settings - Fork 84
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
Upgrade tests #2318
Open
sparrowDom
wants to merge
115
commits into
master
Choose a base branch
from
sparrowDom/upgrade_tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Upgrade tests #2318
Changes from all commits
Commits
Show all changes
115 commits
Select commit
Hold shift + click to select a range
07293d2
initial second implementation of rebasing to another account
sparrowDom 048b03f
update to core functionality
sparrowDom 36c599e
add gas fucntion
sparrowDom 05d746e
simplify execute
sparrowDom 28d83f9
simplify mint and burn
sparrowDom 45f476b
initial version of Daniel's yield delegation implementation
sparrowDom 9994263
prettier and linter fixes
naddison36 4c22467
Add slots to OUSD contract to align with existing deployments
naddison36 f537b63
Generated new OUSD contract diagrams
naddison36 5743461
Added deploy scripts for OToken upgrades
naddison36 68ae87e
Generated new OUSD storage diagram
naddison36 2dbd19e
Merge remote-tracking branch 'origin/master' into sparrowDom/rebaseEl…
naddison36 58afd12
some minor bug fixes
sparrowDom 17f121c
Prettier and fix spelling in comments
naddison36 381d13d
Unit test fixes
naddison36 4ee1b4b
fix initialise function sigature and visibility of functions
sparrowDom 9a29c45
fix some tests
sparrowDom 47e529f
add explanation for the alternativeCreditsPerToken check
sparrowDom 24f099b
prettier
sparrowDom 22c1cf5
reintroduce the original check
sparrowDom a5269b8
explicitly call rebaseOpt out if the yield delegating account hasn't …
sparrowDom e64ab17
add one more test
sparrowDom 68d14bd
add Readme of the token contract logic
sparrowDom ef7c4ab
force account to be rebasing on yield delegation
sparrowDom 90ec917
add explicit whitelist of allowed states when delegating yield
sparrowDom 2c96306
add more defensive checks where isNonRebasingAccount can not mistanki…
sparrowDom 4bf3360
remove increase/decrease allowance
sparrowDom 5cbcf4c
Update docs with invarients
DanielVF 0ab7bc8
Use safecast for any downcasting (#2306)
sparrowDom 2029659
More invarients around outer functions
DanielVF 5951660
Format invarients
DanielVF 8c126c8
further simplify the code when handling different rebase states
sparrowDom 8c2a358
remove nonreentrant modifiers from the toke code as they are not needed
sparrowDom d7a303f
allow empty conracts to rebaseOptIn without auto migration
sparrowDom 2b3189f
Transfer unit tests for new token implementation (#2310)
sparrowDom aa53ea3
More invarients
DanielVF 727e4e9
Correct total supply docs
DanielVF 77d69f1
Transfer unit tests for new token implementation (#2310)
sparrowDom 0cfa352
fix test
sparrowDom 31c8078
remove redundant state checks
sparrowDom 511dcaa
remove overwriting the same value to alternativeCreditsPerToken
sparrowDom 5f63650
add non zero checks in delegation functions
sparrowDom 4e327fa
correct error
sparrowDom 9e9c726
correct some contract view modifiers
sparrowDom 6e1b63e
add a readable error message when allowance is exceeded
sparrowDom 659f294
reducing 2 functions to 1
sparrowDom f261756
deprecate isUpgraded
sparrowDom 54b7ebe
rename totalSupply
sparrowDom 2b31fd6
improve initialisation checks
sparrowDom 108f0eb
remove gas optimisation that would also allow for errorneously large …
sparrowDom 24865d0
remove underflow checks
sparrowDom b728d2e
simplify code check for rebaseOptIn and add a test for it
sparrowDom ba625f0
remove comments
sparrowDom f8280d1
move the balance and credits query above the rebaseState changes
sparrowDom ab460b8
use _adjustGlobals function to adjust globals in yield delegation
sparrowDom c94cd5f
futher simplify the undelegateYield function
sparrowDom c3684a5
unify the variable names
sparrowDom 9cc74cc
add comment
sparrowDom 2987362
a couple of more places to utilise the _adjustGlobals function
sparrowDom 6b02387
no need this being a separate variable
sparrowDom 6556835
undo bug introduction
sparrowDom 56b11e2
wrong use of msg.sender bug fix
sparrowDom bbb3f45
function doesn't need to return any values
sparrowDom e949129
simplify
sparrowDom a1d3cdc
improve syntax
sparrowDom 504a421
add events for yield delegation
sparrowDom 546695f
remove var init
sparrowDom 62c1045
fix deploy file
sparrowDom fd45920
add tests to catch possible incorrect rebaseOptIn / rebaseOptOut attr…
sparrowDom 3d03c7b
simplify changeSupply code
sparrowDom fbb11a9
add storage slot gap
sparrowDom 6d5c745
Comments update
DanielVF 9ded07a
Comments spelling update
DanielVF 2c6bdc2
correct comments
sparrowDom 9436e7c
Merge remote-tracking branch 'origin/sparrowDom/rebaseElsewhere_v2' i…
sparrowDom f1939db
unify variable names
sparrowDom 57c8733
make credits calculation based of off balance for higher accuracy (in…
sparrowDom dc803f2
minor gas optimisation
sparrowDom 4893186
correct storage slot amount so it totals to 200
sparrowDom 09bde1b
Improve rebasing supply accuracy V2 (#2314)
sparrowDom ae51bbd
gas optimisation
sparrowDom f03deb3
better naming
sparrowDom db2044a
add a test where multiple rebaseOptIn/OptOut calls do not result in i…
sparrowDom 4495130
add a check for zero address with governanceRebaseOptIn tx
sparrowDom 53db807
Update on rebasing
DanielVF 948014c
add a check for zero address with governanceRebaseOptIn tx
sparrowDom 7d7055c
Merge remote-tracking branch 'origin/sparrowDom/rebaseElsewhere_v2' i…
sparrowDom 01b49a3
make an exception for balance exact non rebasing accounts (StdNonReba…
sparrowDom e355f3d
add test for the 1e27 cpt token exception
sparrowDom 7636c99
add a test to for creditsBalanceOf and creditsBalanceOfHighres
sparrowDom da68531
add nonRebasingCreditsPerToken to the test
sparrowDom 1b9d1e3
add auto migration test and revert test for rebaseOptOut
sparrowDom 34021fb
prettier
sparrowDom 57cccba
add tests for missing requires in yield delegation
sparrowDom 24bf72a
simplify code
sparrowDom f1b5290
revert to the previous implementation of the deprecated function
sparrowDom b22e9e4
Add the script
shahthepro 03f797f
minor change
sparrowDom 7ae4fbc
finish the balance extraction script
sparrowDom 20f1bd1
add OETH upgrade deployment file
sparrowDom cba9337
Merge remote-tracking branch 'origin/sparrowDom/rebaseElsewhere_v2' i…
sparrowDom ec052c3
add basic upgrade tests
sparrowDom 7b76cb8
change license to Business Source License
sparrowDom dbb3434
prettier
sparrowDom 93545c3
on changeSupply round up in the favour of the protocol
sparrowDom 5b7e2a7
Merge remote-tracking branch 'origin/sparrowDom/rebaseElsewhere_v2' i…
sparrowDom f9174e5
add Readme on how to perform upgrade tests
sparrowDom dc854bc
round down when calculating credits from balances
sparrowDom 4d13c09
make fetching squid balances in paralel
sparrowDom 7225364
remove unneeded await
sparrowDom 63ee2ba
Revert "round down when calculating credits from balances"
sparrowDom 6d95c43
add transfers to upgrade tests
sparrowDom 6592a20
Merge remote-tracking branch 'origin/sparrowDom/rebaseElsewhere_v2' i…
sparrowDom 83b05fc
Merge remote-tracking branch 'origin/master' into sparrowDom/upgrade_…
sparrowDom f04f022
use the more appropriate table
sparrowDom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const { deploymentWithGovernanceProposal } = require("../../utils/deploy"); | ||
|
||
module.exports = deploymentWithGovernanceProposal( | ||
{ | ||
deployName: "109_ousd_upgrade", | ||
forceDeploy: false, | ||
forceSkip: false, | ||
reduceQueueTime: true, | ||
deployerIsProposer: false, | ||
proposalId: "", | ||
}, | ||
async ({ deployWithConfirmation }) => { | ||
// Deployer Actions | ||
// ---------------- | ||
|
||
// 1. Deploy new OUSD implementation without storage slot checks | ||
const dOUSD = await deployWithConfirmation("OUSD", [], "OUSD", true); | ||
const cOUSDProxy = await ethers.getContract("OUSDProxy"); | ||
|
||
// Governance Actions | ||
// ---------------- | ||
return { | ||
name: "Upgrade OUSD token contract", | ||
actions: [ | ||
// 1. Upgrade the OUSD proxy to the new implementation | ||
{ | ||
contract: cOUSDProxy, | ||
signature: "upgradeTo(address)", | ||
args: [dOUSD.address], | ||
}, | ||
], | ||
}; | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const { deploymentWithGovernanceProposal } = require("../../utils/deploy"); | ||
|
||
module.exports = deploymentWithGovernanceProposal( | ||
{ | ||
deployName: "110_oeth_upgrade", | ||
forceDeploy: false, | ||
forceSkip: false, | ||
reduceQueueTime: true, | ||
deployerIsProposer: false, | ||
proposalId: "", | ||
}, | ||
async ({ deployWithConfirmation }) => { | ||
// Deployer Actions | ||
// ---------------- | ||
const cOETHProxy = await ethers.getContract("OETHProxy"); | ||
|
||
// Deploy new version of OETH contract | ||
const dOETHImpl = await deployWithConfirmation("OETH", []); | ||
|
||
// Governance Actions | ||
// ---------------- | ||
return { | ||
name: "Upgrade OETH token contract\n\ | ||
\n\ | ||
This upgrade enabled yield delegation controlled by xOGN governance \n\ | ||
\n\ | ||
", | ||
actions: [ | ||
// Upgrade the OETH token proxy contract to the new implementation | ||
{ | ||
contract: cOETHProxy, | ||
signature: "upgradeTo(address)", | ||
args: [dOETHImpl.address], | ||
}, | ||
], | ||
}; | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require("dotenv").config(); | ||
const postgres = require("postgres"); | ||
const ethers = require("ethers"); | ||
const fs = require('fs'); | ||
|
||
const sql = postgres(process.env.SQUID_DB_URL); | ||
|
||
const OETH_ADDRESS = "0x856c4efb76c1d1ae02e20ceb03a2a6a08b0b8dc3"; | ||
const OUSD_ADDRESS = "0x2a8e1e676ec238d8a992307b495b45b3feaa5e86"; | ||
const SUPER_OETH_ADDRESS = "0xdbfefd2e8460a6ee4955a68582f85708baea60a3"; | ||
|
||
async function getAddressesAndBalances(oTokenAddress, maxBlockNumber, csvFileName) { | ||
const batchSize = 5000; | ||
let offset = 0; | ||
const allAddresses = []; | ||
|
||
const blockSmallerOrEq = blockNumber => sql` AND block_number <= ${ blockNumber }` | ||
while (true) { | ||
console.log(`Running query batchSize: ${batchSize}, offset: ${offset}`); | ||
const batch = await sql` | ||
SELECT b.account, b.balance FROM ( | ||
SELECT DISTINCT ON (account) account, balance | ||
FROM erc20_holder | ||
WHERE address = ${oTokenAddress} | ||
ORDER BY account | ||
LIMIT ${batchSize} | ||
OFFSET ${offset} | ||
) b WHERE balance > 0 | ||
`; | ||
|
||
if (batch.length === 0) break; | ||
|
||
batch.forEach((row) => { | ||
allAddresses.push([row.account, row.balance].join(',')) | ||
//console.log(`account: ${row.account} balance: ${row.balance} block_number: ${row.block_number}`) | ||
}); | ||
offset += batchSize; | ||
|
||
console.log(`Processed ${allAddresses.length} unique addresses so far...`); | ||
} | ||
|
||
console.log(`Total ${oTokenAddress == OETH_ADDRESS ? "OETH" : "OUSD"} unique addresses found: ${allAddresses.length}`); | ||
|
||
// // Write addresses to CSV | ||
const csvContent = allAddresses.join('\n'); | ||
fs.writeFileSync(csvFileName, csvContent); | ||
console.log(`Addresses and balances written to ${csvFileName}`); | ||
|
||
return allAddresses; | ||
} | ||
|
||
async function main() { | ||
const oethAddresses = await getAddressesAndBalances(OETH_ADDRESS, 0, 'oethBalances.csv'); | ||
const ousdAddresses = await getAddressesAndBalances(OUSD_ADDRESS, 0, 'ousdBalances.csv'); | ||
const soethAddresses = await getAddressesAndBalances(SUPER_OETH_ADDRESS, 0, 'soethBalances.csv'); | ||
} | ||
|
||
main() | ||
.then(() => { | ||
console.log("Done!"); | ||
process.exit(0); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to do this in batches using
Promise.all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I didn't do that in the end because all the storage slots are already cached and this function executes quite quickly