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

test: adjusting integration tests for aip1 #147

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion contracts/AutonolasTokenomics.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.25;

// Importing all the necessary Autonolas tokenomics contracts
import {DonatorBlacklist} from "../lib/autonolas-tokenomics/contracts/DonatorBlacklist.sol";
import {GenericBondCalculator} from "../lib/autonolas-tokenomics/contracts/GenericBondCalculator.sol";
import {BondCalculator} from "../lib/autonolas-tokenomics/contracts/BondCalculator.sol";
import {Depository} from "../lib/autonolas-tokenomics/contracts/Depository.sol";
import {Dispenser} from "../lib/autonolas-tokenomics/contracts/Dispenser.sol";
import {Tokenomics} from "../lib/autonolas-tokenomics/contracts/Tokenomics.sol";
Expand Down
2 changes: 1 addition & 1 deletion lib/autonolas-governance
Submodule autonolas-governance updated 30 files
+5 −0 .gitleaksignore
+5 −0 CHANGELOG.md
+39 −2 abis/0.8.25/VoteWeighting.json
+1 −0 abis/test/WormholeCore.json
+3 −1 audits/README.md
+50 −0 audits/internal13/README.md
+44 −28 contracts/VoteWeighting.sol
+7 −7 contracts/bridges/test/MockTimelock.sol
+ docs/Vulnerabilities_list_governance.pdf
+5 −0 docs/configuration.json
+2 −1 docs/olas_bridging.md
+62 −0 scripts/deployment/bridges/solana/test/polygon/deploy_00_mock_timelock.js
+1 −0 scripts/deployment/bridges/solana/test/polygon/globals.json
+54 −0 scripts/deployment/bridges/solana/test/polygon/timelock_send_message.js
+8 −0 scripts/deployment/bridges/solana/test/polygon/verify_00_mock_timelock.js
+48 −0 scripts/deployment/bridges/solana/test/sepolia/deploy_00_mock_timelock.js
+1 −0 scripts/deployment/bridges/solana/test/sepolia/globals.json
+51 −0 scripts/deployment/bridges/solana/test/sepolia/timelock_send_message.js
+60 −0 scripts/deployment/bridges/solana/test/sepolia/timelock_set_upgrade_authority.js
+64 −0 scripts/deployment/bridges/solana/test/sepolia/timelock_transfer_all.js
+66 −0 scripts/deployment/bridges/solana/test/sepolia/timelock_transfer_sol.js
+62 −0 scripts/deployment/bridges/solana/test/sepolia/timelock_transfer_token_accounts.js
+62 −0 scripts/deployment/bridges/solana/test/sepolia/timelock_upgrade_program.js
+8 −0 scripts/deployment/bridges/solana/test/sepolia/verify_00_mock_timelock.js
+62 −0 scripts/deployment/deploy_23_vote_weighting.js
+1 −1 scripts/deployment/globals_mainnet.json
+8 −0 scripts/deployment/verify_23_vote_weighting.js
+44 −0 scripts/proposals/proposal_06_buOLAS_revoke.js
+10 −2 test/VoteWeighting.js
+1 −1 test/veOLAS.js
2 changes: 1 addition & 1 deletion lib/autonolas-registries
Submodule autonolas-registries updated 48 files
+127 −0 .gitleaksignore
+11 −0 CHANGELOG.md
+4 −0 README.md
+28 −2 abis/0.8.25/StakingFactory.json
+71 −8 abis/0.8.25/StakingNativeToken.json
+71 −8 abis/0.8.25/StakingToken.json
+84 −25 abis/0.8.25/StakingVerifier.json
+3 −0 audits/README.md
+212 −0 audits/internal6/README.md
+130 −91 contracts/staking/StakingBase.sol
+60 −29 contracts/staking/StakingFactory.sol
+2 −0 contracts/staking/StakingNativeToken.sol
+124 −30 contracts/staking/StakingVerifier.sol
+25 −3 contracts/test/MockStaking.sol
+1 −3 contracts/test/ReentrancyStakingAttacker.sol
+ docs/Vulnerabilities_list_registries.pdf
+105 −0 docs/configuration.json
+1 −1 package.json
+12 −1 scripts/deployment/l2/deploy_16_service_staking_token.js
+12 −1 scripts/deployment/l2/deploy_17_service_staking_native_token.js
+0 −76 scripts/deployment/l2/deploy_18_service_staking_activity_checker.js
+19 −5 scripts/deployment/l2/deploy_18_service_staking_verifier.js
+13 −2 scripts/deployment/l2/deploy_19_service_staking_factory.js
+1 −1 scripts/deployment/l2/deploy_20_hash_checkpoint_l2.js
+0 −85 scripts/deployment/l2/deploy_21_service_staking_token_instance.js
+0 −82 scripts/deployment/l2/deploy_22_service_staking_native_token_instance.js
+1 −1 scripts/deployment/l2/globals_arbitrum_one.json
+1 −1 scripts/deployment/l2/globals_arbitrum_sepolia.json
+1 −1 scripts/deployment/l2/globals_base_mainnet.json
+1 −1 scripts/deployment/l2/globals_celo_mainnet.json
+20 −0 scripts/deployment/l2/globals_ethereum_mainnet.json
+1 −1 scripts/deployment/l2/globals_gnosis_chiado.json
+7 −26 scripts/deployment/l2/globals_gnosis_mainnet.json
+1 −1 scripts/deployment/l2/globals_optimistic_mainnet.json
+1 −1 scripts/deployment/l2/globals_optimistic_sepolia.json
+1 −1 scripts/deployment/l2/globals_polygon_amoy.json
+1 −1 scripts/deployment/l2/globals_polygon_mainnet.json
+0 −9 scripts/deployment/l2/verify_18_service_staking_activity_checker.js
+9 −3 scripts/deployment/l2/verify_18_service_staking_verifier.js
+0 −0 scripts/deployment/l2/verify_19_service_staking_factory.js
+0 −0 scripts/deployment/l2/verify_20_hash_checkpoint.js
+0 −9 scripts/deployment/l2/verify_21_service_staking_token_instance.js
+0 −9 scripts/deployment/l2/verify_22_service_staking_native_token_instance.js
+2 −2 test/ServiceRegistry.js
+244 −29 test/ServiceStaking.js
+7 −4 test/ServiceStaking.t.sol
+129 −49 test/ServiceStakingFactory.js
+65 −99 yarn.lock
2 changes: 1 addition & 1 deletion lib/autonolas-tokenomics
347 changes: 0 additions & 347 deletions test/NodeDeployment.js

