Skip to content

Commit

Permalink
Add version to relayer (#2526)
Browse files Browse the repository at this point in the history
  • Loading branch information
jubeira committed Jun 22, 2023
1 parent 872342e commit 8fceb87
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
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 isL2Relayer,
string memory version
) BaseRelayerLibrary(vault, version) LidoWrapping(wstETH) GaugeActions(minter, isL2Relayer) {
// solhint-disable-previous-line no-empty-blocks
}
}
9 changes: 7 additions & 2 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 @@ -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;
}
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 @@ -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) {
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 @@ -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);
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
4 changes: 2 additions & 2 deletions pvt/benchmarks/relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 8fceb87

Please sign in to comment.