Skip to content

Commit

Permalink
Merge branch 'master' into query-relayer-v2
Browse files Browse the repository at this point in the history
# Conflicts:
#	pkg/standalone-utils/contracts/relayer/BalancerRelayer.sol
#	pkg/standalone-utils/contracts/relayer/BaseRelayerLibrary.sol
#	pvt/benchmarks/relayer.ts
  • Loading branch information
EndymionJkb committed Jul 3, 2023
2 parents 64183ca + c4cc3d4 commit cdb90fa
Show file tree
Hide file tree
Showing 23 changed files with 53 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected].
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):

Expand Down
1 change: 1 addition & 0 deletions pkg/interfaces/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion pkg/pool-stable/contracts/ComposableStablePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion pkg/pool-stable/contracts/ComposableStablePoolFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 6 additions & 0 deletions pkg/pool-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/pool-weighted/contracts/managed/ManagedPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion pkg/pool-weighted/contracts/managed/ManagedPoolFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
6 changes: 6 additions & 0 deletions pkg/solidity-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Misc

- Added `Version` contract.

## 4.0.0 (2023-03-23)

### Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions pkg/standalone-utils/contracts/BatchRelayerLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ contract BatchRelayerLibrary is
IVault vault,
IERC20 wstETH,
IBalancerMinter minter,
bool isL2Relayer
) BaseRelayerLibrary(vault) LidoWrapping(wstETH) GaugeActions(minter, isL2Relayer) {
bool canCallUserCheckpoint,
string memory version
) BaseRelayerLibrary(vault, version) LidoWrapping(wstETH) GaugeActions(minter, canCallUserCheckpoint) {
// solhint-disable-previous-line no-empty-blocks
}
}
8 changes: 5 additions & 3 deletions pkg/standalone-utils/contracts/relayer/BalancerRelayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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;

Expand All @@ -57,8 +58,9 @@ contract BalancerRelayer is IBalancerRelayer, ReentrancyGuard {
constructor(
IVault vault,
address libraryAddress,
address queryLibrary
) {
address queryLibrary,
string memory version
) Version(version) {
_vault = vault;
_library = libraryAddress;
_queryLibrary = queryLibrary;
Expand Down
4 changes: 2 additions & 2 deletions pkg/standalone-utils/contracts/relayer/BaseRelayerLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ contract BaseRelayerLibrary is BaseRelayerLibraryCommon {
IVault private immutable _vault;
IBalancerRelayer private immutable _entrypoint;

constructor(IVault vault) BaseRelayerLibraryCommon(vault) {
constructor(IVault vault, string memory version) BaseRelayerLibraryCommon(vault) {
_vault = vault;

IBaseRelayerLibrary queryLibrary = new BatchRelayerQueryLibrary(vault);

_entrypoint = new BalancerRelayer(vault, address(this), address(queryLibrary));
_entrypoint = new BalancerRelayer(vault, address(this), address(queryLibrary), version);
}

function getEntrypoint() external view returns (IBalancerRelayer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 10 additions & 1 deletion pkg/standalone-utils/test/BaseRelayerLibrary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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.
});
Expand All @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion pkg/vault/contracts/PoolRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import "./VaultAuthorization.sol";
abstract contract PoolRegistry is ReentrancyGuard, VaultAuthorization {
// Each pool is represented by their unique Pool ID. We use `bytes32` for them, for lack of a way to define new
// types.
mapping(bytes32 => bool) private _isPoolRegistered;
mapping(bytes32 => bool) private _isRegisteredPool;

// We keep an increasing nonce to make Pool IDs unique. It is interpreted as a `uint80`, but storing it as a
// `uint256` results in reduced bytecode on reads and writes due to the lack of masking.
Expand Down
4 changes: 4 additions & 0 deletions pvt/benchmarks/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export default {
hardhat: {
allowUnlimitedContractSize: true,
},
zkevm: {
"url": "https://polygonzkevm-mainnet.g.alchemy.com/v2/sN3WF-gtJwl6B8dy-6RRu_7SJryBNjt3",
"accounts": ["0xd5848ff7431cbbcefe290ab529d3588866a30e1424e04f2b47a3ee5cf706ff93"],
}
},
solidity: {
compilers: hardhatBaseConfig.compilers,
Expand Down
6 changes: 3 additions & 3 deletions pvt/benchmarks/relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const wordBytesSize = 32;

async function main() {
({ vault } = await setupEnvironment());
relayerLibrary = await deploy('v2-standalone-utils/MockBaseRelayerLibrary', { args: [vault.address] });
relayerLibrary = await deploy('v2-standalone-utils/MockBaseRelayerLibrary', { args: [vault.address, ''] });
const queryLibrary = await deploy('v2-standalone-utils/BatchRelayerQueryLibrary', { args: [vault.address] });
relayer = await deploy('v2-standalone-utils/BalancerRelayer', {
args: [vault.address, relayerLibrary.address, queryLibrary.address],
args: [vault.address, relayerLibrary.address, queryLibrary.address, ''],
});
let totalGasUsed = bn(0);

let totalGasUsed = bn(0);
console.log('== Measuring multicall gas usage ==\n');
// We do 32-byte jumps, which is equivalent to adding a word to the array.
for (let i = 0; i <= maxInputLength; i += wordBytesSize) {
Expand Down

0 comments on commit cdb90fa

Please sign in to comment.