Skip to content

Commit

Permalink
chore: 7.5 minute Epoch and Europa Testnet Contracts Released (#1011)
Browse files Browse the repository at this point in the history
* chore: 7.5 min epoch

* chore: fix test constants for 90s state and 7.5min epoch

* chore: fix test

* chore: update package version
  • Loading branch information
yohanelly95 authored Sep 25, 2024
1 parent 258cf2d commit 651bb76
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 18 deletions.
2 changes: 1 addition & 1 deletion contracts/Core/storage/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions deployed/europaTestnet/addresses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Governance": "0x40c9339735D8A323240C775BAa2aA3DFf4a9068a",
"BlockManager": "0x2c44089cf0b69bB99937E18d3F68E410CDbd72D5",
"CollectionManager": "0x6565F307ADfb1c7105ECa401f600C4c352F4B65f",
"StakeManager": "0x3CD0B9650642D9D47614754f1f25b2D78821a998",
"RewardManager": "0x87da99bEB8F781f7FCC606812BA6E8c5eB46CcD5",
"VoteManager": "0x4B7d5280490BB97D78a9a733678d669c782EaFCA",
"Delegator": "0x36294b24E27AA5a1B82c9f4127CEB082fdB13a99",
"RAZOR": "0x56ea26865DF007dD16b642ecAA3E0B21DeE7Ec64",
"StakedTokenFactory": "0xEd8d85d4fDB870f07A7D92e6400AD46C2e983Bd7",
"RandomNoManager": "0x728038fb03d28866e5028da4fD3b5004fB4C36CE"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
26 changes: 13 additions & 13 deletions test/AssignCollectionsRandomly.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -201,27 +201,28 @@ 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');

// 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');
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/InternalEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const proposeWithDeviation = async (signer, deviation, stakeManager, blockManage
}
}
}
// console.log('propose', idsRevealedThisEpoch, mediansValues);

await blockManager.connect(signer).propose(epoch,
idsRevealedThisEpoch,
mediansValues,
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions test/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const calculateDisputesData = async (collectionId, voteManager, stakeManager, ep
median = sortedValues[i];
}
}

return {
median, totalInfluenceRevealed, sortedValues,
};
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 651bb76

Please sign in to comment.