Skip to content

Commit

Permalink
patch address & topics parsing in parseLog
Browse files Browse the repository at this point in the history
  • Loading branch information
RnkSngh committed Dec 20, 2024
1 parent edc2503 commit 0530f6c
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bindings/go/crossl2prover/CrossL2Prover.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion contracts/libs/Ibc.sol
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ struct Proof {
}

library Ibc {
error invalidAddressBytes();

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

function bytesToAddr(bytes memory a) public pure returns (address addr) {
if (a.length != 20) {
revert invalidAddressBytes();
}
assembly {
addr := mload(add(a, 20))
}
}

function parseLog(uint256 logIndex, bytes memory receiptRLP)
internal
pure
Expand Down Expand Up @@ -315,11 +326,13 @@ library Ibc {
// }
RLPReader.RLPItem[] memory log = RLPReader.readList(RLPReader.readList(receipt[3])[logIndex]);

emittingContract = address(uint160(uint256(bytes32(RLPReader.readBytes(log[0])))));
emittingContract = bytesToAddr(RLPReader.readBytes(log[0]));

RLPReader.RLPItem[] memory encodedTopics = RLPReader.readList(log[1]);
unindexedData = (RLPReader.readBytes(log[2])); // This is the raw unindexed data. in this case it's
// just an abi encoded uint64

topics = new bytes[](encodedTopics.length);
for (uint256 i = 0; i < encodedTopics.length; i++) {
topics[i] = RLPReader.readBytes(encodedTopics[i]);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@open-ibc/vibc-core-smart-contracts",
"version": "4.0.18",
"version": "4.0.19",
"main": "dist/index.js",
"bin": {
"verify-vibc-core-smart-contracts": "./dist/scripts/verify-contract-script.js",
Expand Down
14 changes: 14 additions & 0 deletions src/evm/contracts/Ibc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface IbcInterface extends Interface {
nameOrSignature:
| "ackProofKey"
| "ackProofValue"
| "bytesToAddr"
| "channelProofKey"
| "channelProofKeyMemory"
| "channelProofValue"
Expand All @@ -93,6 +94,10 @@ export interface IbcInterface extends Interface {
functionFragment: "ackProofValue",
values: [BytesLike]
): string;
encodeFunctionData(
functionFragment: "bytesToAddr",
values: [BytesLike]
): string;
encodeFunctionData(
functionFragment: "channelProofKey",
values: [string, BytesLike]
Expand Down Expand Up @@ -138,6 +143,10 @@ export interface IbcInterface extends Interface {
functionFragment: "ackProofValue",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "bytesToAddr",
data: BytesLike
): Result;
decodeFunctionResult(
functionFragment: "channelProofKey",
data: BytesLike
Expand Down Expand Up @@ -223,6 +232,8 @@ export interface Ibc extends BaseContract {

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

bytesToAddr: TypedContractMethod<[a: BytesLike], [string], "view">;

channelProofKey: TypedContractMethod<
[portId: string, channelId: BytesLike],
[string],
Expand Down Expand Up @@ -297,6 +308,9 @@ export interface Ibc extends BaseContract {
getFunction(
nameOrSignature: "ackProofValue"
): TypedContractMethod<[ack: BytesLike], [string], "view">;
getFunction(
nameOrSignature: "bytesToAddr"
): TypedContractMethod<[a: BytesLike], [string], "view">;
getFunction(
nameOrSignature: "channelProofKey"
): TypedContractMethod<
Expand Down
7 changes: 6 additions & 1 deletion src/evm/contracts/factories/CrossL2Prover__factory.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/evm/contracts/factories/Dispatcher__factory.ts

Large diffs are not rendered by default.

Loading

0 comments on commit 0530f6c

Please sign in to comment.