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
Changes from 1 commit
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
786b766
v3 core experements
Aug 8, 2022
29830c5
replace owner earns logic by operator
Aug 8, 2022
cdc607f
turn off optimizer
Aug 8, 2022
455abfa
wip optimisation
Aug 8, 2022
6977457
WIP updateValidator
Aug 8, 2022
0367a16
remove & update & tests
Aug 10, 2022
4f78290
fix tests
Aug 10, 2022
b90da20
wip improve tests
Aug 10, 2022
cc06aaa
wip
Aug 10, 2022
ab0f45d
wip
Aug 10, 2022
b85dbbf
wip logic math
Aug 14, 2022
af69417
wip logic math
Aug 15, 2022
ba67f75
mixed up values IO1-990
Aug 15, 2022
025cca2
update tests
Aug 15, 2022
f854a34
logs improvements, fix math issues
Aug 16, 2022
c8a784f
extend logs
Aug 16, 2022
f888cfd
update validator etc
Aug 17, 2022
78663ed
gas issues, validatorpk, extended operator logic
Aug 21, 2022
b4c7164
update encrypted and shares keys logic
Aug 21, 2022
c9141d2
fix group balance
Aug 21, 2022
7475309
tmp
Aug 21, 2022
786d50a
Revert "fix group balance"
Aug 21, 2022
7d4904c
fix tests
Aug 21, 2022
2a209ce
push stress test
Aug 21, 2022
518f7cc
mapping for transfer
Aug 22, 2022
5a856a5
fixed to correct events
Aug 23, 2022
7a3c9bf
wip cleanup the code
Aug 23, 2022
f1d5a1d
transfer tests #1
adamzigdon Aug 23, 2022
7048499
Merge remote-tracking branch 'origin/logic-refactoring' into transfer…
adamzigdon Aug 23, 2022
0fd9085
small code fixes
Aug 24, 2022
ffa038e
add balanceOf
Aug 24, 2022
0c3c3d7
remove test functions
Aug 24, 2022
90eb1c9
integrated compressed shares
Aug 24, 2022
fa9dbe5
Merge branch 'logic-refactoring' of github.com:bloxapp/ssv-network in…
Aug 24, 2022
a7aef9f
update testing structure (#85)
andrew-blox Aug 24, 2022
6c2356c
fixed vadim test
Aug 24, 2022
bafb7a0
clean contract tests
Aug 25, 2022
9ae41d5
changed collection name to cluster
Aug 25, 2022
53a44de
changed group name to pod
Aug 25, 2022
59180dd
Merge pull request #87 from bloxapp/cluster-pod-names
Aug 25, 2022
59b8561
Merge branch 'contract-v3' into Andrew--clean-tests--IO1-1664
adamzigdon Aug 25, 2022
bc22cc7
Merge pull request #86 from bloxapp/Andrew--clean-tests--IO1-1664
adamzigdon Aug 25, 2022
eeabaf7
init interface with supported events
Aug 25, 2022
8a35d66
interface with supported functions
Aug 25, 2022
3e493f1
Merge pull request #88 from bloxapp/contract-interface
Aug 25, 2022
b8b16bd
add gas usage tracking
adamzigdon Aug 25, 2022
6a1d5ed
eslint fixes, runTx, changed validators tests
Aug 30, 2022
5947e13
runTx -> trackGas + fix tests
Aug 31, 2022
cd1bd4b
fix tests, extend validators tests
Aug 31, 2022
5655ca8
improvements and remove validator
Aug 31, 2022
7fa7206
fix tests
Aug 31, 2022
1e73ff4
misspel fix
Aug 31, 2022
24f68c6
adding GasGroup enum
adamzigdon Aug 31, 2022
03024f8
Merge branch 'tests-scnearios' of github.com:bloxapp/ssv-network into…
adamzigdon Aug 31, 2022
8acb640
fix trackgas output
Sep 1, 2022
03fc0d8
rename eraningins to snapshot + gas improvment
Sep 1, 2022
067e558
operatorSnapshot to interface
Sep 1, 2022
22a3076
Merge pull request #91 from bloxapp/operator-snapshot
Sep 1, 2022
f04e4fc
wip errors
Sep 1, 2022
7960903
Merge remote-tracking branch 'origin/contract-v3' into tests-scnearios
adamzigdon Sep 1, 2022
af0317e
refactor helpers
adamzigdon Sep 1, 2022
0a81d8b
comment out some files
adamzigdon Sep 1, 2022
2619cb0
change to chai
adamzigdon Sep 1, 2022
a04ad3e
finilise validator tests with changed infrastructure
Sep 4, 2022
8984813
fix lint issues
Sep 4, 2022
a6074c6
extend register validator test
Sep 6, 2022
03e21ed
extend tests by new cases
Sep 6, 2022
aa77dbf
Merge pull request #90 from bloxapp/tests-scnearios
Sep 7, 2022
46cfa62
Tests operator register--IO1-1740 (#92)
vadiminc Sep 12, 2022
698bad8
Tests operator remove--IO1-1741 (#93)
vadiminc Sep 12, 2022
9ea025b
enable optimzier and update gas limits
Sep 12, 2022
64d1fc5
Merge branch 'contract-v3' of github.com:bloxapp/ssv-network into con…
Sep 12, 2022
c37fa61
adding validator testing
Sep 12, 2022
4237af6
update validator tests
Sep 13, 2022
6a1e50c
Update solidity code
Sep 13, 2022
a196942
add bulk transfer tests
Sep 13, 2022
5aa1720
update remove testing
Sep 14, 2022
1748cf5
some changes
adamzigdon Sep 14, 2022
b2bdc95
update terminology
Sep 14, 2022
0d30b8c
update helper from cluster to pod emit
Sep 14, 2022
d263d2f
small updates to tests
Sep 14, 2022
9a45178
more changes
adamzigdon Sep 15, 2022
7bbb123
Merge branch 'Andrew--adding-validator-testing--IO1-1753' of github.c…
adamzigdon Sep 15, 2022
afa638c
Update tests
Sep 15, 2022
30917d3
fixes
adamzigdon Sep 15, 2022
a8025b6
Finalize validator tests
Sep 15, 2022
0899f77
Add transfer helpers
Sep 15, 2022
3943abb
Register with 7 operator fix
Sep 15, 2022
a34764f
Merge pull request #100 from bloxapp/Andrew--adding-validator-testing…
Sep 18, 2022
a344ff9
Operator fee timelocks (#98)
vadiminc Sep 22, 2022
31a1553
network fee core changes (#103)
vadiminc Oct 6, 2022
32e3112
Liquidate function (#105)
vadiminc Oct 23, 2022
1ca7afd
core logic with improvements (#107)
vadiminc Oct 26, 2022
44401fa
fix merge conflicts with v3
Oct 26, 2022
0f7d3ce
add liquidate gas limit
Oct 26, 2022
9c063d9
code improvements based by pr review
Oct 27, 2022
3d6fda0
code improvements based by pr review
Oct 27, 2022
2c722e4
proposal for registerpod flow
Oct 27, 2022
e1771d2
remove operator simplified
Oct 27, 2022
cb776c2
maxAllowedFee simplified
Oct 27, 2022
51e77d7
improve and fix tests
Oct 27, 2022
12e6c6b
on register validator make sure all the operators exist
Oct 27, 2022
9e530d6
Merge branch 'contract-v3-temp' of github.com:bloxapp/ssv-network int…
Oct 27, 2022
4f45122
on remove validator make sure all the operators exist
Oct 27, 2022
49839c0
Merge branch 'contract-v3-temp' of github.com:bloxapp/ssv-network int…
Oct 27, 2022
149813f
small validation improvment
Oct 27, 2022
40862ac
rename operators update on transfer function
Oct 27, 2022
1670eb9
remove private dao functions
Oct 27, 2022
cb0be42
fix tests
adamzigdon Oct 27, 2022
b7e310d
Merge pull request #106 from bloxapp/contract-v3-temp
adamzigdon Oct 27, 2022
3030335
core balances logic includes reactivation (#108)
vadiminc Nov 10, 2022
eb682fe
core and tests changes for register validator (#112)
vadiminc Nov 14, 2022
47c00d1
remove operator with withdraw (#117)
vadiminc Nov 15, 2022
cd8330d
Or-update liquidate test names
Or-blox Nov 29, 2022
94ab6fa
Or- update validator test names
Or-blox Nov 29, 2022
68e4de9
Or-Changes in test names
Or-blox Nov 29, 2022
72afcf3
Poc validator bytes (#132)
vadiminc Dec 20, 2022
db119e6
Or deposit tests (#135)
Or-blox Dec 20, 2022
66a1756
fee recipient logic (#134)
vadiminc Dec 21, 2022
94f13a4
Or withdraw tests (#136)
Or-blox Dec 21, 2022
e8a1f8f
operator removal logic (#151)
vadiminc Dec 28, 2022
939c45a
Get DAO functions + pod burn rate (#153)
vadiminc Dec 28, 2022
5e39c4e
Revert "Get DAO functions + pod burn rate (#153)" (#154)
vadiminc Dec 28, 2022
5752a44
Missed get functions (#155)
vadiminc Dec 29, 2022
4393503
Remove podMetadataUpdated IO1 2182
andrew-blox Jan 2, 2023
c655580
Add validator gas test io1-2187
andrew-blox Jan 2, 2023
6545896
apply rules, upgrade solhint
mtabasco Jan 3, 2023
b43dd3a
list of gas optz changes IO1-1433 (#160)
vadiminc Jan 4, 2023
220a964
sync with contract-v3
mtabasco Jan 4, 2023
ecdbedd
Merge pull request #161 from bloxapp/solhint-rules
mtabasco Jan 5, 2023
ebcc4d0
Extra names (#163)
vadiminc Jan 10, 2023
187b3f2
add OperatorFeeDeclared, ValidatorDoesNotExist (#166)
mtabasco Jan 12, 2023
bdb60f6
UUPS proxy implementation (#167)
mtabasco Jan 12, 2023
92c0c38
naming changes
mtabasco Jan 17, 2023
57dbfac
Real RSA data
andrew-blox Jan 18, 2023
e9f3b36
naming changes (#169)
mtabasco Jan 18, 2023
2536f2e
Merge branch 'contract-v3' of https://github.com/bloxapp/ssv-network …
mtabasco Jan 20, 2023
6a069ee
IO1-2358-index-events (#175)
vadiminc Jan 25, 2023
a9bc0dc
Final names (#174)
Or-blox Jan 26, 2023
2ead029
Merge branch 'contract-v3' of https://github.com/bloxapp/ssv-network …
mtabasco Jan 27, 2023
7b7026e
isTimeLocked function + initial tests
mtabasco Feb 3, 2023
cd67697
add sanity tests
mtabasco Feb 5, 2023
2ba206c
withdrawNetworkEarnings time-locked functionality
mtabasco Feb 6, 2023
11a55df
updateLiquidationThresholdPeriod time-locked
mtabasco Feb 7, 2023
4ca30b7
delete locked period of functions after execution
mtabasco Feb 7, 2023
fad1ed5
Change contracts structure - IO1-2233 (#176)
mtabasco Feb 8, 2023
f789a00
Merge branch 'contract-v3' of https://github.com/bloxapp/ssv-network …
mtabasco Feb 9, 2023
da229c4
Add slither to CI pipeline - IO1-2233 (#177)
mtabasco Feb 9, 2023
e8d9b16
Merge branch 'contract-v3' of https://github.com/bloxapp/ssv-network …
mtabasco Feb 9, 2023
8a92030
Limit max # validators per operator - IO1-2160 (#178)
mtabasco Feb 9, 2023
132d2af
Merge branch 'contract-v3' of https://github.com/bloxapp/ssv-network …
mtabasco Feb 9, 2023
5ddba74
tagging process before deployment and upgrade
mtabasco Feb 10, 2023
03a6bb7
sync with contract-v3
mtabasco Feb 10, 2023
a041f6c
Revert "tagging process before deployment and upgrade"
mtabasco Feb 13, 2023
1ebd665
remove locker account from FunctionLocked event
mtabasco Feb 13, 2023
4c4a9dc
emit uint256 cluster balance
mtabasco Feb 15, 2023
7d368ec
Versioned contract - IO1-1818 (#179)
mtabasco Feb 15, 2023
60b0208
Merge branch 'contract-v3' of https://github.com/bloxapp/ssv-network …
mtabasco Feb 15, 2023
82ad2c4
Merge branch 'contract-v3' into time-lock-functions
mtabasco Feb 16, 2023
7c3f0a0
change id name
mtabasco Feb 16, 2023
98996d3
emit parameter data in FunctionLocked event, add TIMELOCK readme
mtabasco Feb 17, 2023
f46b580
TIMELOCK.md updated
mtabasco Feb 20, 2023
5a0bb1b
2 step transfer ownership - IO1-434 (#180)
mtabasco Feb 21, 2023
88b5545
merge contract-v3
Feb 21, 2023
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
Prev Previous commit
Next Next commit
Update tests
  • Loading branch information
AndrewBlox committed Sep 15, 2022
commit afa638c06960d7b9e532846ccd253838bbedca21
4 changes: 4 additions & 0 deletions test/helpers/gas-usage.ts
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@ export enum GasGroup {
TRANSFER_VALIDATOR_NEW_CLUSTER,
TRANSFER_VALIDATOR,
TRANSFER_VALIDATOR_NON_EXISTING_POD,
BULK_TRANSFER_VALIDATOR,
BULK_TRANSFER_VALIDATOR_NON_EXISTING_POD,
}

const MAX_GAS_PER_GROUP: any = {
@@ -22,6 +24,8 @@ const MAX_GAS_PER_GROUP: any = {
[GasGroup.TRANSFER_VALIDATOR_NEW_CLUSTER]: 400000,
[GasGroup.TRANSFER_VALIDATOR]: 260000,
[GasGroup.TRANSFER_VALIDATOR_NON_EXISTING_POD]: 290000,
[GasGroup.BULK_TRANSFER_VALIDATOR]: 340000,
[GasGroup.BULK_TRANSFER_VALIDATOR_NON_EXISTING_POD]: 340000,
};

class GasStats {
39 changes: 23 additions & 16 deletions test/validators/transfer-bulk.ts
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ describe('Bulk Transfer Validator Tests', () => {

// Register operators
await helpers.registerOperators(0, 12, '10');
await helpers.registerOperators(0, 1, '1000000');

// Deposit into accounts
await helpers.deposit([4], ['1000000']);
@@ -63,18 +64,16 @@ describe('Bulk Transfer Validator Tests', () => {
)).to.be.revertedWith('ValidatorNotOwned');
});

// NEED TO MAKE NEW GAS GROUP FOR BULK TRANSFER
it('Bulk transfer 10 validators', async () => {
await trackGas(ssvNetworkContract.connect(helpers.DB.owners[4]).bulkTransferValidators(
[clusterResult1.validators[0].publicKey, ...clusterResult2.validators.map((validator: any) => validator.publicKey)],
clusterResult1.clusterId,
clusterResult3.clusterId,
Array(clusterResult2.validators.length + 1).fill(helpers.DataGenerator.shares(0)),
'10000'
), [GasGroup.REGISTER_VALIDATOR_EXISTING_CLUSTER]);
), [GasGroup.BULK_TRANSFER_VALIDATOR]);
});

// NEED TO MAKE NEW GAS GROUP FOR BULK TRANSFER
it('Bulk transfer 10 validators to a cluster with 7 operators', async () => {
// Register validator with 7 operators
const { clusterId } = await helpers.registerValidators(4, 1, '90000', [1, 2, 3, 4, 5, 6, 7]);
@@ -86,10 +85,9 @@ describe('Bulk Transfer Validator Tests', () => {
clusterId,
Array(clusterResult2.validators.length + 1).fill(helpers.DataGenerator.shares(0)),
'10000'
), [GasGroup.REGISTER_VALIDATOR_EXISTING_CLUSTER]);
), [GasGroup.BULK_TRANSFER_VALIDATOR_NON_EXISTING_POD]);
});

// IMPOSSIBLE TO DO WITHOUT AMOUNT PARAM
it('Bulk transfer 10 validators to cluster created by other owner', async () => {
// Register validator with 7 operators
const { clusterId } = await helpers.registerValidators(5, 1, '90000', helpers.DataGenerator.cluster.new(), [GasGroup.REGISTER_VALIDATOR_NEW_STATE]);
@@ -100,10 +98,9 @@ describe('Bulk Transfer Validator Tests', () => {
clusterId,
Array(clusterResult2.validators.length + 1).fill(helpers.DataGenerator.shares(0)),
'100000'
), [GasGroup.REGISTER_VALIDATOR_EXISTING_CLUSTER]);
), [GasGroup.BULK_TRANSFER_VALIDATOR_NON_EXISTING_POD]);
});

// SHOULD GIVE ERROR OF MAYBE INVALID FROM cluster
it('Bulk transfer 10 validators to an invalid cluster', async () => {
await expect(ssvNetworkContract.connect(helpers.DB.owners[4]).bulkTransferValidators(
[clusterResult1.validators[0].publicKey, ...clusterResult2.validators.map((validator: any) => validator.publicKey)],
@@ -114,7 +111,6 @@ describe('Bulk Transfer Validator Tests', () => {
)).to.be.revertedWith('InvalidCluster');
});

// SHOULD GIVE ERROR OF MAYBE VALIDATOR SHARE MISMATCH
it('Validator and share length mismatch', async () => {
// 10 validators and 11 shares
await expect(ssvNetworkContract.connect(helpers.DB.owners[4]).bulkTransferValidators(
@@ -135,13 +131,24 @@ describe('Bulk Transfer Validator Tests', () => {
)).to.be.revertedWith('ParametersMismatch');
});

// // NEED TO IMPLEMENT AN AMOUNT
// it('Transfer validator with not enough amount', async () => {

// });

// // NEED TO IMPLEMENT AN AMOUNT
// it('Transfer validator with not enough balance', async () => {
it('Bulk transfer validator with not enough amount', async () => {
const { clusterId } = await helpers.registerValidators(5, 1, '90000', [10, 11, 12, 13], [GasGroup.REGISTER_VALIDATOR_NEW_STATE]);
await expect(ssvNetworkContract.connect(helpers.DB.owners[4]).bulkTransferValidators(
[clusterResult1.validators[0].publicKey, ...clusterResult2.validators.map((validator: any) => validator.publicKey)],
clusterResult1.clusterId,
clusterId,
Array(clusterResult2.validators.length + 1).fill(helpers.DataGenerator.shares(0)),
'1'
)).to.be.revertedWith('AccountLiquidatable');
});

// });
it('Bulk transfer validator with not enough balance', async () => {
await expect(ssvNetworkContract.connect(helpers.DB.owners[4]).bulkTransferValidators(
[clusterResult1.validators[0].publicKey, ...clusterResult2.validators.map((validator: any) => validator.publicKey)],
clusterResult1.clusterId,
clusterResult3.clusterId,
Array(clusterResult2.validators.length + 1).fill(helpers.DataGenerator.shares(0)),
'10000000'
)).to.be.revertedWith('NotEnoughDeposited');
});
});
46 changes: 24 additions & 22 deletions test/validators/transfer.ts
Original file line number Diff line number Diff line change
@@ -42,27 +42,6 @@ describe('Transfer Validator Tests', () => {
expect(clusterResult1.clusterId).not.equals(transferedValidator.eventsByName.ValidatorTransferred[0].args.clusterId);
});

it('Transfer validator to an existing pod', async () => {
const transfredValidator1 = await trackGas(ssvNetworkContract.connect(helpers.DB.owners[4]).transferValidator(
clusterResult1.validators[0].publicKey,
helpers.DataGenerator.cluster.byId(clusterResult2.clusterId),
helpers.DataGenerator.shares(helpers.DB.validators.length),
'10000'
), [GasGroup.REGISTER_VALIDATOR_EXISTING_CLUSTER]);
expect(clusterResult2.clusterId).equals(transfredValidator1.eventsByName.ValidatorTransferred[0].args.clusterId);
});

it('Transfer validator to an existing cluster', async () => {
const clusterResult3 = await helpers.registerValidators(5, 1, '10000', helpers.DataGenerator.cluster.new(), [GasGroup.REGISTER_VALIDATOR_NEW_STATE]);
const transfredValidator1 = await trackGas(ssvNetworkContract.connect(helpers.DB.owners[4]).transferValidator(
clusterResult1.validators[0].publicKey,
helpers.DataGenerator.cluster.byId(clusterResult3.clusterId),
helpers.DataGenerator.shares(helpers.DB.validators.length),
'10000'
), [GasGroup.REGISTER_VALIDATOR_EXISTING_CLUSTER]);
expect(clusterResult2.clusterId).equals(transfredValidator1.eventsByName.ValidatorTransferred[0].args.clusterId);
});

it('Transfer validator with an invalid owner', async () => {
// Transfer validator with an invalid owner
await expect(ssvNetworkContract.connect(helpers.DB.owners[5]).transferValidator(
@@ -94,6 +73,29 @@ describe('Transfer Validator Tests', () => {
)).to.emit(ssvNetworkContract, 'ValidatorTransferred');
});

// GOING ABOVE GAS LIMIT
it('Transfer validator to an existing pod', async () => {
const transfredValidator1 = await trackGas(ssvNetworkContract.connect(helpers.DB.owners[4]).transferValidator(
clusterResult1.validators[0].publicKey,
helpers.DataGenerator.cluster.byId(clusterResult2.clusterId),
helpers.DataGenerator.shares(helpers.DB.validators.length),
'10000'
), [GasGroup.REGISTER_VALIDATOR_EXISTING_POD]);
expect(clusterResult2.clusterId).equals(transfredValidator1.eventsByName.ValidatorTransferred[0].args.podId);
});

// GOING ABOVE GAS LIMIT
it('Transfer validator to an existing cluster', async () => {
const clusterResult3 = await helpers.registerValidators(5, 1, '10000', helpers.DataGenerator.cluster.new(), [GasGroup.REGISTER_VALIDATOR_NEW_STATE]);
const transfredValidator1 = await trackGas(ssvNetworkContract.connect(helpers.DB.owners[4]).transferValidator(
clusterResult1.validators[0].publicKey,
helpers.DataGenerator.cluster.byId(clusterResult3.clusterId),
helpers.DataGenerator.shares(helpers.DB.validators.length),
'10000'
), [GasGroup.REGISTER_VALIDATOR_EXISTING_CLUSTER]);
expect(clusterResult2.clusterId).equals(transfredValidator1.eventsByName.ValidatorTransferred[0].args.podId);
});

// THIS NEEDS SOME PROPER ERROR MESSAGE
it('Transfer validator with not enough amount', async () => {
// Register validator
@@ -127,7 +129,7 @@ describe('Transfer Validator Tests', () => {
clusterResult1.validators[0].publicKey,
helpers.DataGenerator.cluster.byId(clusterResult2.clusterId),
helpers.DataGenerator.shares(helpers.DB.validators.length),
'100001'
'1000001'
)).to.be.revertedWith('NotEnoughBalance');
});