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

Add time-lock functionality - IO1-2302 #181

Open
wants to merge 164 commits into
base: main
Choose a base branch
from
Open

Conversation

mtabasco
Copy link
Collaborator

@mtabasco mtabasco commented Feb 7, 2023

Implementation of time-locked functionality to these functions:
UpdateNetworkFee
WithdrawNetworkEarnings
UpdateLiquidationThresholdPeriod

How it works:

  1. The owner calls one of these functions with a specific parameter.
  2. For that call (function + parameter), the lock period starts (2 days, constant). The event FunctionLocked is emitted.
  3. If the owner calls the function with the same parameter before the release time, the transaction is reverted with the FunctionLocked error.
  4. Only after the 2 days period passes, the function can be executed by the owner.

There could be multiple locked executions at the same time, for example:
UpdateNetworkFee(200000000) at Tue 7 Feb, 1:40
UpdateNetworkFee(350000000)at Tue 8 Feb, 11:20
...
Every request for execution will have its own release time.

As this functionality is expected to be used by authorized accounts and consumed after scheduled, there is no implementation for deleting unused time-locked schedules.

* naming changes

* create views contract and libraries for Operator, Network, and Cluster

* update tests, refactor libraries

* deploy & upgrade test cases, upgrade scripts

* update README

* use underscore notation

* cleanup, add deploy tests
Allow to change max number of validators per operator via upgrade process
uint64 releaseTime = uint64(block.timestamp) + TIMELOCK_PERIOD;
_timelocks[fnData] = releaseTime;

emit FunctionLocked(selector, releaseTime, msg.sender);
Copy link
Collaborator Author

@mtabasco mtabasco Feb 13, 2023

Choose a reason for hiding this comment

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

msg.sender redundant

if (shrunkAmount > dao_.networkBalance(network.networkFee)) {
revert InsufficientBalance();
}
if(shrunkAmount > dao_.networkBalance(network.networkFee)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please just double check that dao_.networkBalance(network.networkFee) is returning a shrunk amount not expanded.

@liorrutenberg
Copy link

liorrutenberg commented Feb 15, 2023

@mtabasco @andrew-blox
a. we need to know based on event what type of lock was emitted
b. and to know how to parse it.-> add to readme with example - timelock.readme
c. list of all operations/functions that are bound to timelock

@mtabasco
Copy link
Collaborator Author

@mtabasco @andrew-blox a. we need to know based on event what type of lock was emitted b. and to know how to parse it.-> add to readme with example - timelock.readme c. list of all operations/functions that are bound to timelock

Done

TIMELOCK.md Outdated

## How it works

1. The contract owner calls the time-locked fucntion with the required parameters.
Copy link
Collaborator

Choose a reason for hiding this comment

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

fucntion - change to function

]

// Decode data parameters passed to updateNetworkFee call
const functionData = ssvNetwork.interface.decodeFunctionData('updateNetworkFee', decodedLog.functionData);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am prob wrong but do we need any dependencies to run this code? For example we have decodeFunctionData and i dont see any requires here other then the abi

Copy link
Collaborator Author

@mtabasco mtabasco Feb 20, 2023

Choose a reason for hiding this comment

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

no, its included with ethers library. When you instantiate a contract with ethers, you can access Interface class to interact with the ABI. More info here: Intrerface
The interface can be also instantiated passing the ABI but for this case its more easy to access this way.

I have added ethers import in the example.

* use Ownable2StepUpgradeable to support 2-step transfer
@mtabasco mtabasco changed the base branch from contract-v3 to develop March 17, 2023 13:32
@mtabasco mtabasco changed the base branch from develop to main May 16, 2023 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants