From 872342e060bfc31c3ab6a1deb7b1d3050ea7e19d Mon Sep 17 00:00:00 2001 From: Juan Ignacio Ubeira Date: Wed, 21 Jun 2023 12:19:08 -0300 Subject: [PATCH 1/4] Refactor: move `Version` to `solidity-utils`. (#2525) --- pkg/interfaces/CHANGELOG.md | 1 + .../contracts/liquidity-mining/IChildChainGauge.sol | 2 +- .../{pool-utils => solidity-utils/helpers}/IVersion.sol | 0 .../contracts/gauges/ChildChainGaugeFactory.sol | 2 +- .../contracts/gauges/ethereum/SingleRecipientGauge.sol | 2 +- pkg/pool-stable/contracts/ComposableStablePool.sol | 2 +- pkg/pool-stable/contracts/ComposableStablePoolFactory.sol | 2 +- pkg/pool-utils/CHANGELOG.md | 6 ++++++ pkg/pool-weighted/contracts/managed/ManagedPool.sol | 2 +- pkg/pool-weighted/contracts/managed/ManagedPoolFactory.sol | 2 +- pkg/solidity-utils/CHANGELOG.md | 6 ++++++ .../contracts/helpers}/Version.sol | 2 +- pkg/{pool-utils => solidity-utils}/test/Version.test.ts | 0 13 files changed, 21 insertions(+), 8 deletions(-) rename pkg/interfaces/contracts/{pool-utils => solidity-utils/helpers}/IVersion.sol (100%) rename pkg/{pool-utils/contracts => solidity-utils/contracts/helpers}/Version.sol (93%) rename pkg/{pool-utils => solidity-utils}/test/Version.test.ts (100%) diff --git a/pkg/interfaces/CHANGELOG.md b/pkg/interfaces/CHANGELOG.md index c08d096cfd..021bf5e7dd 100644 --- a/pkg/interfaces/CHANGELOG.md +++ b/pkg/interfaces/CHANGELOG.md @@ -21,6 +21,7 @@ - Refactored `IL2GaugeCheckpointer`. - Removed `isSupportedGaugeType` from interface. - Bumped minimum compiler version from `0.7.0` to `0.7.1` in `BalancerErrors`. +- `IVersion` moved from `pool-utils` to `solidity-utils`. ## 0.4.0 (2023-03-15) diff --git a/pkg/interfaces/contracts/liquidity-mining/IChildChainGauge.sol b/pkg/interfaces/contracts/liquidity-mining/IChildChainGauge.sol index d4df179287..b9721fdc17 100644 --- a/pkg/interfaces/contracts/liquidity-mining/IChildChainGauge.sol +++ b/pkg/interfaces/contracts/liquidity-mining/IChildChainGauge.sol @@ -14,7 +14,7 @@ pragma solidity >=0.7.0 <0.9.0; -import "../pool-utils/IVersion.sol"; +import "../solidity-utils/helpers/IVersion.sol"; import "./ILiquidityGaugeFactory.sol"; // For compatibility, we're keeping the same function names as in the original Curve code, including the mixed-case diff --git a/pkg/interfaces/contracts/pool-utils/IVersion.sol b/pkg/interfaces/contracts/solidity-utils/helpers/IVersion.sol similarity index 100% rename from pkg/interfaces/contracts/pool-utils/IVersion.sol rename to pkg/interfaces/contracts/solidity-utils/helpers/IVersion.sol diff --git a/pkg/liquidity-mining/contracts/gauges/ChildChainGaugeFactory.sol b/pkg/liquidity-mining/contracts/gauges/ChildChainGaugeFactory.sol index fcf3fa15cd..e14f1234e4 100644 --- a/pkg/liquidity-mining/contracts/gauges/ChildChainGaugeFactory.sol +++ b/pkg/liquidity-mining/contracts/gauges/ChildChainGaugeFactory.sol @@ -16,7 +16,7 @@ pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-interfaces/contracts/liquidity-mining/IChildChainGauge.sol"; -import "@balancer-labs/v2-pool-utils/contracts/Version.sol"; +import "@balancer-labs/v2-solidity-utils/contracts/helpers/Version.sol"; import "./BaseGaugeFactory.sol"; diff --git a/pkg/liquidity-mining/contracts/gauges/ethereum/SingleRecipientGauge.sol b/pkg/liquidity-mining/contracts/gauges/ethereum/SingleRecipientGauge.sol index a7fb149ec1..3bb7ec9c63 100644 --- a/pkg/liquidity-mining/contracts/gauges/ethereum/SingleRecipientGauge.sol +++ b/pkg/liquidity-mining/contracts/gauges/ethereum/SingleRecipientGauge.sol @@ -15,7 +15,7 @@ pragma solidity ^0.7.0; import "@balancer-labs/v2-interfaces/contracts/liquidity-mining/IFeeDistributor.sol"; -import "@balancer-labs/v2-pool-utils/contracts/Version.sol"; +import "@balancer-labs/v2-solidity-utils/contracts/helpers/Version.sol"; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/SafeERC20.sol"; import "../StakelessGauge.sol"; diff --git a/pkg/pool-stable/contracts/ComposableStablePool.sol b/pkg/pool-stable/contracts/ComposableStablePool.sol index 6edc1cb02f..c24087f1b2 100644 --- a/pkg/pool-stable/contracts/ComposableStablePool.sol +++ b/pkg/pool-stable/contracts/ComposableStablePool.sol @@ -19,7 +19,7 @@ import "@balancer-labs/v2-interfaces/contracts/pool-stable/StablePoolUserData.so import "@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/BalancerErrors.sol"; import "@balancer-labs/v2-interfaces/contracts/standalone-utils/IProtocolFeePercentagesProvider.sol"; import "@balancer-labs/v2-interfaces/contracts/pool-utils/IRateProvider.sol"; -import "@balancer-labs/v2-interfaces/contracts/pool-utils/IVersion.sol"; +import "@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/IVersion.sol"; import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol"; import "@balancer-labs/v2-solidity-utils/contracts/math/Math.sol"; diff --git a/pkg/pool-stable/contracts/ComposableStablePoolFactory.sol b/pkg/pool-stable/contracts/ComposableStablePoolFactory.sol index 6e7f35cc46..db5be0a704 100644 --- a/pkg/pool-stable/contracts/ComposableStablePoolFactory.sol +++ b/pkg/pool-stable/contracts/ComposableStablePoolFactory.sol @@ -16,7 +16,7 @@ pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; import "@balancer-labs/v2-interfaces/contracts/pool-utils/IPoolVersion.sol"; -import "@balancer-labs/v2-interfaces/contracts/pool-utils/IVersion.sol"; +import "@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/IVersion.sol"; import "@balancer-labs/v2-interfaces/contracts/vault/IVault.sol"; import "@balancer-labs/v2-pool-utils/contracts/factories/BasePoolFactory.sol"; diff --git a/pkg/pool-utils/CHANGELOG.md b/pkg/pool-utils/CHANGELOG.md index f54d2e1c06..95f75bd87a 100644 --- a/pkg/pool-utils/CHANGELOG.md +++ b/pkg/pool-utils/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Breaking changes + +- Removed `Version` contract. It is now part of `v2-solidity-utils` since it will be used more generally. + ## 4.1.1 (2023-06-05) ### Bugfix diff --git a/pkg/pool-weighted/contracts/managed/ManagedPool.sol b/pkg/pool-weighted/contracts/managed/ManagedPool.sol index 29ddee384c..df79d9dcd6 100644 --- a/pkg/pool-weighted/contracts/managed/ManagedPool.sol +++ b/pkg/pool-weighted/contracts/managed/ManagedPool.sol @@ -15,7 +15,7 @@ pragma solidity ^0.7.0; pragma experimental ABIEncoderV2; -import "@balancer-labs/v2-interfaces/contracts/pool-utils/IVersion.sol"; +import "@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/IVersion.sol"; import "@balancer-labs/v2-interfaces/contracts/pool-utils/IRecoveryModeHelper.sol"; import "@balancer-labs/v2-interfaces/contracts/pool-weighted/IExternalWeightedMath.sol"; import "@balancer-labs/v2-interfaces/contracts/pool-weighted/WeightedPoolUserData.sol"; diff --git a/pkg/pool-weighted/contracts/managed/ManagedPoolFactory.sol b/pkg/pool-weighted/contracts/managed/ManagedPoolFactory.sol index 18f9f72735..b02218cc6a 100644 --- a/pkg/pool-weighted/contracts/managed/ManagedPoolFactory.sol +++ b/pkg/pool-weighted/contracts/managed/ManagedPoolFactory.sol @@ -21,7 +21,7 @@ import "@balancer-labs/v2-interfaces/contracts/pool-weighted/IExternalWeightedMa import "@balancer-labs/v2-interfaces/contracts/standalone-utils/IProtocolFeePercentagesProvider.sol"; import "@balancer-labs/v2-pool-utils/contracts/factories/BasePoolFactory.sol"; -import "@balancer-labs/v2-pool-utils/contracts/Version.sol"; +import "@balancer-labs/v2-solidity-utils/contracts/helpers/Version.sol"; import "./ManagedPool.sol"; diff --git a/pkg/solidity-utils/CHANGELOG.md b/pkg/solidity-utils/CHANGELOG.md index 9bb6d1484f..3992c30bd5 100644 --- a/pkg/solidity-utils/CHANGELOG.md +++ b/pkg/solidity-utils/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Misc + +- Added `Version` contract. + ## 4.0.0 (2023-03-23) ### Breaking Changes diff --git a/pkg/pool-utils/contracts/Version.sol b/pkg/solidity-utils/contracts/helpers/Version.sol similarity index 93% rename from pkg/pool-utils/contracts/Version.sol rename to pkg/solidity-utils/contracts/helpers/Version.sol index 8e0f62a528..939951a57f 100644 --- a/pkg/pool-utils/contracts/Version.sol +++ b/pkg/solidity-utils/contracts/helpers/Version.sol @@ -14,7 +14,7 @@ pragma solidity ^0.7.0; -import "@balancer-labs/v2-interfaces/contracts/pool-utils/IVersion.sol"; +import "@balancer-labs/v2-interfaces/contracts/solidity-utils/helpers/IVersion.sol"; /** * @notice Retrieves a contract's version set at creation time from storage. diff --git a/pkg/pool-utils/test/Version.test.ts b/pkg/solidity-utils/test/Version.test.ts similarity index 100% rename from pkg/pool-utils/test/Version.test.ts rename to pkg/solidity-utils/test/Version.test.ts From 8fceb87c1d6dc522344bdca8f89a384f10f44ef6 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Ubeira Date: Thu, 22 Jun 2023 13:12:49 -0300 Subject: [PATCH 2/4] Add version to relayer (#2526) --- .../contracts/BatchRelayerLibrary.sol | 5 +++-- .../contracts/relayer/BalancerRelayer.sol | 9 +++++++-- .../contracts/relayer/BaseRelayerLibrary.sol | 4 ++-- .../contracts/test/MockBaseRelayerLibrary.sol | 2 +- .../contracts/test/MockBatchRelayerLibrary.sol | 2 +- pkg/standalone-utils/test/BaseRelayerLibrary.test.ts | 11 ++++++++++- pvt/benchmarks/relayer.ts | 4 ++-- 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/pkg/standalone-utils/contracts/BatchRelayerLibrary.sol b/pkg/standalone-utils/contracts/BatchRelayerLibrary.sol index 22c86b63a1..8a33d0a554 100644 --- a/pkg/standalone-utils/contracts/BatchRelayerLibrary.sol +++ b/pkg/standalone-utils/contracts/BatchRelayerLibrary.sol @@ -58,8 +58,9 @@ contract BatchRelayerLibrary is IVault vault, IERC20 wstETH, IBalancerMinter minter, - bool isL2Relayer - ) BaseRelayerLibrary(vault) LidoWrapping(wstETH) GaugeActions(minter, isL2Relayer) { + bool isL2Relayer, + string memory version + ) BaseRelayerLibrary(vault, version) LidoWrapping(wstETH) GaugeActions(minter, isL2Relayer) { // solhint-disable-previous-line no-empty-blocks } } diff --git a/pkg/standalone-utils/contracts/relayer/BalancerRelayer.sol b/pkg/standalone-utils/contracts/relayer/BalancerRelayer.sol index 32b7f81278..8a52852fc2 100644 --- a/pkg/standalone-utils/contracts/relayer/BalancerRelayer.sol +++ b/pkg/standalone-utils/contracts/relayer/BalancerRelayer.sol @@ -17,6 +17,7 @@ pragma experimental ABIEncoderV2; import "@balancer-labs/v2-interfaces/contracts/standalone-utils/IBalancerRelayer.sol"; +import "@balancer-labs/v2-solidity-utils/contracts/helpers/Version.sol"; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ReentrancyGuard.sol"; import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Address.sol"; @@ -42,7 +43,7 @@ import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Address.sol"; * Vault will reject calls from outside the context of the entrypoint: e.g., if a user mistakenly called directly * into the library contract. */ -contract BalancerRelayer is IBalancerRelayer, ReentrancyGuard { +contract BalancerRelayer is IBalancerRelayer, Version, ReentrancyGuard { using Address for address payable; using Address for address; @@ -53,7 +54,11 @@ contract BalancerRelayer is IBalancerRelayer, ReentrancyGuard { * @dev This contract is not meant to be deployed directly by an EOA, but rather during construction of a contract * derived from `BaseRelayerLibrary`, which will provide its own address as the relayer's library. */ - constructor(IVault vault, address libraryAddress) { + constructor( + IVault vault, + address libraryAddress, + string memory version + ) Version(version) { _vault = vault; _library = libraryAddress; } diff --git a/pkg/standalone-utils/contracts/relayer/BaseRelayerLibrary.sol b/pkg/standalone-utils/contracts/relayer/BaseRelayerLibrary.sol index edf87cc1b6..dd1feda3b3 100644 --- a/pkg/standalone-utils/contracts/relayer/BaseRelayerLibrary.sol +++ b/pkg/standalone-utils/contracts/relayer/BaseRelayerLibrary.sol @@ -48,9 +48,9 @@ contract BaseRelayerLibrary is IBaseRelayerLibrary { IVault private immutable _vault; IBalancerRelayer private immutable _entrypoint; - constructor(IVault vault) IBaseRelayerLibrary(vault.WETH()) { + constructor(IVault vault, string memory version) IBaseRelayerLibrary(vault.WETH()) { _vault = vault; - _entrypoint = new BalancerRelayer(vault, address(this)); + _entrypoint = new BalancerRelayer(vault, address(this), version); } function getVault() public view override returns (IVault) { diff --git a/pkg/standalone-utils/contracts/test/MockBaseRelayerLibrary.sol b/pkg/standalone-utils/contracts/test/MockBaseRelayerLibrary.sol index 5d4db3e209..185b154649 100644 --- a/pkg/standalone-utils/contracts/test/MockBaseRelayerLibrary.sol +++ b/pkg/standalone-utils/contracts/test/MockBaseRelayerLibrary.sol @@ -24,7 +24,7 @@ import "../relayer/BaseRelayerLibrary.sol"; contract MockBaseRelayerLibrary is BaseRelayerLibrary { event ChainedReferenceValueRead(uint256 value); - constructor(IVault vault) BaseRelayerLibrary(vault) {} + constructor(IVault vault, string memory version) BaseRelayerLibrary(vault, version) {} function isChainedReference(uint256 amount) public pure returns (bool) { return _isChainedReference(amount); diff --git a/pkg/standalone-utils/contracts/test/MockBatchRelayerLibrary.sol b/pkg/standalone-utils/contracts/test/MockBatchRelayerLibrary.sol index 705aad56a1..e5c999f8fa 100644 --- a/pkg/standalone-utils/contracts/test/MockBatchRelayerLibrary.sol +++ b/pkg/standalone-utils/contracts/test/MockBatchRelayerLibrary.sol @@ -27,7 +27,7 @@ contract MockBatchRelayerLibrary is BatchRelayerLibrary { IERC20 wstETH, IBalancerMinter minter, bool isL2Relayer - ) BatchRelayerLibrary(vault, wstETH, minter, isL2Relayer) {} + ) BatchRelayerLibrary(vault, wstETH, minter, isL2Relayer, "") {} function setChainedReferenceValue(uint256 ref, uint256 value) public { _setChainedReferenceValue(ref, value); diff --git a/pkg/standalone-utils/test/BaseRelayerLibrary.test.ts b/pkg/standalone-utils/test/BaseRelayerLibrary.test.ts index 048b30d10a..2959455214 100644 --- a/pkg/standalone-utils/test/BaseRelayerLibrary.test.ts +++ b/pkg/standalone-utils/test/BaseRelayerLibrary.test.ts @@ -22,6 +22,11 @@ describe('BaseRelayerLibrary', function () { let otherRelayer: SignerWithAddress; let admin: SignerWithAddress, signer: SignerWithAddress; + const version = JSON.stringify({ + name: 'BatchRelayer', + version: '1', + deployment: 'test-deployment', + }); before('get signers', async () => { [, admin, signer, otherRelayer] = await ethers.getSigners(); @@ -33,7 +38,7 @@ describe('BaseRelayerLibrary', function () { vault = vaultHelper.instance; // Deploy Relayer - relayerLibrary = await deploy('MockBaseRelayerLibrary', { args: [vault.address] }); + relayerLibrary = await deploy('MockBaseRelayerLibrary', { args: [vault.address, version] }); relayer = await deployedAt('BalancerRelayer', await relayerLibrary.getEntrypoint()); token = await deploy('TestWETH'); // Any ERC-20 will do. }); @@ -46,6 +51,10 @@ describe('BaseRelayerLibrary', function () { it('returns the vault address', async () => { expect(await relayer.getVault()).to.equal(vault.address); }); + + it('returns the relayer version', async () => { + expect(await relayer.version()).to.equal(version); + }); }); describe('chained references', () => { diff --git a/pvt/benchmarks/relayer.ts b/pvt/benchmarks/relayer.ts index 671076dfdb..6e2501d545 100644 --- a/pvt/benchmarks/relayer.ts +++ b/pvt/benchmarks/relayer.ts @@ -14,8 +14,8 @@ const wordBytesSize = 32; async function main() { ({ vault } = await setupEnvironment()); - relayerLibrary = await deploy('v2-standalone-utils/MockBaseRelayerLibrary', { args: [vault.address] }); - relayer = await deploy('v2-standalone-utils/BalancerRelayer', { args: [vault.address, relayerLibrary.address] }); + relayerLibrary = await deploy('v2-standalone-utils/MockBaseRelayerLibrary', { args: [vault.address, ''] }); + relayer = await deploy('v2-standalone-utils/BalancerRelayer', { args: [vault.address, relayerLibrary.address, ''] }); let totalGasUsed = bn(0); console.log('== Measuring multicall gas usage ==\n'); From 859d4bd4a8ba8fadbe2026690c7d07f87f9f1cb6 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Ubeira Date: Fri, 23 Jun 2023 11:08:54 -0300 Subject: [PATCH 3/4] Minor argument rename for consistency. (#2527) --- pkg/standalone-utils/contracts/BatchRelayerLibrary.sol | 4 ++-- .../contracts/test/MockBatchRelayerLibrary.sol | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/standalone-utils/contracts/BatchRelayerLibrary.sol b/pkg/standalone-utils/contracts/BatchRelayerLibrary.sol index 8a33d0a554..dffd9808b3 100644 --- a/pkg/standalone-utils/contracts/BatchRelayerLibrary.sol +++ b/pkg/standalone-utils/contracts/BatchRelayerLibrary.sol @@ -58,9 +58,9 @@ contract BatchRelayerLibrary is IVault vault, IERC20 wstETH, IBalancerMinter minter, - bool isL2Relayer, + bool canCallUserCheckpoint, string memory version - ) BaseRelayerLibrary(vault, version) LidoWrapping(wstETH) GaugeActions(minter, isL2Relayer) { + ) BaseRelayerLibrary(vault, version) LidoWrapping(wstETH) GaugeActions(minter, canCallUserCheckpoint) { // solhint-disable-previous-line no-empty-blocks } } diff --git a/pkg/standalone-utils/contracts/test/MockBatchRelayerLibrary.sol b/pkg/standalone-utils/contracts/test/MockBatchRelayerLibrary.sol index e5c999f8fa..d19bddc584 100644 --- a/pkg/standalone-utils/contracts/test/MockBatchRelayerLibrary.sol +++ b/pkg/standalone-utils/contracts/test/MockBatchRelayerLibrary.sol @@ -26,8 +26,8 @@ contract MockBatchRelayerLibrary is BatchRelayerLibrary { IVault vault, IERC20 wstETH, IBalancerMinter minter, - bool isL2Relayer - ) BatchRelayerLibrary(vault, wstETH, minter, isL2Relayer, "") {} + bool canCallUserCheckpoint + ) BatchRelayerLibrary(vault, wstETH, minter, canCallUserCheckpoint, "") {} function setChainedReferenceValue(uint256 ref, uint256 value) public { _setChainedReferenceValue(ref, value); From c4cc3d466eaa3c1e5fa62d303208c6c4a10db48a Mon Sep 17 00:00:00 2001 From: Markus Buhatem Koch Date: Tue, 27 Jun 2023 20:34:43 +0100 Subject: [PATCH 4/4] deprecate security@balancer.finance email (#2528) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 498b3c0ed2..0fd0fa8655 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ $ yarn test-fuzz Multiple independent reviews and audits were performed by [Certora](https://www.certora.com/), [OpenZeppelin](https://openzeppelin.com/) and [Trail of Bits](https://www.trailofbits.com/). The latest reports from these engagements are located in the [`audits`](./audits) directory. -Bug bounties apply to most of the smart contracts hosted in this repository: head to [Balancer V2 Bug Bounties](https://docs.balancer.fi/reference/contracts/security.html#bug-bounty) to learn more. Alternatively, send an email to security@balancer.finance. +Bug bounties apply to most of the smart contracts hosted in this repository: head to [Balancer V2 Bug Bounties](https://docs.balancer.fi/reference/contracts/security.html#bug-bounty) to learn more. All core smart contracts are immutable, and cannot be upgraded. See page 6 of the [Trail of Bits audit](https://github.com/balancer-labs/balancer-v2-monorepo/blob/master/audits/trail-of-bits/2021-04-02.pdf):