From 651bb76bf8375e8b9b570c65384bd0ebf5934f0d Mon Sep 17 00:00:00 2001 From: Yohan Nelson Date: Wed, 25 Sep 2024 14:13:07 +0530 Subject: [PATCH] chore: 7.5 minute Epoch and Europa Testnet Contracts Released (#1011) * chore: 7.5 min epoch * chore: fix test constants for 90s state and 7.5min epoch * chore: fix test * chore: update package version --- contracts/Core/storage/Constants.sol | 2 +- deployed/europaTestnet/addresses.json | 12 ++++++++++++ package.json | 2 +- test/AssignCollectionsRandomly.js | 26 +++++++++++++------------- test/helpers/InternalEngine.js | 2 +- test/helpers/constants.js | 4 ++-- test/helpers/utils.js | 2 ++ 7 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 deployed/europaTestnet/addresses.json diff --git a/contracts/Core/storage/Constants.sol b/contracts/Core/storage/Constants.sol index 601edfd4..4a6710aa 100644 --- a/contracts/Core/storage/Constants.sol +++ b/contracts/Core/storage/Constants.sol @@ -29,7 +29,7 @@ contract Constants { uint8 public constant NUM_STATES = 5; - uint16 public constant EPOCH_LENGTH = 300; + uint16 public constant EPOCH_LENGTH = 450; // slither-disable-next-line too-many-digits address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD; diff --git a/deployed/europaTestnet/addresses.json b/deployed/europaTestnet/addresses.json new file mode 100644 index 00000000..64b66637 --- /dev/null +++ b/deployed/europaTestnet/addresses.json @@ -0,0 +1,12 @@ +{ + "Governance": "0x40c9339735D8A323240C775BAa2aA3DFf4a9068a", + "BlockManager": "0x2c44089cf0b69bB99937E18d3F68E410CDbd72D5", + "CollectionManager": "0x6565F307ADfb1c7105ECa401f600C4c352F4B65f", + "StakeManager": "0x3CD0B9650642D9D47614754f1f25b2D78821a998", + "RewardManager": "0x87da99bEB8F781f7FCC606812BA6E8c5eB46CcD5", + "VoteManager": "0x4B7d5280490BB97D78a9a733678d669c782EaFCA", + "Delegator": "0x36294b24E27AA5a1B82c9f4127CEB082fdB13a99", + "RAZOR": "0x56ea26865DF007dD16b642ecAA3E0B21DeE7Ec64", + "StakedTokenFactory": "0xEd8d85d4fDB870f07A7D92e6400AD46C2e983Bd7", + "RandomNoManager": "0x728038fb03d28866e5028da4fD3b5004fB4C36CE" +} diff --git a/package.json b/package.json index 15febdbc..97842051 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@razor-network/contracts", - "version": "2.0.2", + "version": "2.0.3", "description": "These are the contracts for Razor network v2 mainnet", "author": "Razor Network", "private": false, diff --git a/test/AssignCollectionsRandomly.js b/test/AssignCollectionsRandomly.js index 26f90786..47f961f0 100644 --- a/test/AssignCollectionsRandomly.js +++ b/test/AssignCollectionsRandomly.js @@ -55,7 +55,7 @@ describe('AssignCollectionsRandomly', function () { describe('razor', async () => { it('Assign Collections Randomly End to End Flow', async () => { - await network.provider.send('evm_setNextBlockTimestamp', [2625097600]); + await network.provider.send('evm_setNextBlockTimestamp', [2625095600]); /* /////////////////////////////////////////////////////////////// SETUP @@ -201,7 +201,7 @@ describe('AssignCollectionsRandomly', function () { await assertRevert(blockManager.connect(signers[19]).finalizeDispute(epoch, 0, collectionIndexInBlock), 'Block proposed with same medians'); // Give Sorted and FinaliseDispute on non-revealed asset - await blockManager.giveSorted(epoch, 3, [400]); + await blockManager.giveSorted(epoch, 0, [100]); collectionIndexInBlock = await getCollectionIdPositionInBlock(epoch, await blockManager.sortedProposedBlockIds(epoch, 0), signers[0], blockManager, collectionManager); await assertRevert(blockManager.finalizeDispute(epoch, 0, collectionIndexInBlock), 'Invalid dispute'); @@ -209,19 +209,20 @@ describe('AssignCollectionsRandomly', function () { // disputeForProposedCollectionIds await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 2), 'Dispute: ID present only'); await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 3), 'Dispute: ID present only'); - await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 5), 'Dispute: ID present only'); - await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 6), 'Dispute: ID present only'); + await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 4), 'Dispute: ID present only'); + await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 5), 'Dispute: ID should be absent'); + await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 6), 'Dispute: ID should be absent'); await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 7), 'Dispute: ID present only'); - await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 1), 'Dispute: ID present only'); - await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 4), 'Dispute: ID should be absent'); + await assertRevert(blockManager.disputeCollectionIdShouldBePresent(epoch, 0, 1), 'Dispute: ID should be absent'); await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 2, 0), 'Dispute: ID should be present'); await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 3, 0), 'Dispute: ID should be present'); - await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 5, 0), 'Dispute: ID should be present'); - await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 6, 0), 'Dispute: ID should be present'); + await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 4, 0), 'Dispute: ID should be present'); + await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 5, 0), 'Dispute: ID absent only'); + await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 6, 0), 'Dispute: ID absent only'); await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 7, 0), 'Dispute: ID should be present'); - await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 1, 0), 'Dispute: ID should be present'); - await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 4, 0), 'Dispute: ID absent only'); + await assertRevert(blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 1, 0), 'Dispute: ID absent only'); + // the id itself doesnt exist await assertRevert(blockManager.disputeOnOrderOfIds(epoch, 0, 1, 0), 'index1 not greater than index0 0'); await assertRevert(blockManager.disputeOnOrderOfIds(epoch, 0, 0, 1), 'ID at i0 not gt than of i1'); @@ -295,11 +296,10 @@ describe('AssignCollectionsRandomly', function () { await restoreSnapshot(snapshotId); snapshotId = await takeSnapshot(); // additional 2 - await adhocPropose(signers[1], [1, 2, 4, 5, 6, 7], [100, 200, 400, 500, 600, 700], stakeManager, blockManager, voteManager); + await adhocPropose(signers[1], [1, 2, 8, 5, 6, 7], [100, 200, 800, 500, 600, 700], stakeManager, blockManager, voteManager); await mineToNextState(); const epoch = await getEpoch(); - - await blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 4, 2); + await blockManager.disputeCollectionIdShouldBeAbsent(epoch, 0, 8, 2); const blockIndexToBeConfirmed = await blockManager.blockIndexToBeConfirmed(); const block = await blockManager.getProposedBlock(epoch, 0); expect(blockIndexToBeConfirmed).to.eq(-1); diff --git a/test/helpers/InternalEngine.js b/test/helpers/InternalEngine.js index 041fb08f..de193999 100644 --- a/test/helpers/InternalEngine.js +++ b/test/helpers/InternalEngine.js @@ -224,7 +224,7 @@ const proposeWithDeviation = async (signer, deviation, stakeManager, blockManage } } } - // console.log('propose', idsRevealedThisEpoch, mediansValues); + await blockManager.connect(signer).propose(epoch, idsRevealedThisEpoch, mediansValues, diff --git a/test/helpers/constants.js b/test/helpers/constants.js index dc6d63cd..91f88ae4 100644 --- a/test/helpers/constants.js +++ b/test/helpers/constants.js @@ -3,11 +3,11 @@ const { BigNumber } = ethers; const DEFAULT_ADMIN_ROLE_HASH = '0x0000000000000000000000000000000000000000000000000000000000000000'; const ONE_ETHER = BigNumber.from(10).pow(BigNumber.from(18)); -const EPOCH_LENGTH = BigNumber.from(300); +const EPOCH_LENGTH = BigNumber.from(450); const BASE_DENOMINATOR = BigNumber.from(10000000); const NUM_BLOCKS = 10; const NUM_STATES = BigNumber.from(5); -const STATE_LENGTH = BigNumber.from(60); +const STATE_LENGTH = BigNumber.from(90); const GRACE_PERIOD = 0; const UNSTAKE_LOCK_PERIOD = 1; const WITHDRAW_LOCK_PERIOD = 1; diff --git a/test/helpers/utils.js b/test/helpers/utils.js index 6adcecab..3314130e 100644 --- a/test/helpers/utils.js +++ b/test/helpers/utils.js @@ -47,6 +47,7 @@ const calculateDisputesData = async (collectionId, voteManager, stakeManager, ep median = sortedValues[i]; } } + return { median, totalInfluenceRevealed, sortedValues, }; @@ -295,6 +296,7 @@ const adhocPropose = async (signer, ids, medians, stakeManager, blockManager, vo const staker = await stakeManager.getStaker(stakerID); const { biggestStake, biggestStakerId } = await getBiggestStakeAndId(stakeManager, voteManager); (stakeManager); const iteration = await getIteration(voteManager, stakeManager, staker, biggestStake); + await blockManager.connect(signer).propose(getEpoch(), ids, medians,