Skip to content

Commit b7cf2f2

Browse files
authored
fix: [N-03] Lack of Documentation (removed hardcoded refund address) (#326)
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
1 parent d45b820 commit b7cf2f2

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

contracts/chain-adapters/ZkSync_Adapter.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ contract ZkSync_Adapter is AdapterInterface {
139139
// This address receives any remaining fee after an L1 to L2 transaction completes.
140140
// If refund recipient = address(0) then L2 msg.sender is used, unless msg.sender is a contract then its address
141141
// gets aliased.
142-
address public constant l2RefundAddress = 0x428AB2BA90Eba0a4Be7aF34C9Ac451ab061AC010;
142+
address public immutable l2RefundAddress;
143143

144144
// Hardcode the following ZkSync system contract addresses to save gas on construction. This adapter can be
145145
// redeployed in the event that the following addresses change.
@@ -162,9 +162,11 @@ contract ZkSync_Adapter is AdapterInterface {
162162
/**
163163
* @notice Constructs new Adapter.
164164
* @param _l1Weth WETH address on L1.
165+
* @param _l2RefundAddress address that recieves excess gas refunds on L2.
165166
*/
166-
constructor(WETH9Interface _l1Weth) {
167+
constructor(WETH9Interface _l1Weth, address _l2RefundAddress) {
167168
l1Weth = _l1Weth;
169+
l2RefundAddress = _l2RefundAddress;
168170
}
169171

170172
/**

deploy/015_deploy_zksync_adapter.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import { DeployFunction } from "hardhat-deploy/types";
22
import { HardhatRuntimeEnvironment } from "hardhat/types";
3+
import { L1_ADDRESS_MAP } from "./consts";
34

45
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5-
const { deployments, getNamedAccounts } = hre;
6+
const { deployments, getNamedAccounts, getChainId } = hre;
67

78
const { deploy } = deployments;
89

910
const { deployer } = await getNamedAccounts();
11+
const chainId = parseInt(await getChainId());
1012

1113
await deploy("ZkSync_Adapter", {
1214
from: deployer,
1315
log: true,
1416
skipIfAlreadyDeployed: true,
15-
args: [],
17+
// Most common across dataworker set as the refund address, but changeable by whoever runs the script.
18+
args: [L1_ADDRESS_MAP[chainId].weth, "0x428AB2BA90Eba0a4Be7aF34C9Ac451ab061AC010"],
1619
});
1720
};
1821

test/chain-adapters/ZkSync_Adapter.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import { smock } from "@defi-wonderland/smock";
1717

1818
let hubPool: Contract, zkSyncAdapter: Contract, weth: Contract, dai: Contract, timer: Contract, mockSpoke: Contract;
1919
let l2Weth: string, l2Dai: string, mainnetWeth: FakeContract;
20-
let owner: SignerWithAddress, dataWorker: SignerWithAddress, liquidityProvider: SignerWithAddress;
20+
let owner: SignerWithAddress,
21+
dataWorker: SignerWithAddress,
22+
liquidityProvider: SignerWithAddress,
23+
refundAddress: SignerWithAddress;
2124
let zkSync: FakeContract, zkSyncErc20Bridge: FakeContract;
2225

2326
const zkSyncChainId = 324;
@@ -73,7 +76,7 @@ const l2TransactionBaseCost = toWei("0.0001");
7376

7477
describe("ZkSync Chain Adapter", function () {
7578
beforeEach(async function () {
76-
[owner, dataWorker, liquidityProvider] = await ethers.getSigners();
79+
[owner, dataWorker, liquidityProvider, refundAddress] = await ethers.getSigners();
7780
({ weth, dai, l2Weth, l2Dai, hubPool, mockSpoke, timer } = await hubPoolFixture());
7881
await seedWallet(dataWorker, [dai], weth, amountToLp);
7982
await seedWallet(liquidityProvider, [dai], weth, amountToLp.mul(10));
@@ -93,7 +96,9 @@ describe("ZkSync Chain Adapter", function () {
9396
address: "0x57891966931Eb4Bb6FB81430E6cE0A03AAbDe063",
9497
});
9598

96-
zkSyncAdapter = await (await getContractFactory("ZkSync_Adapter", owner)).deploy(weth.address);
99+
zkSyncAdapter = await (
100+
await getContractFactory("ZkSync_Adapter", owner)
101+
).deploy(weth.address, refundAddress.address);
97102

98103
// Seed the HubPool some funds so it can send L1->L2 messages.
99104
await hubPool.connect(liquidityProvider).loadEthForL2Calls({ value: toWei("100000") });

0 commit comments

Comments
 (0)