Skip to content

Commit

Permalink
Merge pull request #19 from exp-table/fix-remapping
Browse files Browse the repository at this point in the history
fix: remappings
  • Loading branch information
sujithsomraaj authored Aug 11, 2023
2 parents 47583a6 + 09569cf commit f2543a0
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 28 deletions.
10 changes: 5 additions & 5 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ AxelarHelperTest:testFancyAxelar() (gas: 177347)
AxelarHelperTest:testMultiDstAxelar() (gas: 274247)
AxelarHelperTest:testSimpleAxelar() (gas: 132177)
CelerHelperTest:testCustomOrderingCeler() (gas: 107604)
CelerHelperTest:testFancyCeler() (gas: 122912)
CelerHelperTest:testFancyCeler() (gas: 118268)
CelerHelperTest:testMultiDstCeler() (gas: 151019)
CelerHelperTest:testSimpleCeler() (gas: 71721)
CelerHelperTest:testSimpleCelerWithEstimates() (gas: 77441)
CelerHelperTest:testSimpleCelerWithEstimates() (gas: 72938)
HyperlaneHelperTest:testCustomOrderingHL() (gas: 144068)
HyperlaneHelperTest:testFancyHL() (gas: 145759)
HyperlaneHelperTest:testMultiDstHL() (gas: 191075)
Expand All @@ -16,12 +16,12 @@ LayerZeroHelperTest:testCustomOrderingLZ() (gas: 338253)
LayerZeroHelperTest:testFancyLZ() (gas: 294802)
LayerZeroHelperTest:testMultiDstLZ() (gas: 472512)
LayerZeroHelperTest:testSimpleLZ() (gas: 244928)
LayerZeroHelperTest:testSimpleLZWithEstimates() (gas: 309700)
LayerZeroHelperTest:testSimpleLZWithEstimates() (gas: 245786)
StargateHelperTest:testCustomOrderingSG() (gas: 802092)
StargateHelperTest:testFancySG() (gas: 591546)
StargateHelperTest:testSimpleSG() (gas: 539546)
StargateHelperTest:testSimpleSGWithEstimates() (gas: 605941)
StargateHelperTest:testSimpleSGWithEstimates() (gas: 540819)
WormholeHelperTest:testCustomOrderingWormhole() (gas: 288455)
WormholeHelperTest:testFancyWormhole() (gas: 227694)
WormholeHelperTest:testMultiDstWormhole() (gas: 353402)
WormholeHelperTest:testMultiDstWormhole() (gas: 353375)
WormholeHelperTest:testSimpleWormhole() (gas: 181430)
1 change: 0 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
solady/=lib/solady/src/
solmate/=lib/solmate/src/
lib/forge-std:ds-test/=lib/forge-std/lib/ds-test/src/
lib/solady:ds-test/=lib/solady/lib/forge-std/lib/ds-test/src/
Expand Down
2 changes: 1 addition & 1 deletion src/celer/CelerHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity >=0.8.0;
import "forge-std/Test.sol";
import "forge-std/console.sol";

import "solady/utils/LibString.sol";
import "solady/src/utils/LibString.sol";
import {TypeCasts} from "../libraries/TypeCasts.sol";

interface IMessageBus {
Expand Down
2 changes: 1 addition & 1 deletion src/hyperlane/HyperlaneHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity >=0.8.0;

import "forge-std/Test.sol";
import "solady/utils/LibString.sol";
import "solady/src/utils/LibString.sol";

import {TypeCasts} from "../libraries/TypeCasts.sol";

Expand Down
61 changes: 41 additions & 20 deletions src/layerzero/lib/LZPacket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity >=0.7.6;

import "./Buffer.sol";
import "solady/utils/DynamicBufferLib.sol";
import "solady/src/utils/DynamicBufferLib.sol";

library LayerZeroPacket {
using Buffer for Buffer.buffer;
Expand All @@ -19,7 +19,9 @@ library LayerZeroPacket {
bytes payload;
}

function getPacket(bytes memory data) internal pure returns (Packet memory) {
function getPacket(
bytes memory data
) internal pure returns (Packet memory) {
Packet memory packet;
uint256 realSize;
uint64 nonce;
Expand All @@ -40,7 +42,7 @@ library LayerZeroPacket {
DynamicBufferLib.DynamicBuffer memory payloadBuffer;
uint256 start = 84; // 32 + 52 bytes
uint256 size = realSize + 32 - 84; // 64 bytes
for (uint256 i = start; i < start + size;) {
for (uint256 i = start; i < start + size; ) {
bytes32 toAdd;
assembly {
toAdd := mload(add(data, i))
Expand All @@ -57,11 +59,11 @@ library LayerZeroPacket {
return packet;
}

function getPacketV2(bytes memory data, uint256 sizeOfSrcAddress, bytes32 ulnAddress)
internal
pure
returns (LayerZeroPacket.Packet memory)
{
function getPacketV2(
bytes memory data,
uint256 sizeOfSrcAddress,
bytes32 ulnAddress
) internal pure returns (LayerZeroPacket.Packet memory) {
// packet def: abi.encodePacked(nonce, srcChain, srcAddress, dstChain, dstAddress, payload);
// data def: abi.encode(packet) = offset(32) + length(32) + packet
// if from EVM
Expand Down Expand Up @@ -101,16 +103,23 @@ library LayerZeroPacket {
// payloadBuffer.init(payloadSize);
// payloadBuffer.writeRawBytes(0, data, nonPayloadSize + 96, payloadSize);

return LayerZeroPacket.Packet(
srcChain, dstChain, nonce, dstAddress, srcAddressBuffer.buf, ulnAddress, payloadBuffer.buf
);
return
LayerZeroPacket.Packet(
srcChain,
dstChain,
nonce,
dstAddress,
srcAddressBuffer.buf,
ulnAddress,
payloadBuffer.buf
);
}

function getPacketV3(bytes memory data, uint256 sizeOfSrcAddress, bytes32 ulnAddress)
internal
pure
returns (LayerZeroPacket.Packet memory)
{
function getPacketV3(
bytes memory data,
uint256 sizeOfSrcAddress,
bytes32 ulnAddress
) internal pure returns (LayerZeroPacket.Packet memory) {
// data def: abi.encodePacked(nonce, srcChain, srcAddress, dstChain, dstAddress, payload);
// if from EVM
// 0 - 31 0 - 31 | total bytes size
Expand Down Expand Up @@ -147,11 +156,23 @@ library LayerZeroPacket {
Buffer.buffer memory payloadBuffer;
if (payloadSize > 0) {
payloadBuffer.init(payloadSize);
payloadBuffer.writeRawBytes(0, data, nonPayloadSize + 32, payloadSize);
payloadBuffer.writeRawBytes(
0,
data,
nonPayloadSize + 32,
payloadSize
);
}

return LayerZeroPacket.Packet(
srcChain, dstChain, nonce, dstAddress, srcAddressBuffer.buf, ulnAddress, payloadBuffer.buf
);
return
LayerZeroPacket.Packet(
srcChain,
dstChain,
nonce,
dstAddress,
srcAddressBuffer.buf,
ulnAddress,
payloadBuffer.buf
);
}
}

0 comments on commit f2543a0

Please sign in to comment.