-
Notifications
You must be signed in to change notification settings - Fork 177
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
[P1-N08] Converge upon single source of time for all contracts in testing environments #1236
Conversation
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
@@ -90,7 +90,7 @@ const initializeSystem = async function(callback) { | |||
}; | |||
await tokenizedDerivativeCreator.createTokenizedDerivative(defaultConstructorParams, { from: sponsor }); | |||
|
|||
const derivatives = await deployedRegistry.getRegisteredDerivatives(sponsor); | |||
const derivatives = await deployedRegistry.getRegisteredContracts(sponsor); |
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.
Outside the scope of this PR but this contract method has since been renamed.
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
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.
Looks great! A few minor comments.
@@ -63,9 +63,9 @@ abstract contract FeePayer is Testable { | |||
* @notice Constructs the FeePayer contract. Called by child contracts. | |||
* @param collateralAddress ERC20 token that is used as the underlying collateral for the synthetic. | |||
* @param finderAddress UMA protocol Finder used to discover other protocol contracts. | |||
* @param isTest whether this contract is being constructed for the purpose of running tests. | |||
* @param timerAddress Universal store of time for contracts in test environment. |
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.
nit: I would add that this parameter should be set to 0x0 for production environments, so they will fall back to block time. Here and elsewhere.
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.
Good call. Changed to:
* @param _timerAddress Contract that stores the current time in a testing environment. Should be set to 0x0 for production environments that use live time.
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.
One very tiny nit. I would change should to must.
@@ -0,0 +1,8 @@ | |||
const Timer = artifacts.require("Timer"); |
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.
Putting this here because I can't comment on a moved file.
Why move support identifiers from step 10 to step 20 rather than preserve the ordering? The only reason I suggest that we keep the ordering is that they were previously separated into DVM-related migrations (1-10), TD-related migrations (11-16), and EMP-related migrations (17-19). This was to make selective deployments a little easier, specifically, deploying the DVM without any contract creators.
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.
Ah this was a fat finger on my part. I needed to move the Timer migration earlier because its an upstream dependency for a lot of contracts, but accidentally bumped support identifiers to last. Will fix.
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.
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
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.
LGTM outside of a tiny nit on the @param
comment.
@@ -63,9 +63,9 @@ abstract contract FeePayer is Testable { | |||
* @notice Constructs the FeePayer contract. Called by child contracts. | |||
* @param collateralAddress ERC20 token that is used as the underlying collateral for the synthetic. | |||
* @param finderAddress UMA protocol Finder used to discover other protocol contracts. | |||
* @param isTest whether this contract is being constructed for the purpose of running tests. | |||
* @param timerAddress Contract that stores the current time in a testing environment. Should be set to 0x0 for production environments that use live time. |
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.
* @param timerAddress Contract that stores the current time in a testing environment. Should be set to 0x0 for production environments that use live time. | |
* @param timerAddress Contract that stores the current time in a testing environment. | |
* Should be set to 0x0 for production environments that use live time. |
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.
This string is way too long. Can we split them and try keep it below the 120 char limit?
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.
Yup I'll make this change throughout the PR
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.
This looks great! Thanks @nicholaspai, this will really make testing easier into the future. I'm happy except for a few nits on commenting. Please add the natspec to the new Testable files and ensure that the comments you've added to the other contracts are less than 120 chars in length.
Co-Authored-By: Chris Maree <christopher.maree@gmail.com>
Co-Authored-By: Chris Maree <christopher.maree@gmail.com>
Co-Authored-By: Chris Maree <christopher.maree@gmail.com>
Co-Authored-By: Chris Maree <christopher.maree@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
…ocol into testable-timing
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
Signed-off-by: Nick Pai <npai.nyc@gmail.com>
@mrice32 @chrismaree @ptare Have responde to all comments, any outstanding issues before merging? |
Resolves #1047
This PR separates the time storage in
Testable.sol
from the external methods. This contract requires a lot of down stream changes to tests and scripts because it rejects our previous assumption that eachTestable
contract maintains its own sense of time.The major change is that the input
bool isTest
intoTestable.sol
is replaced with anaddress timerAddress
. If the address is anything besides the zero address, then the contract is set to a testing environment andTestable.setCurrentTime()
can be called on the Timer contract at the input address. If the address passed in is the zero address, then the contract is considered to be in production, andTestable
will always returnnow
as thecurrentTime
.