Skip to content

Commit

Permalink
limit commit root timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
ququzone committed Feb 3, 2024
1 parent 3ee2334 commit eb02d7a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contracts/VotingEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ contract VotingEscrow is IVotingEscrow, ReentrancyGuardUpgradeable {

/// @inheritdoc IVotingEscrow
function commitNativeRoots(uint256 _timestamp, bytes32[] memory _pendingRoots) external {
if (_timestamp < nativeSnapshotTime) revert InvalidTimestamp();
if (_timestamp < nativeSnapshotTime || _timestamp > block.timestamp) revert InvalidTimestamp();
if (msg.sender != team) revert NotTeam();
for (uint256 i = 0; i < _pendingRoots.length; i++) {
if (bytes32(0) == _pendingRoots[i]) revert InvalidRoot();
Expand Down
2 changes: 1 addition & 1 deletion src/types/factories/contracts/VotingEscrow__factory.ts

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion test/VotingEscrow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('VotingEscrow', function () {
let node1: string;
let node2: string;

before(function () {
before(async function () {
now = Math.floor(new Date().getTime() / 1000);

node1 = ethers.keccak256(
Expand All @@ -54,6 +54,7 @@ describe('VotingEscrow', function () {
});

it('create native ve', async function () {
await ethers.provider.send("evm_mine");
await expect(ve.connect(accounts[1]).commitNativeRoots(now, [root])).to.be.revertedWithCustomError(ve, 'NotTeam');
await ve.connect(accounts[0]).commitNativeRoots(now, [root]);
await ve.connect(accounts[0]).approveNativeRoots();
Expand Down

0 comments on commit eb02d7a

Please sign in to comment.