From 2b3ed8dd5e0f8fc1a615b9b49fc435105464686a Mon Sep 17 00:00:00 2001 From: mzxyz <8177474+mzxyz@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:08:48 +1300 Subject: [PATCH] Support swap booster deployment (#387) * Support `swapBoosterDeployment` * Code format * Add test * Update contract changes * Incease `gasLimit` to fix contract deployment issue * Update test * Fix test * Reuse add and remove boosterDeployment --- contracts/RewardsBooster.sol | 116 ++++++++++++++----- publish/ABI/RewardsBooster.json | 30 ++++- publish/revertcode.json | 2 + scripts/config/contracts.config.ts | 8 +- scripts/config/mainnet.config.ts | 18 +-- scripts/deployContracts.ts | 2 +- scripts/startup.ts | 8 +- scripts/verify.ts | 9 +- src/rootSdk.ts | 11 +- test/RewardsBooster.test.ts | 77 ++++++++++--- test/fixtures/rpc_projects.yaml | 176 ++++++++++++++--------------- test/fixtures/settings.yaml | 16 +-- 12 files changed, 302 insertions(+), 171 deletions(-) diff --git a/contracts/RewardsBooster.sol b/contracts/RewardsBooster.sol index 5ff788e6..50c9e0cf 100644 --- a/contracts/RewardsBooster.sol +++ b/contracts/RewardsBooster.sol @@ -15,6 +15,7 @@ import './interfaces/IEraManager.sol'; import './interfaces/IStakingAllocation.sol'; import './interfaces/IStakingManager.sol'; import './interfaces/IIndexerRegistry.sol'; +import './interfaces/IConsumerRegistry.sol'; import './interfaces/ISettings.sol'; import './interfaces/ISQToken.sol'; import './interfaces/IRewardsDistributor.sol'; @@ -162,50 +163,74 @@ contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster { } /** - * @notice add booster deployment staking modify eraPool and deployment map - * @param _deploymentId the deployment id - * @param _amount the added amount + * @notice + * @param deploymentId project deployment id */ - function boostDeployment(bytes32 _deploymentId, uint256 _amount) external { + modifier onlyRegisteredDeployment(bytes32 deploymentId) { require( IProjectRegistry(settings.getContractAddress(SQContracts.ProjectRegistry)) - .isDeploymentRegistered(_deploymentId), + .isDeploymentRegistered(deploymentId), 'RB008' ); + _; + } - address boosterAccount = msg.sender; - DeploymentPool storage deploymentPool = deploymentPools[_deploymentId]; - onDeploymentBoosterUpdate(_deploymentId, boosterAccount); - deploymentPool.boosterPoint += _amount; - deploymentPool.accountBooster[boosterAccount] += _amount; - deploymentPool.accRewardsPerBooster = accRewardsPerBooster; - totalBoosterPoint += _amount; - + /** + * @notice add booster deployment staking modify eraPool and deployment map + * @param _deploymentId the deployment id + * @param _amount the added amount + */ + function boostDeployment( + bytes32 _deploymentId, + uint256 _amount + ) external onlyRegisteredDeployment(_deploymentId) { + _addBoosterDeployment(_deploymentId, msg.sender, _amount); IERC20(settings.getContractAddress(SQContracts.SQToken)).safeTransferFrom( - boosterAccount, + msg.sender, address(this), _amount ); - emit DeploymentBoosterAdded(_deploymentId, boosterAccount, _amount); } /** * @notice remove booster from deployment - * @param deployment deploymentId + * @param deploymentId deploymentId * @param amount the added amount */ - function removeBoosterDeployment(bytes32 deployment, uint256 amount) external { - DeploymentPool storage deploymentPool = deploymentPools[deployment]; - require(deploymentPool.accountBooster[msg.sender] >= amount, 'RB003'); + function removeBoosterDeployment( + bytes32 deploymentId, + uint256 amount + ) external { + require(deploymentPools[deploymentId].accountBooster[msg.sender] >= amount, 'RB003'); + _removeBoosterDeployment(deploymentId, msg.sender, amount); + IERC20(settings.getContractAddress(SQContracts.SQToken)).safeTransfer(msg.sender, amount); + } - onDeploymentBoosterUpdate(deployment, msg.sender); - deploymentPool.boosterPoint -= amount; - deploymentPool.accountBooster[msg.sender] -= amount; - deploymentPool.accRewardsPerBooster = accRewardsPerBooster; - totalBoosterPoint -= amount; + /** + * @notice swap booster from one deployment to another + * @param account the account booster the deployments + * @param from from deploymentId + * @param to to deploymentId + * @param amount the amount to swap + */ + function swapBoosterDeployment( + address account, + bytes32 from, + bytes32 to, + uint256 amount + ) external onlyRegisteredDeployment(to) { + require(from != to, 'RB013'); + if (account != msg.sender) { + require( + IConsumerRegistry(settings.getContractAddress(SQContracts.ConsumerRegistry)) + .isController(account, msg.sender), + 'RB014' + ); + } - IERC20(settings.getContractAddress(SQContracts.SQToken)).safeTransfer(msg.sender, amount); - emit DeploymentBoosterRemoved(deployment, msg.sender, amount); + require(deploymentPools[from].accountBooster[account] >= amount, 'RB003'); + _removeBoosterDeployment(from, account, amount); + _addBoosterDeployment(to, account, amount); } function getRunnerDeploymentBooster( @@ -253,6 +278,45 @@ contract RewardsBooster is Initializable, OwnableUpgradeable, IRewardsBooster { ); } + + /** + * @notice Add booster deployment staking + * @param _deploymentId the deployment id + * @param _account the booster account + * @param _amount the added amount + */ + function _addBoosterDeployment(bytes32 _deploymentId, address _account, uint256 _amount) internal { + DeploymentPool storage deploymentPool = deploymentPools[_deploymentId]; + onDeploymentBoosterUpdate(_deploymentId, _account); + deploymentPool.boosterPoint += _amount; + deploymentPool.accountBooster[_account] += _amount; + deploymentPool.accRewardsPerBooster = accRewardsPerBooster; + totalBoosterPoint += _amount; + + emit DeploymentBoosterAdded(_deploymentId, _account, _amount); + } + + /** + * @notice Remove booster from deployment + * @param _deploymentId deploymentId + * @param _account the booster account + * @param _amount the added amount + */ + function _removeBoosterDeployment( + bytes32 _deploymentId, + address _account, + uint256 _amount + ) internal { + DeploymentPool storage deploymentPool = deploymentPools[_deploymentId]; + onDeploymentBoosterUpdate(_deploymentId, _account); + deploymentPool.boosterPoint -= _amount; + deploymentPool.accountBooster[_account] -= _amount; + deploymentPool.accRewardsPerBooster = accRewardsPerBooster; + totalBoosterPoint -= _amount; + + emit DeploymentBoosterRemoved(_deploymentId, _account, _amount); + } + /** * @notice Fix reward considering missed labor * @param _reward reward before fix diff --git a/publish/ABI/RewardsBooster.json b/publish/ABI/RewardsBooster.json index 394ec546..c1b63b56 100644 --- a/publish/ABI/RewardsBooster.json +++ b/publish/ABI/RewardsBooster.json @@ -832,7 +832,7 @@ "inputs": [ { "internalType": "bytes32", - "name": "deployment", + "name": "deploymentId", "type": "bytes32" }, { @@ -1027,6 +1027,34 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "from", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "to", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "swapBoosterDeployment", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "totalBoosterPoint", diff --git a/publish/revertcode.json b/publish/revertcode.json index b3e285cd..1aabdb3c 100644 --- a/publish/revertcode.json +++ b/publish/revertcode.json @@ -213,5 +213,7 @@ "RB010": "Invalid report time when setMissedLabor", "RB011": "MissedLaborTime exceed current report period", "RB012": "Invalid param length to set MissedLabor", + "RB013": "Deployment ids can not be same", + "RB014": "Caller is not a controller of the account", "OPD01": "l2token address is empty" } diff --git a/scripts/config/contracts.config.ts b/scripts/config/contracts.config.ts index 06d135b6..da343597 100644 --- a/scripts/config/contracts.config.ts +++ b/scripts/config/contracts.config.ts @@ -4,7 +4,11 @@ export default { mainnet: { InflationController: [12000, '0x9E3a8e4d0115e5b157B61b6a5372ecc41446D472'], // inflationRate, inflationDestination InflationDestination: ['0xd043807A0f41EE95fD66A523a93016a53456e79B'], // XcRecipient - OpDestination: ['0x09395a2A58DB45db0da254c7EAa5AC469D8bDc85', '0x858c50C3AF1913b0E849aFDB74617388a1a5340d', '0x3154Cf16ccdb4C6d922629664174b904d80F2C35'], + OpDestination: [ + '0x09395a2A58DB45db0da254c7EAa5AC469D8bDc85', + '0x858c50C3AF1913b0E849aFDB74617388a1a5340d', + '0x3154Cf16ccdb4C6d922629664174b904d80F2C35', + ], SQToken: [utils.parseEther('10000000000')], // initial supply 10 billion VTSQToken: [], Staking: [1209600, 1e3], // lockPeriod: 14 days, unbondFeeRate: 10e3/10e6=0.001=0.1% @@ -17,7 +21,7 @@ export default { // base: 2s a block, 31536000/2 = 15768000 blocks a year, 1% rewards = 100000000 / 15768000 = about 6.3419584 SQT per block RewardsBooster: [utils.parseEther('6.3419584'), utils.parseEther('1000')], // _issuancePerBlock, _minimumDeploymentBooster L2SQToken: ['0x4200000000000000000000000000000000000010', '0x09395a2A58DB45db0da254c7EAa5AC469D8bDc85'], // l2bridge, l1token - PriceOracle: [10 , 3600], + PriceOracle: [10, 3600], }, kepler: { InflationController: [0, '0x34c35136ECe9CBD6DfDf2F896C6e29be01587c0C'], // inflationRate, inflationDestination diff --git a/scripts/config/mainnet.config.ts b/scripts/config/mainnet.config.ts index 3f30dc72..02f85c8d 100644 --- a/scripts/config/mainnet.config.ts +++ b/scripts/config/mainnet.config.ts @@ -1,16 +1,16 @@ const config = { multiSig: { root: { - foundation: "0x623D1426f5F45D39A1D9EbD3A5f6abeE0c8eC469", - teamAllocation: "0x32aB17a7d990F4afA8AD01cbFcbf49c26CFC0494", - foundationAllocation: "0x16F94a7719994303125bc7cEB2Dac0Cca2e9b787", + foundation: '0x623D1426f5F45D39A1D9EbD3A5f6abeE0c8eC469', + teamAllocation: '0x32aB17a7d990F4afA8AD01cbFcbf49c26CFC0494', + foundationAllocation: '0x16F94a7719994303125bc7cEB2Dac0Cca2e9b787', }, child: { - foundation: "0x31E99bdA5939bA2e7528707507b017f43b67F89B", - treasury: "0xd043807A0f41EE95fD66A523a93016a53456e79B", - council: "0xDD93Add934dCc40b54f3d701C5666CFf1C9FD0Df", - } - } -} + foundation: '0x31E99bdA5939bA2e7528707507b017f43b67F89B', + treasury: '0xd043807A0f41EE95fD66A523a93016a53456e79B', + council: '0xDD93Add934dCc40b54f3d701C5666CFf1C9FD0Df', + }, + }, +}; export default config; diff --git a/scripts/deployContracts.ts b/scripts/deployContracts.ts index ecaa8f96..a8aa3e9d 100644 --- a/scripts/deployContracts.ts +++ b/scripts/deployContracts.ts @@ -81,7 +81,7 @@ async function getOverrides(): Promise { const price = await wallet.provider.getGasPrice(); // console.log(`gasprice: ${price.toString()}`) // price = price.add(15000000000); // add extra 15 gwei - return { gasPrice: price, gasLimit: 3000000 }; + return { gasPrice: price }; } export function saveDeployment(name: string, deployment: Partial) { diff --git a/scripts/startup.ts b/scripts/startup.ts index 51295ee4..75b7fbae 100644 --- a/scripts/startup.ts +++ b/scripts/startup.ts @@ -191,12 +191,7 @@ export async function airdrop(sdk: ContractSDK, _provider?: StaticJsonRpcProvide async function rootContractOwnerTransfer(sdk: RootContractSDK) { logger = getLogger('Owner Transfer'); - const contracts = [ - sdk.sqToken, - sdk.vtSQToken, - sdk.vesting, - sdk.inflationDestination, - ]; + const contracts = [sdk.sqToken, sdk.vtSQToken, sdk.vesting, sdk.inflationDestination]; const foundation = mainnetConfig.multiSig.root.foundation; logger.info(`Transfer Ownership to ${foundation}`); @@ -214,7 +209,6 @@ async function rootContractOwnerTransfer(sdk: RootContractSDK) { // TODO: please manually transfer the ownership of `proxyAdmin` | `settings` | `infaltionController` to `mainnetConfig.multiSig.root.foundationAllocation;` } - export async function childContractOwnerTransfer(sdk: ContractSDK) { logger = getLogger('Owner Transfer'); diff --git a/scripts/verify.ts b/scripts/verify.ts index 19c74dd7..dfec6472 100644 --- a/scripts/verify.ts +++ b/scripts/verify.ts @@ -28,9 +28,7 @@ async function checkRootInitialisation(sdk: RootContractSDK, config) { logger.info(`InflationRate to be equal ${rate}`); expect((await sdk.inflationController.inflationRate()).toNumber()).to.eq(rate); logger.info(`InflationDestination to be equal ${destination}`); - expect((await sdk.inflationController.inflationDestination()).toUpperCase()).to.equal( - destination.toUpperCase() - ); + expect((await sdk.inflationController.inflationDestination()).toUpperCase()).to.equal(destination.toUpperCase()); logger.info('🎉 InflationController Contract verified\n'); // inflation destination @@ -57,7 +55,7 @@ async function checkRootInitialisation(sdk: RootContractSDK, config) { expect(totalSupply).to.eql(amount); logger.info(`SQToken minter is ${sdk.inflationController.address}`); // TODO: update this check after TGE launched - expect((await sdk.sqToken.getMinter())).to.equal('0x0000000000000000000000000000000000000000'); + expect(await sdk.sqToken.getMinter()).to.equal('0x0000000000000000000000000000000000000000'); const wallet = mainnetConfig.multiSig.root.foundation; logger.info(`Foundation wallet: ${wallet} own the total assets`); const foundationSQTBalance = await sdk.sqToken.balanceOf(wallet); @@ -172,7 +170,6 @@ async function checkChildInitialisation(sdk: ContractSDK, config, caller: string logger.info(`blockLimit to be equal ${blockLimit}`); expect(await sdk.priceOracle.blockLimit()).to.eql(BN(blockLimit)); logger.info('🎉 PriceOracle Contract verified\n'); - } catch (err) { logger.info(`Failed to verify contract: ${err}`); } @@ -246,7 +243,7 @@ async function checkRootContractsOwnership(sdk: RootContractSDK) { [sdk.inflationController, foundationW], // TODO: verify `settings` and `proxyAmdin` which owner is `allocationW` ]; - + try { for (const [contract, owner] of contracts) { // @ts-expect-error no owner interface diff --git a/src/rootSdk.ts b/src/rootSdk.ts index 505b85bc..b1a5fbd7 100644 --- a/src/rootSdk.ts +++ b/src/rootSdk.ts @@ -46,12 +46,11 @@ export class RootContractSDK { } private async _init() { - const contracts = Object.entries(this._contractDeployments) - .map(([name, contract]) => ({ - address: contract.address, - factory: CONTRACT_FACTORY[name as ContractName] as FactoryContstructor, - name: name as ContractName, - })); + const contracts = Object.entries(this._contractDeployments).map(([name, contract]) => ({ + address: contract.address, + factory: CONTRACT_FACTORY[name as ContractName] as FactoryContstructor, + name: name as ContractName, + })); for (const { name, factory, address } of contracts) { if (!factory) continue; diff --git a/test/RewardsBooster.test.ts b/test/RewardsBooster.test.ts index 4e244aac..87b5c38e 100644 --- a/test/RewardsBooster.test.ts +++ b/test/RewardsBooster.test.ts @@ -36,6 +36,7 @@ import { } from './helper'; import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import { BigNumber, constants } from 'ethers'; +import { ConsumerRegistry } from 'build'; const PER_MILL = BigNumber.from(1e6); @@ -44,6 +45,7 @@ describe('RewardsBooster Contract', () => { const deploymentId1 = deploymentIds[1]; const deploymentId2 = deploymentIds[2]; const deploymentId3 = deploymentIds[3]; + const deploymentId4 = deploymentIds[4]; const defaultChannelId = ethers.utils.randomBytes(32); const mockProvider = waffle.provider; @@ -52,7 +54,8 @@ describe('RewardsBooster Contract', () => { runner1: SignerWithAddress, runner2: SignerWithAddress, consumer0: SignerWithAddress, - consumer1: SignerWithAddress; + consumer1: SignerWithAddress, + controller: SignerWithAddress; let token: ERC20; let staking: Staking; @@ -65,6 +68,7 @@ describe('RewardsBooster Contract', () => { let stakingAllocation: StakingAllocation; let projectRegistry: ProjectRegistry; let stateChannel: StateChannel; + let consumerRegistry: ConsumerRegistry; const getAllocationReward = (deploymentReward: BigNumber, queryRewardRatePerMill: BigNumber): BigNumber => { return deploymentReward.mul(PER_MILL.sub(queryRewardRatePerMill)).div(PER_MILL); @@ -111,7 +115,7 @@ describe('RewardsBooster Contract', () => { const deployer = () => deployContracts(root, root, root); before(async () => { - [root, runner0, runner1, runner2, consumer0, consumer1] = await ethers.getSigners(); + [root, runner0, runner1, runner2, consumer0, consumer1, controller] = await ethers.getSigners(); }); const applyStaking = async (runner, delegator) => { @@ -136,6 +140,7 @@ describe('RewardsBooster Contract', () => { stakingAllocation = deployment.stakingAllocation; projectRegistry = deployment.projectRegistry; stateChannel = deployment.stateChannel; + consumerRegistry = deployment.consumerRegistry; await token.approve(rewardsBooster.address, constants.MaxInt256); // config rewards booster @@ -149,7 +154,7 @@ describe('RewardsBooster Contract', () => { root, projectMetadatas[0], deploymentMetadatas[0], - deploymentIds[0], + deploymentId0, ProjectType.SUBQUERY ); await createProject( @@ -157,7 +162,7 @@ describe('RewardsBooster Contract', () => { root, projectMetadatas[1], deploymentMetadatas[1], - deploymentIds[1], + deploymentId1, ProjectType.SUBQUERY ); await createProject( @@ -165,7 +170,7 @@ describe('RewardsBooster Contract', () => { root, projectMetadatas[2], deploymentMetadatas[2], - deploymentIds[2], + deploymentId2, ProjectType.SUBQUERY ); await createProject( @@ -173,7 +178,7 @@ describe('RewardsBooster Contract', () => { root, projectMetadatas[3], deploymentMetadatas[3], - deploymentIds[3], + deploymentId3, ProjectType.RPC ); @@ -183,6 +188,7 @@ describe('RewardsBooster Contract', () => { await token.connect(root).transfer(runner2.address, etherParse('100000')); await token.connect(root).transfer(consumer0.address, etherParse('100000')); await token.connect(root).transfer(consumer1.address, etherParse('100000')); + await token.connect(root).transfer(controller.address, etherParse('100000')); await token.connect(consumer0).increaseAllowance(staking.address, etherParse('100000')); await token.connect(consumer1).increaseAllowance(staking.address, etherParse('100000')); @@ -417,6 +423,43 @@ describe('RewardsBooster Contract', () => { getQueryReward(reward2.sub(reward1), queryRewardRatePerMill) ); }); + + it('can swap booster from one deployment to another', async () => { + await boosterDeployment(token, rewardsBooster, consumer0, deploymentId1, etherParse('10000')); + + await blockTravel(999); + const consumer = consumer0.address; + // swap with consumer account + await rewardsBooster.connect(consumer0).swapBoosterDeployment(consumer, deploymentId1, deploymentId2, etherParse('3000')); + // check states + const accRewardsPerBooster = await rewardsBooster.getAccRewardsPerBooster(); + const pool1 = await rewardsBooster.deploymentPools(deploymentId1); + expect(pool1.boosterPoint).to.eq(etherParse('7000')); + expect(pool1.accRewardsPerBooster).to.eq(accRewardsPerBooster) + const runnerDeployment2Booster = await rewardsBooster.getRunnerDeploymentBooster(deploymentId1, consumer); + expect(runnerDeployment2Booster).to.eq(etherParse('7000')); + + const pool2 = await rewardsBooster.deploymentPools(deploymentId2); + expect(pool2.boosterPoint).to.eq(etherParse('3000')); + expect(pool2.accRewardsPerBooster).to.eq(accRewardsPerBooster); + const runnerDeployment3Booster = await rewardsBooster.getRunnerDeploymentBooster(deploymentId2, consumer); + expect(runnerDeployment3Booster).to.eq(etherParse('3000')); + + // swap with controller account + await consumerRegistry.connect(consumer0).addController(consumer, controller.address); + await rewardsBooster.connect(consumer0).swapBoosterDeployment(consumer, deploymentId1, deploymentId3, etherParse('3000')); + }); + + it('fail to swap booster with invalid params', async () => { + // 1. invalid `to` deploymentId + await expect(rewardsBooster.swapBoosterDeployment(consumer0.address, deploymentId2, deploymentId4, etherParse('10000'))).to.be.revertedWith('RB008'); + // 2. same `from` and `to` deploymentId + await expect(rewardsBooster.swapBoosterDeployment(consumer0.address, deploymentId2, deploymentId2, etherParse('10000'))).to.be.revertedWith('RB013'); + // 3. invalid caller + await expect(rewardsBooster.connect(consumer0).swapBoosterDeployment(consumer1.address, deploymentId1, deploymentId2, etherParse('10000'))).to.be.revertedWith('RB014'); + // 4. not enough amount to swap + await expect(rewardsBooster.connect(consumer0).swapBoosterDeployment(consumer0.address, deploymentId1, deploymentId2, etherParse('10000'))).to.be.revertedWith('RB003'); + }); }); }); @@ -869,7 +912,7 @@ describe('RewardsBooster Contract', () => { it('overflow clear by RewardsBooster', async () => { await stakingAllocation .connect(runner0) - .addAllocation(deploymentIds[0], runner0.address, etherParse('10000')); + .addAllocation(deploymentId0, runner0.address, etherParse('10000')); const status0 = await stakingAllocation.runnerAllocation(runner0.address); expect(status0.overflowAt).to.eq(0); expect(status0.overflowTime).to.eq(0); @@ -883,12 +926,12 @@ describe('RewardsBooster Contract', () => { const overtime1 = await stakingAllocation.overAllocationTime(runner0.address); // collect when overflow - await rewardsBooster.connect(runner0).collectAllocationReward(deploymentIds[0], runner0.address); + await rewardsBooster.connect(runner0).collectAllocationReward(deploymentId0, runner0.address); const overtime2 = await stakingAllocation.overAllocationTime(runner0.address); expect(overtime2).to.gt(overtime1); - const rewards2 = await rewardsBooster.getRunnerDeploymentRewards(deploymentIds[0], runner0.address); + const rewards2 = await rewardsBooster.getRunnerDeploymentRewards(deploymentId0, runner0.address); expect(rewards2.overflowTimeSnapshot).to.eq(overtime2); - const rewards22 = await rewardsBooster.getRunnerDeploymentRewards(deploymentIds[1], runner0.address); + const rewards22 = await rewardsBooster.getRunnerDeploymentRewards(deploymentId1, runner0.address); expect(rewards22.overflowTimeSnapshot).to.eq(0); await timeTravel(10); @@ -902,10 +945,10 @@ describe('RewardsBooster Contract', () => { // collect when not overflow await timeTravel(10); - await rewardsBooster.connect(runner0).collectAllocationReward(deploymentIds[0], runner0.address); - const rewards3 = await rewardsBooster.getRunnerDeploymentRewards(deploymentIds[0], runner0.address); + await rewardsBooster.connect(runner0).collectAllocationReward(deploymentId0, runner0.address); + const rewards3 = await rewardsBooster.getRunnerDeploymentRewards(deploymentId0, runner0.address); expect(rewards3.overflowTimeSnapshot).to.eq(overtime3); - const rewards33 = await rewardsBooster.getRunnerDeploymentRewards(deploymentIds[1], runner0.address); + const rewards33 = await rewardsBooster.getRunnerDeploymentRewards(deploymentId1, runner0.address); expect(rewards33.overflowTimeSnapshot).to.eq(0); await stakingManager.connect(runner0).unstake(runner0.address, etherParse('5000')); @@ -920,12 +963,12 @@ describe('RewardsBooster Contract', () => { expect(status4.overflowTime).to.eq(overtime4); // collect when overflow again - await rewardsBooster.connect(runner0).collectAllocationReward(deploymentIds[0], runner0.address); - const rewards4 = await rewardsBooster.getRunnerDeploymentRewards(deploymentIds[0], runner0.address); + await rewardsBooster.connect(runner0).collectAllocationReward(deploymentId0, runner0.address); + const rewards4 = await rewardsBooster.getRunnerDeploymentRewards(deploymentId0, runner0.address); expect(rewards4.overflowTimeSnapshot).to.eq(overtime4); - await rewardsBooster.connect(runner0).collectAllocationReward(deploymentIds[1], runner0.address); - const rewards44 = await rewardsBooster.getRunnerDeploymentRewards(deploymentIds[1], runner0.address); + await rewardsBooster.connect(runner0).collectAllocationReward(deploymentId1, runner0.address); + const rewards44 = await rewardsBooster.getRunnerDeploymentRewards(deploymentId1, runner0.address); expect(rewards44.overflowTimeSnapshot).to.eq(overtime4); }); }); diff --git a/test/fixtures/rpc_projects.yaml b/test/fixtures/rpc_projects.yaml index 3a288c68..26fa0ee9 100644 --- a/test/fixtures/rpc_projects.yaml +++ b/test/fixtures/rpc_projects.yaml @@ -45,104 +45,104 @@ - kind: Project projectType: 1 # rpc metadata: - name: Eth Mainnet Rpc - Full Node - description: '' - websiteUrl: https://ethereum.org/ + name: Eth Mainnet Rpc - Full Node + description: '' + websiteUrl: https://ethereum.org/ deployments: - - deployment: | - kind: ChainRpc - specVersion: 1.0.0 - name: eth-mainnet - full - chain: - chainId: 1 - rpcFamily: - - evm - nodeType: full - rpcDenyList: - - admin - - debug - - txpool - - personal - - miner - - les - version: - version: 1.0.0 - description: '' + - deployment: | + kind: ChainRpc + specVersion: 1.0.0 + name: eth-mainnet - full + chain: + chainId: 1 + rpcFamily: + - evm + nodeType: full + rpcDenyList: + - admin + - debug + - txpool + - personal + - miner + - les + version: + version: 1.0.0 + description: '' - kind: Project projectType: 1 # rpc metadata: - name: Eth Mainnet Rpc - Archive Node - description: '' - websiteUrl: https://ethereum.org/ + name: Eth Mainnet Rpc - Archive Node + description: '' + websiteUrl: https://ethereum.org/ deployments: - - deployment: | - kind: ChainRpc - specVersion: 1.0.0 - name: eth-mainnet - archive - chain: - chainId: 1 - rpcFamily: - - evm - nodeType: archive - rpcDenyList: - - admin - - debug - - txpool - - personal - - miner - - les - version: - version: 1.0.0 - description: '' + - deployment: | + kind: ChainRpc + specVersion: 1.0.0 + name: eth-mainnet - archive + chain: + chainId: 1 + rpcFamily: + - evm + nodeType: archive + rpcDenyList: + - admin + - debug + - txpool + - personal + - miner + - les + version: + version: 1.0.0 + description: '' - kind: Project projectType: 1 # rpc metadata: - name: Base Rpc - Full Node - description: '' - websiteUrl: https://base.org/ + name: Base Rpc - Full Node + description: '' + websiteUrl: https://base.org/ deployments: - - deployment: | - kind: ChainRpc - specVersion: 1.0.0 - name: base - full - chain: - chainId: 8453 - rpcFamily: - - evm - nodeType: full - rpcDenyList: - - admin - - debug - - txpool - - personal - - miner - - les - version: - version: 1.0.0 - description: '' + - deployment: | + kind: ChainRpc + specVersion: 1.0.0 + name: base - full + chain: + chainId: 8453 + rpcFamily: + - evm + nodeType: full + rpcDenyList: + - admin + - debug + - txpool + - personal + - miner + - les + version: + version: 1.0.0 + description: '' - kind: Project projectType: 1 # rpc metadata: - name: Base Rpc - Archive Node - description: '' - websiteUrl: https://base.org/ + name: Base Rpc - Archive Node + description: '' + websiteUrl: https://base.org/ deployments: - - deployment: | - kind: ChainRpc - specVersion: 1.0.0 - name: base - archive - chain: - chainId: 8453 - rpcFamily: - - evm - nodeType: archive - rpcDenyList: - - admin - - debug - - txpool - - personal - - miner - - les - version: - version: 1.0.0 - description: '' + - deployment: | + kind: ChainRpc + specVersion: 1.0.0 + name: base - archive + chain: + chainId: 8453 + rpcFamily: + - evm + nodeType: archive + rpcDenyList: + - admin + - debug + - txpool + - personal + - miner + - les + version: + version: 1.0.0 + description: '' diff --git a/test/fixtures/settings.yaml b/test/fixtures/settings.yaml index b46848ed..9b427fbd 100644 --- a/test/fixtures/settings.yaml +++ b/test/fixtures/settings.yaml @@ -7,11 +7,11 @@ issuancePerBlock: '6341958400000000000' # 6.34 - kind: ProjectTypeCreatorRestricted value: - - projectType: 0 # subquery project - restricted: true - - projectType: 1 # rpc - restricted: true - - projectType: 2 # dict - restricted: true - - projectType: 3 # subgraqh - restricted: true + - projectType: 0 # subquery project + restricted: true + - projectType: 1 # rpc + restricted: true + - projectType: 2 # dict + restricted: true + - projectType: 3 # subgraqh + restricted: true