-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add fork test tooling #419
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
df1e6f4
Add fork test tooling
shahthepro aaae7d6
Update tooling to record script executions
shahthepro d3f4806
Merge branch 'DanielVF/DeployFiles' into shah/fork-test-tooling
shahthepro 28e29a7
Add a bit of tests
shahthepro cc01b28
Fix brownie tests
shahthepro 516937b
Add fork tests
shahthepro 383f2df
Print safe tx data
shahthepro e5582e1
Print tx data only on mainnet
shahthepro 8526d1d
Add Migrator tests
shahthepro 9728d78
Fix CI
shahthepro 5a7e530
Brownie remap
shahthepro efd24a5
Cherry pick CR comments
shahthepro 14d1073
Deploy 010 - OGN Rewards Source and xOGN (#420)
shahthepro 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
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 |
---|---|---|
|
@@ -16,3 +16,5 @@ out/ | |
.vscode | ||
brownie-deploy/ | ||
.idea | ||
deployments-fork*.json | ||
broadcast/* |
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
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 |
---|---|---|
|
@@ -3,3 +3,7 @@ dependencies: | |
- OpenZeppelin/[email protected] | ||
- OpenZeppelin/[email protected] | ||
- paulrberg/[email protected] | ||
compiler: | ||
solc: | ||
remappings: | ||
- forge-std/=./lib/forge-std/src/ |
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,13 @@ | ||
{ | ||
"1": { | ||
"executions": { | ||
"010_xOGNSetup": 1716312107 | ||
}, | ||
"contracts": { | ||
"OGN_REWARDS_SOURCE": "0x7609c88E5880e934dd3A75bCFef44E31b1Badb8b", | ||
"OGN_REWARDS_SOURCE_IMPL": "0x16890bdd817Ed1c4654430d67329CB20b0B71bB0", | ||
"XOGN": "0x63898b3b6Ef3d39332082178656E9862bee45C57", | ||
"XOGN_IMPL": "0x97711c7a5D64A064a95d10e37f786d2bD8b1F3c8" | ||
} | ||
} | ||
} |
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
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,10 @@ | ||
// SPDX-License-Identifier: Unlicense | ||
pragma solidity 0.8.10; | ||
|
||
interface IMintableERC20 { | ||
function mint(address to, uint256 amount) external; | ||
function balanceOf(address owner) external view returns (uint256); | ||
function totalSupply() external view returns (uint256); | ||
function transfer(address to, uint256 amount) external returns (bool); | ||
function approve(address spender, uint256 allowance) external; | ||
} |
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,15 @@ | ||
// SPDX-License-Identifier: Unlicense | ||
pragma solidity 0.8.10; | ||
|
||
interface IOGNGovernance { | ||
function state(uint256 proposalId) external view returns (uint256); | ||
function proposalCount() external view returns (uint256); | ||
function queue(uint256 proposalId) external; | ||
function execute(uint256 proposalId) external; | ||
function propose( | ||
address[] memory targets, | ||
string[] memory signatures, | ||
bytes[] memory calldatas, | ||
string memory description | ||
) external returns (uint256); | ||
} |
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
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,67 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.10; | ||
|
||
import {Vm} from "forge-std/Vm.sol"; | ||
import {Addresses} from "contracts/utils/Addresses.sol"; | ||
import "forge-std/console.sol"; | ||
|
||
import "OpenZeppelin/[email protected]/contracts/utils/Strings.sol"; | ||
|
||
library GovFive { | ||
struct GovFiveAction { | ||
address receiver; | ||
string fullsig; | ||
bytes data; | ||
} | ||
|
||
struct GovFiveProposal { | ||
string name; | ||
string description; | ||
GovFiveAction[] actions; | ||
} | ||
|
||
function setName(GovFiveProposal storage prop, string memory name) internal { | ||
prop.name = name; | ||
} | ||
|
||
function setDescription(GovFiveProposal storage prop, string memory description) internal { | ||
prop.description = description; | ||
} | ||
|
||
function action(GovFiveProposal storage prop, address receiver, string memory fullsig, bytes memory data) | ||
internal | ||
{ | ||
prop.actions.push(GovFiveAction({receiver: receiver, fullsig: fullsig, data: data})); | ||
} | ||
|
||
function printTxData(GovFiveProposal storage prop) internal { | ||
console.log("-----------------------------------"); | ||
console.log("Create following tx on Gnosis safe:"); | ||
console.log("-----------------------------------"); | ||
for (uint256 i = 0; i < prop.actions.length; i++) { | ||
GovFiveAction memory propAction = prop.actions[i]; | ||
bytes memory sig = abi.encodePacked(bytes4(keccak256(bytes(propAction.fullsig)))); | ||
|
||
console.log("### Tx", i + 1); | ||
console.log("Address:", propAction.receiver); | ||
console.log("Data:"); | ||
console.logBytes(abi.encodePacked(sig, propAction.data)); | ||
} | ||
} | ||
|
||
function execute(GovFiveProposal storage prop) internal { | ||
address VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code")))); | ||
Vm vm = Vm(VM_ADDRESS); | ||
for (uint256 i = 0; i < prop.actions.length; i++) { | ||
GovFiveAction memory propAction = prop.actions[i]; | ||
bytes memory sig = abi.encodePacked(bytes4(keccak256(bytes(propAction.fullsig)))); | ||
vm.prank(Addresses.TIMELOCK); | ||
(bool success, bytes memory data) = propAction.receiver.call(abi.encodePacked(sig, propAction.data)); | ||
if (!success) { | ||
console.log(propAction.fullsig); | ||
revert("Multisig action failed"); | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,9 +3,15 @@ src = 'contracts' | |
test = 'tests' | ||
remappings = [ | ||
"contracts/=./contracts", | ||
"script/=./script", | ||
"tests/=./tests", | ||
"OpenZeppelin/openzeppelin-contracts@02fcc75bb7f35376c22def91b0fb9bc7a50b9458/=./lib/openzeppelin-contracts", | ||
"OpenZeppelin/openzeppelin-contracts-upgradeable@a16f26a063cd018c4c986832c3df332a131f53b9/=./lib/openzeppelin-contracts-upgradeable", | ||
"OpenZeppelin/[email protected]/=./lib/openzeppelin-contracts", | ||
"OpenZeppelin/[email protected]/=./lib/openzeppelin-contracts-upgradeable", | ||
"paulrberg/[email protected]/=./lib/prb-math" | ||
] | ||
fs_permissions = [{ access = "read-write", path = "./build"}] | ||
extra_output_files = [ | ||
"metadata" | ||
] |
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.
Currently deploy script 10 deploys the contract and deploy script 12 sets the rewards per second. I would leave this check in since it is a sanity check and not very gas expensive one at that.
With the current code of the contract, the contract needs to be deployed and funded in the correct order, or it will not function properly. Since one can:
I think the correct functioning of the contract should be assured even if the deploy is not configured perfectly as expected. For that reason I would:
_rewardsPerSecond
from the initialize function. Any deployment of this contract will suffer the same issues on initialisation of rewards source and start of emission.setRewardsPerSecond
isn't called with a non 0 value.setRewardsPerSecond
with a 0 value. This would in effect pause the contract and remove any rewards accrued since the last collect. Is that intentional? If not change the_setRewardsPerSecond
to: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.
As of now, The deploy script initializes the proxy and implementation in the same call. So, once the proxy is initialized, it'll always have a lastCollect set and will never be zero. That's the reason I removed that check as it seemed redundant.
If the
rewardsPerSecond
isn't changed, won't previewRewards just return zero (and 0 reward collected)? Why would it revert?Agree with this, will make this change
Yep. xOGN Governance (
rewardsTarget
) is only contract that can callcollectRewards
. Also, xOGN Governance doesn't account for any rewards sent to it directly (It does a balance check before and after collectRewards to figure out the diff and uses that as reward collected). So, collecting rewards internally won't be possible when changing the rateI'm not sure if we want the ability to pause rewards in future for any reason. Let me check with @DanielVF
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.
Thanks for correcting me on first 2 points; you're right they are not an issue.
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.
I'm good with a change to rewards rate potentially changing how much users receive for the past, as well as the future. We'll probably usually couple it with a xOGN collect in most changes though.
Having a "pause" feature that stops rewards could be a useful thing.