Skip to content

Commit 13cfb58

Browse files
authored
chore(protocol-contracts): save lz gas in FeesSenderToBurner (#1269)
* chore(protocol-contracts): save lz gas in FeesSenderToBurner * chore(protocol-contracts): optimize enforced executor option * test(protocol-contracts): fix fees burner tests * chore(protocol-contracts): fix comment
1 parent d01b11f commit 13cfb58

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

protocol-contracts/feesBurner/contracts/FeesSenderToBurner.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ contract FeesSenderToBurner {
4848

4949
if (amountNormalized == 0) revert NotEnoughZAMAToSend();
5050

51-
bytes memory options = OptionsBuilder.newOptions().addExecutorLzReceiveOption(80000, 0);
51+
bytes memory options = OptionsBuilder.newOptions();
5252

5353
SendParam memory sendParam = SendParam({
5454
dstEid: DESTINATION_EID,
@@ -72,7 +72,7 @@ contract FeesSenderToBurner {
7272
uint256 amountNormalized = (amount/(_DECIMAL_CONVERSION_RATE))*_DECIMAL_CONVERSION_RATE;
7373
if (amountNormalized == 0) revert NotEnoughZAMAToSend();
7474

75-
bytes memory options = OptionsBuilder.newOptions().addExecutorLzReceiveOption(80000, 0);
75+
bytes memory options = OptionsBuilder.newOptions();
7676

7777
SendParam memory sendParam = SendParam({
7878
dstEid: DESTINATION_EID,

protocol-contracts/feesBurner/test/hardhat/feesBurner.test.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,30 @@ describe("FeesBurner", () => {
6868
await zamaERC20.grantRole(MINTER_ROLE, deployer.address);
6969

7070
// Setting destination endpoints in the LZEndpoint mock for each MyOFT instance
71-
7271
await mockEndpointV2A.setDestLzEndpoint(zamaOFTAddress, mockEndpointV2BAddress);
7372
await mockEndpointV2B.setDestLzEndpoint(zamaOFTAdapterAddress, mockEndpointV2AAddress);
73+
7474
// Setting each OFT instance as a peer of the other in the mock LZEndpoint
7575
await zamaOFTAdapter.connect(deployer).setPeer(eidB, ethers.zeroPadValue(zamaOFTAddress, 32));
7676
await zamaOFT.connect(deployer).setPeer(eidA, ethers.zeroPadValue(zamaOFTAdapterAddress, 32));
77+
78+
// Set enforced executor options
79+
const enforcedOptionsOFT = [
80+
{
81+
eid: eidA,
82+
msgType: await zamaOFT.SEND(),
83+
options: Options.newOptions().addExecutorLzReceiveOption(50000, 0).toHex().toString(),
84+
},
85+
];
86+
await zamaOFT.setEnforcedOptions(enforcedOptionsOFT);
87+
const enforcedOptionsOFTAdapter = [
88+
{
89+
eid: eidB,
90+
msgType: await zamaOFTAdapter.SEND(),
91+
options: Options.newOptions().addExecutorLzReceiveOption(50000, 0).toHex().toString(),
92+
},
93+
];
94+
await zamaOFTAdapter.setEnforcedOptions(enforcedOptionsOFTAdapter);
7795
});
7896

7997
describe("ProtocolFeesBurner", () => {
@@ -224,10 +242,7 @@ describe("FeesBurner", () => {
224242
it("should properly quote native fees for bridging", async () => {
225243
const quotedFees = await feesSenderToBurner.quote();
226244

227-
await expect(feesSenderToBurner.sendFeesToBurner({ value: quotedFees - 1n })).to.be.revertedWithCustomError(
228-
feesSenderToBurnerInterface,
229-
"InsufficientFee",
230-
);
245+
await expect(feesSenderToBurner.sendFeesToBurner({ value: quotedFees - 1n })).to.be.revertedWith('LayerZeroMock: not enough native for fees');
231246
expect(await feesSenderToBurner.sendFeesToBurner({ value: quotedFees })).not.to.be.reverted;
232247
});
233248

protocol-contracts/token/layerzero.config.mainnet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const EVM_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
2626
{
2727
msgType: 1,
2828
optionType: ExecutorOptionType.LZ_RECEIVE,
29-
gas: 80000,
29+
gas: 50000,
3030
value: 0,
3131
},
3232
]

protocol-contracts/token/layerzero.config.testnet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const EVM_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
2525
{
2626
msgType: 1,
2727
optionType: ExecutorOptionType.LZ_RECEIVE,
28-
gas: 80000,
28+
gas: 50000,
2929
value: 0,
3030
},
3131
]

0 commit comments

Comments
 (0)