Skip to content

Commit 2c480fa

Browse files
committed
patch address & topics parsing in parseLog
1 parent edc2503 commit 2c480fa

18 files changed

+73
-17
lines changed

bindings/go/crossl2prover/CrossL2Prover.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/libs/Ibc.sol

+14-1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ struct Proof {
150150
}
151151

152152
library Ibc {
153+
error invalidAddressBytes();
154+
153155
// https://github.com/open-ibc/ibcx-go/blob/ef80dd6784fd/modules/core/24-host/keys.go#L135
154156
function channelProofKey(string calldata portId, bytes32 channelId) external pure returns (bytes memory proofKey) {
155157
proofKey = abi.encodePacked("channelEnds/ports/", portId, "/channels/", toStr(channelId));
@@ -288,6 +290,15 @@ library Ibc {
288290
outStr = string(buffer);
289291
}
290292

293+
function bytesToAddr(bytes memory a) public pure returns (address addr) {
294+
if (a.length != 20) {
295+
revert invalidAddressBytes();
296+
}
297+
assembly {
298+
addr := mload(add(a, 20))
299+
}
300+
}
301+
291302
function parseLog(uint256 logIndex, bytes memory receiptRLP)
292303
internal
293304
pure
@@ -315,11 +326,13 @@ library Ibc {
315326
// }
316327
RLPReader.RLPItem[] memory log = RLPReader.readList(RLPReader.readList(receipt[3])[logIndex]);
317328

318-
emittingContract = address(uint160(uint256(bytes32(RLPReader.readBytes(log[0])))));
329+
emittingContract = bytesToAddr(RLPReader.readBytes(log[0]));
330+
319331
RLPReader.RLPItem[] memory encodedTopics = RLPReader.readList(log[1]);
320332
unindexedData = (RLPReader.readBytes(log[2])); // This is the raw unindexed data. in this case it's
321333
// just an abi encoded uint64
322334

335+
topics = new bytes[](encodedTopics.length);
323336
for (uint256 i = 0; i < encodedTopics.length; i++) {
324337
topics[i] = RLPReader.readBytes(encodedTopics[i]);
325338
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@open-ibc/vibc-core-smart-contracts",
3-
"version": "4.0.18",
3+
"version": "4.0.19",
44
"main": "dist/index.js",
55
"bin": {
66
"verify-vibc-core-smart-contracts": "./dist/scripts/verify-contract-script.js",

src/evm/contracts/Ibc.ts

+14
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export interface IbcInterface extends Interface {
7474
nameOrSignature:
7575
| "ackProofKey"
7676
| "ackProofValue"
77+
| "bytesToAddr"
7778
| "channelProofKey"
7879
| "channelProofKeyMemory"
7980
| "channelProofValue"
@@ -93,6 +94,10 @@ export interface IbcInterface extends Interface {
9394
functionFragment: "ackProofValue",
9495
values: [BytesLike]
9596
): string;
97+
encodeFunctionData(
98+
functionFragment: "bytesToAddr",
99+
values: [BytesLike]
100+
): string;
96101
encodeFunctionData(
97102
functionFragment: "channelProofKey",
98103
values: [string, BytesLike]
@@ -138,6 +143,10 @@ export interface IbcInterface extends Interface {
138143
functionFragment: "ackProofValue",
139144
data: BytesLike
140145
): Result;
146+
decodeFunctionResult(
147+
functionFragment: "bytesToAddr",
148+
data: BytesLike
149+
): Result;
141150
decodeFunctionResult(
142151
functionFragment: "channelProofKey",
143152
data: BytesLike
@@ -223,6 +232,8 @@ export interface Ibc extends BaseContract {
223232

224233
ackProofValue: TypedContractMethod<[ack: BytesLike], [string], "view">;
225234

235+
bytesToAddr: TypedContractMethod<[a: BytesLike], [string], "view">;
236+
226237
channelProofKey: TypedContractMethod<
227238
[portId: string, channelId: BytesLike],
228239
[string],
@@ -297,6 +308,9 @@ export interface Ibc extends BaseContract {
297308
getFunction(
298309
nameOrSignature: "ackProofValue"
299310
): TypedContractMethod<[ack: BytesLike], [string], "view">;
311+
getFunction(
312+
nameOrSignature: "bytesToAddr"
313+
): TypedContractMethod<[a: BytesLike], [string], "view">;
300314
getFunction(
301315
nameOrSignature: "channelProofKey"
302316
): TypedContractMethod<

src/evm/contracts/factories/CrossL2Prover__factory.ts

+6-1
Large diffs are not rendered by default.

src/evm/contracts/factories/Dispatcher__factory.ts

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)