This file was deleted.

16 changes: 8 additions & 8 deletions test/StakingIncentives.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { expect } = require("chai");
const helpers = require("@nomicfoundation/hardhat-network-helpers");

describe.only("StakingIncentives", async () => {
describe("StakingIncentives", async () => {
const initialMint = "1" + "0".repeat(26);
const AddressZero = ethers.constants.AddressZero;
const HashZero = ethers.constants.HashZero;
Expand Down Expand Up @@ -80,7 +80,7 @@
return ("0x" + "0".repeat(24) + account.slice(2)).toLowerCase();
}

function convertBytes32ToAddress(account) {

Check warning on line 83 in test/StakingIncentives.js

View workflow job for this annotation

GitHub Actions / build

'convertBytes32ToAddress' is defined but never used
return "0x" + account.slice(26);
}

Expand Down Expand Up @@ -129,8 +129,9 @@
[serviceParams, deployer.address, olas.address]);
// Create staking proxy instances
for (let i = 0; i < numInstances; i++) {
const stakingTokenAddress = await stakingFactory.getProxyAddress(stakingTokenImplementation.address);
await stakingFactory.createStakingInstance(stakingTokenImplementation.address, initPayload);
const tx = await stakingFactory.createStakingInstance(stakingTokenImplementation.address, initPayload);
const res = await tx.wait();
const stakingTokenAddress = "0x" + res.logs[0].topics[2].slice(26);
const stakingInstance = await ethers.getContractAt("StakingToken", stakingTokenAddress);
stakingInstances[i] = stakingInstance;
stakingInstanceAddresses[i] = stakingTokenAddress;
Expand Down Expand Up @@ -199,8 +200,7 @@

const GnosisTargetDispenserL2 = await ethers.getContractFactory("GnosisTargetDispenserL2");
gnosisTargetDispenserL2 = await GnosisTargetDispenserL2.deploy(olas.address,
stakingFactory.address, bridgeRelayer.address, gnosisDepositProcessorL1.address, chainId,
bridgeRelayer.address);
stakingFactory.address, bridgeRelayer.address, gnosisDepositProcessorL1.address, chainId);
await gnosisTargetDispenserL2.deployed();

// Set the gnosisTargetDispenserL2 address in gnosisDepositProcessorL1
Expand Down Expand Up @@ -585,9 +585,9 @@
[serviceParams, deployer.address, olas.address]);
// Create staking proxy instances
for (let i = 0; i < numInstances; i++) {
const stakingTokenAddress = await stakingFactory.getProxyAddress(stakingTokenImplementation.address);
await stakingFactory.createStakingInstance(stakingTokenImplementation.address, initPayload);
const stakingInstance = await ethers.getContractAt("StakingToken", stakingTokenAddress);
const tx = await stakingFactory.createStakingInstance(stakingTokenImplementation.address, initPayload);
const res = await tx.wait();
const stakingTokenAddress = "0x" + res.logs[0].topics[2].slice(26);
stakingInstanceAddresses[i] = stakingTokenAddress;
}

Expand Down
504 changes: 90 additions & 414 deletions test/TokenomicsLoop.js

Large diffs are not rendered by default.

83 changes: 31 additions & 52 deletions test/TokenomicsLoop.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {ServiceManager} from "../lib/autonolas-registries/contracts/ServiceManag
import {GnosisSafeMultisig} from "../lib/autonolas-registries/contracts/multisigs/GnosisSafeMultisig.sol";
import {Depository} from "../lib/autonolas-tokenomics/contracts/Depository.sol";
import {Dispenser} from "../lib/autonolas-tokenomics/contracts/Dispenser.sol";
import {GenericBondCalculator} from "../lib/autonolas-tokenomics/contracts/GenericBondCalculator.sol";
import {BondCalculator, DiscountParams} from "../lib/autonolas-tokenomics/contracts/BondCalculator.sol";
import "../lib/autonolas-tokenomics/contracts/Tokenomics.sol";
import {TokenomicsProxy} from "../lib/autonolas-tokenomics/contracts/TokenomicsProxy.sol";
import {Treasury} from "../lib/autonolas-tokenomics/contracts/Treasury.sol";
Expand All @@ -39,7 +39,7 @@ contract BaseSetup is Test {
Dispenser internal dispenser;
Treasury internal treasury;
Tokenomics internal tokenomics;
GenericBondCalculator internal genericBondCalculator;
BondCalculator internal bondCalculator;
ZuniswapV2Factory internal factory;
ZuniswapV2Router internal router;

Expand Down Expand Up @@ -183,10 +183,14 @@ contract BaseSetup is Test {

// Correct depository address is missing here, it will be defined just one line below
treasury = new Treasury(address(olas), address(tokenomics), deployer, deployer);
// Deploy generic bond calculator contract
genericBondCalculator = new GenericBondCalculator(address(olas), address(tokenomics));
// Deploy bond calculator contract
DiscountParams memory discountParams;
discountParams.targetVotingPower = 10 ether;
discountParams.targetNewUnits = 10;
bondCalculator = new BondCalculator(address(olas), address(tokenomics), address(ve), discountParams);
// Deploy depository contract
depository = new Depository(address(olas), address(tokenomics), address(treasury), address(genericBondCalculator));
depository = new Depository("Depository", "OLAS_BOND", "baseURI", address(olas), address(tokenomics),
address(treasury), address(bondCalculator));
// Deploy dispenser contract
dispenser = new Dispenser(address(olas), address(tokenomics), address(treasury), deployer, retainer, 100, 100,
100, 100);
Expand Down Expand Up @@ -294,14 +298,12 @@ contract TokenomicsLoopTest is BaseSetup {
serviceManager.deploy(serviceIds[1], address(gnosisSafeMultisig), payload);
vm.stopPrank();

// In order to get OLAS top-ups for owners of components / agents, service serviceOwner needs to lock enough veOLAS
// Note this value will be enough for about 2.5 years, after which owners will start getting zero tup-ups
vm.startPrank(serviceOwner);
// In order to get OLAS top-ups for owners of components / agents, the donator needs to lock enough veOLAS
// Note this value will be enough for about 2.5 years, after which owners will start getting zero top-ups
olas.approve(address(ve), tokenomics.veOLASThreshold() * 10);
// Set the lock duration to 4 years such that the amount of OLAS is almost the amount of veOLAS
// veOLAS = OLAS * time_locked / MAXTIME (where MAXTIME is 4 years)
ve.createLock(tokenomics.veOLASThreshold() * 10, 4 * oneYear);
vm.stopPrank();

// Set treasury reward fraction to be more than zero
tokenomics.changeIncentiveFractions(50, 25, 49, 34, 17, 0);
Expand All @@ -313,7 +315,6 @@ contract TokenomicsLoopTest is BaseSetup {
tokenomics.checkpoint();

uint256[] memory rewards = new uint256[](3);
uint256[] memory topUps = new uint256[](2);

// Run for more than 10 years (more than 52 weeks in a year)
uint256 endTime = 550 weeks;
Expand All @@ -323,7 +324,7 @@ contract TokenomicsLoopTest is BaseSetup {

// Deposit LP token for OLAS using half of the product supply considering that there will be the IDF multiplier
vm.prank(deployer);
(, , bondId) = depository.deposit(productId, supplyProductOLAS / 2);
(, , bondId) = depository.deposit(productId, supplyProductOLAS / 2, vesting);

uint256[] memory productIds = new uint256[](1);
productIds[0] = productId;
Expand Down Expand Up @@ -368,14 +369,12 @@ contract TokenomicsLoopTest is BaseSetup {
rewards[1] = (ep.totalDonationsETH * up[1].rewardUnitFraction) / 100;
rewards[2] = (ep.totalDonationsETH * ep.rewardTreasuryFraction) / 100;
uint256 accountRewards = rewards[0] + rewards[1];
// Calculate top-ups based on the points information
topUps[0] = (ep.totalTopUpsOLAS * up[0].topUpUnitFraction) / 100;
topUps[1] = (ep.totalTopUpsOLAS * up[1].topUpUnitFraction) / 100;
uint256 accountTopUps = topUps[0] + topUps[1];
// Get top-ups amount based on the inflation amount vs voting power
(uint96 totalUnitTopUps, uint96 totalDonationPower, ) = tokenomics.mapDonationPoints(lastPoint);
uint256 accountTopUps = totalDonationPower > totalUnitTopUps ? totalUnitTopUps : totalDonationPower;

// Rewards and top-ups must not be zero
// Rewards must not be zero, but top-ups could
assertGt(accountRewards, 0);
assertGt(accountTopUps, 0);
assertGt(rewards[2], 0);

// Check for the Treasury balance to correctly be reflected by ETHFromServices + ETHOwned
Expand Down Expand Up @@ -462,7 +461,7 @@ contract TokenomicsLoopTest is BaseSetup {
depository.redeem(bondIds);
}

// Check that all bond products are not closed
// Check that all bond products are now closed
productIds = depository.getProducts(true);
assertEq(productIds.length, 0);
}
Expand Down Expand Up @@ -527,14 +526,12 @@ contract TokenomicsLoopTest is BaseSetup {
}
vm.stopPrank();

// In order to get OLAS top-ups for owners of components / agents, service serviceOwner needs to lock enough veOLAS
// Note this value will be enough for about 2.5 years, after which owners will start getting zero tup-ups
vm.startPrank(serviceOwner);
// In order to get OLAS top-ups for owners of components / agents, donator needs to lock enough veOLAS
// Note this value will be enough for about 2.5 years, after which owners will start getting zero top-ups
olas.approve(address(ve), tokenomics.veOLASThreshold() * 10);
// Set the lock duration to 4 years such that the amount of OLAS is almost the amount of veOLAS
// veOLAS = OLAS * time_locked / MAXTIME (where MAXTIME is 4 years)
ve.createLock(tokenomics.veOLASThreshold() * 10, 4 * oneYear);
vm.stopPrank();

// Set treasury reward fraction to be more than zero
tokenomics.changeIncentiveFractions(40, 20, 49, 34, 17, 0);
Expand All @@ -546,7 +543,6 @@ contract TokenomicsLoopTest is BaseSetup {
tokenomics.checkpoint();

uint256[] memory rewards = new uint256[](3);
uint256[] memory topUps = new uint256[](3);

// Run for more than 10 years (more than 52 weeks in a year)
uint256 endTime = 550 weeks;
Expand Down Expand Up @@ -588,22 +584,15 @@ contract TokenomicsLoopTest is BaseSetup {
rewards[1] = (ep.totalDonationsETH * up[1].rewardUnitFraction) / 100;
rewards[2] = (ep.totalDonationsETH * ep.rewardTreasuryFraction) / 100;
uint256 accountRewards = rewards[0] + rewards[1];
// Calculate top-ups based on the points information
topUps[0] = (ep.totalTopUpsOLAS * up[0].topUpUnitFraction) / 100;
topUps[1] = (ep.totalTopUpsOLAS * up[1].topUpUnitFraction) / 100;
topUps[2] = (ep.totalTopUpsOLAS * ep.maxBondFraction) / 100;
uint256 accountTopUps = topUps[0] + topUps[1];
// Get top-ups amount based on the inflation amount vs voting power
(uint96 totalUnitTopUps, uint96 totalDonationPower, ) = tokenomics.mapDonationPoints(lastPoint);
uint256 accountTopUps = totalDonationPower > totalUnitTopUps ? totalUnitTopUps : totalDonationPower;

// Rewards and top-ups must not be zero
// Rewards must not be zero, but top-ups could
assertGt(accountRewards, 0);
assertGt(accountTopUps, 0);
assertGt(rewards[2], 0);
// maxBond must not be zero
assertGt(topUps[2], 0);
// Other epoch point values must not be zero as well
assertGt(ep.idf, 0);
assertGt(tokenomics.devsPerCapital(), 0);
assertGt(ep.endTime, 0);
assertGt((ep.totalTopUpsOLAS * ep.maxBondFraction) / 100, 0);

// Check for the Treasury balance to correctly be reflected by ETHFromServices + ETHOwned
assertEq(address(treasury).balance, treasury.ETHFromServices() + treasury.ETHOwned());
Expand Down Expand Up @@ -740,14 +729,12 @@ contract TokenomicsLoopTest is BaseSetup {
}
vm.stopPrank();

// In order to get OLAS top-ups for owners of components / agents, service serviceOwner needs to lock enough veOLAS
// Note this value will be enough for about 2.5 years, after which owners will start getting zero tup-ups
vm.startPrank(serviceOwner);
// In order to get OLAS top-ups for owners of components / agents, donator needs to lock enough veOLAS
// Note this value will be enough for about 2.5 years, after which owners will start getting zero top-ups
olas.approve(address(ve), tokenomics.veOLASThreshold() * 10);
// Set the lock duration to 4 years such that the amount of OLAS is almost the amount of veOLAS
// veOLAS = OLAS * time_locked / MAXTIME (where MAXTIME is 4 years)
ve.createLock(tokenomics.veOLASThreshold() * 10, 4 * oneYear);
vm.stopPrank();

// Set treasury reward fraction to be more than zero
tokenomics.changeIncentiveFractions(40, 20, 0, 0, 0, 0);
Expand All @@ -759,7 +746,6 @@ contract TokenomicsLoopTest is BaseSetup {
tokenomics.checkpoint();

uint256[] memory rewards = new uint256[](3);
uint256[] memory topUps = new uint256[](3);
uint256 effectiveBond = tokenomics.effectiveBond();

// Run for more than 10 years (more than 52 weeks in a year)
Expand Down Expand Up @@ -802,22 +788,15 @@ contract TokenomicsLoopTest is BaseSetup {
rewards[1] = (ep.totalDonationsETH * up[1].rewardUnitFraction) / 100;
rewards[2] = (ep.totalDonationsETH * ep.rewardTreasuryFraction) / 100;
uint256 accountRewards = rewards[0] + rewards[1];
// Calculate top-ups based on the points information
topUps[0] = (ep.totalTopUpsOLAS * up[0].topUpUnitFraction) / 100;
topUps[1] = (ep.totalTopUpsOLAS * up[1].topUpUnitFraction) / 100;
topUps[2] = (ep.totalTopUpsOLAS * ep.maxBondFraction) / 100;
uint256 accountTopUps = topUps[0] + topUps[1];
// Get top-ups amount based on the inflation amount vs voting power
(uint96 accountTopUps, uint96 totalDonationPower, ) = tokenomics.mapDonationPoints(lastPoint);
accountTopUps = totalDonationPower > accountTopUps ? accountTopUps : totalDonationPower;

// Rewards and top-ups must not be zero
// Rewards must not be zero, but top-ups could
assertGt(accountRewards, 0);
assertEq(accountTopUps, 0);
assertGt(rewards[2], 0);
// maxBond must not be zero
assertEq(topUps[2], 0);
// Other epoch point values must not be zero as well
assertGt(ep.idf, 0);
assertGt(tokenomics.devsPerCapital(), 0);
assertGt(ep.endTime, 0);
assertEq((ep.totalTopUpsOLAS * ep.maxBondFraction) / 100, 0);

// Check for the Treasury balance to correctly be reflected by ETHFromServices + ETHOwned
assertEq(address(treasury).balance, treasury.ETHFromServices() + treasury.ETHOwned());
Expand Down
Loading