Skip to content

Commit

Permalink
fix key storage in peptide iaval proof
Browse files Browse the repository at this point in the history
  • Loading branch information
RnkSngh committed Dec 5, 2024
1 parent 1272b6c commit 1dcd580
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 23 deletions.
4 changes: 2 additions & 2 deletions contracts/core/proofAPI/CrossL2Prover.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pragma solidity ^0.8.0;
import {RLPReader} from "optimism/libraries/rlp/RLPReader.sol";
import {MerkleTrie} from "optimism/libraries/trie/MerkleTrie.sol";
import {Bytes} from "optimism/libraries/Bytes.sol";
import {PolymerProofs} from "../../libs/PolymerProofs.sol";
import {Ibc} from "../../libs/Ibc.sol";
import {AppStateVerifier} from "../../base/AppStateVerifier.sol";
import {ICrossL2Prover} from "../../interfaces/ICrossL2Prover.sol";
import {Ics23Proof} from "../../interfaces/IProofVerifier.sol";
Expand Down Expand Up @@ -61,7 +61,7 @@ contract CrossL2Prover is AppStateVerifier, ICrossL2Prover {
// given eventHeight has the receipt root at the peptide height
this.verifyMembership(
bytes32(_getPeptideAppHash(peptideAppProof.height)),
PolymerProofs.receiptProofKey(peptideClientId, eventHeight),
Ibc.receiptRootKey(peptideClientId, eventHeight),
abi.encodePacked(receiptRoot),
peptideAppProof
);
Expand Down
4 changes: 4 additions & 0 deletions contracts/libs/Ibc.sol
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,8 @@ library Ibc {

outStr = string(buffer);
}

function receiptRootKey(string memory clientId, uint256 height) internal pure returns (bytes memory proofKey) {
proofKey = abi.encodePacked("client/", clientId, "/receiptRoot/", toStr(height));
}
}
10 changes: 5 additions & 5 deletions contracts/libs/PolymerProofs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

pragma solidity ^0.8.0;

// import {Ibc} from "./Ibc.sol";

/**
* A library for helpers for proving peptide state
*/
library PolymerProofs {
function receiptProofKey(string memory clientId, uint64 height) internal pure returns (bytes memory proofKey) {
proofKey = abi.encodePacked("polyibc/client/", clientId, "/receiptRoot/", height);
}
}
// library PolymerProofs {

// }
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.12",
"version": "4.0.13",
"main": "dist/index.js",
"bin": {
"verify-vibc-core-smart-contracts": "./dist/scripts/verify-contract-script.js",
Expand Down
2 changes: 1 addition & 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.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/evm/contracts/factories/FeeVault__factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const _abi = [
] as const;

const _bytecode =
"0x608060405234801561001057600080fd5b5061001a33610024565b600160025561009b565b600180546001600160a01b03191690556100488161004b602090811b6103f617901c565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6109c5806100aa6000396000f3fe60806040526004361061007b5760003560e01c80638da5cb5b1161004e5780638da5cb5b146100d4578063e30c39781461010a578063f2fde38b14610128578063fce34e401461014857600080fd5b80630be6a22d1461008057806318e3404b14610097578063715018a6146100aa57806379ba5097146100bf575b600080fd5b34801561008c57600080fd5b5061009561015b565b005b6100956100a5366004610527565b610198565b3480156100b657600080fd5b50610095610275565b3480156100cb57600080fd5b50610095610289565b3480156100e057600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b34801561011657600080fd5b506001546001600160a01b03166100ee565b34801561013457600080fd5b506100956101433660046105a1565b610300565b610095610156366004610676565b610371565b600080546040516001600160a01b03909116914780156108fc02929091818181858888f19350505050158015610195573d6000803e3d6000fd5b50565b6101a0610446565b633b9aca003410156101c557604051633b9b24db60e01b815260040160405180910390fd5b60006101d9602080840135908501356107b4565b6101e5833585356107b4565b6101ef91906107d3565b905034811461021f57604051635c6dd11360e11b8152600481018290523460248201526044015b60405180910390fd5b8367ffffffffffffffff16857f0733dc80f277e205edf5d913fa5d91fa0c4cc2635db600b365471c688356c034858560405161025c9291906107eb565b60405180910390a35061026f6001600255565b50505050565b61027d61049d565b61028760006104f7565b565b60015433906001600160a01b031681146102f75760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610216565b610195816104f7565b61030861049d565b600180546001600160a01b0383166001600160a01b031990911681179091556103396000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b610379610446565b633b9aca0034101561039e57604051633b9b24db60e01b815260040160405180910390fd5b7f8ab5595b5ac9231b64513ba86f6bd9fb73c51cae40c36083f7dfc2298e4429e687878787878787346040516103db9897969594939291906108e4565b60405180910390a16103ed6001600255565b50505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60028054036104975760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610216565b60028055565b6000546001600160a01b031633146102875760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610216565b600180546001600160a01b0319169055610195816103f6565b806040810183101561052157600080fd5b92915050565b60008060008060c0858703121561053d57600080fd5b84359350602085013567ffffffffffffffff8116811461055c57600080fd5b925061056b8660408701610510565b915061057a8660808701610510565b905092959194509250565b80356001600160a01b038116811461059c57600080fd5b919050565b6000602082840312156105b357600080fd5b6105bc82610585565b9392505050565b634e487b7160e01b600052604160045260246000fd5b80356003811061059c57600080fd5b60008083601f8401126105fa57600080fd5b50813567ffffffffffffffff81111561061257600080fd5b6020830191508360208260051b850101111561062d57600080fd5b9250929050565b60008083601f84011261064657600080fd5b50813567ffffffffffffffff81111561065e57600080fd5b60208301915083602082850101111561062d57600080fd5b600080600080600080600060a0888a03121561069157600080fd5b61069a88610585565b9650602088013567ffffffffffffffff808211156106b757600080fd5b818a0191508a601f8301126106cb57600080fd5b8135818111156106dd576106dd6105c3565b604051601f8201601f19908116603f01168101908382118183101715610705576107056105c3565b816040528281528d602084870101111561071e57600080fd5b82602086016020830137600060208483010152809a5050505061074360408b016105d9565b965060608a013591508082111561075957600080fd5b6107658b838c016105e8565b909650945060808a013591508082111561077e57600080fd5b5061078b8a828b01610634565b989b979a50959850939692959293505050565b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156107ce576107ce61079e565b500290565b600082198211156107e6576107e661079e565b500190565b6080810160408483376040836040840137600081529392505050565b6003811061082557634e487b7160e01b600052602160045260246000fd5b9052565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b81835260006020808501808196508560051b810191508460005b878110156108d75782840389528135601e1988360301811261088d57600080fd5b8701858101903567ffffffffffffffff8111156108a957600080fd5b8036038213156108b857600080fd5b6108c3868284610829565b9a87019a955050509084019060010161086c565b5091979650505050505050565b60018060a01b03891681526000602060c08184015289518060c085015260005b81811015610920578b810183015185820160e001528201610904565b8181111561093257600060e083870101525b50601f01601f19168301905061094b604084018a610807565b60e083820301606084015261096460e08201888a610852565b90508281036080840152610979818688610829565b9150508260a0830152999850505050505050505056fea2646970667358221220985400b23e75aef756ccffd261d4e62b564e0cf9d1ed69d75c306116c6a66b7864736f6c634300080f0033";
"0x608060405234801561001057600080fd5b5061001a33610024565b600160025561009b565b600180546001600160a01b03191690556100488161004b602090811b6103f617901c565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6109c5806100aa6000396000f3fe60806040526004361061007b5760003560e01c80638da5cb5b1161004e5780638da5cb5b146100d4578063e30c39781461010a578063f2fde38b14610128578063fce34e401461014857600080fd5b80630be6a22d1461008057806318e3404b14610097578063715018a6146100aa57806379ba5097146100bf575b600080fd5b34801561008c57600080fd5b5061009561015b565b005b6100956100a5366004610527565b610198565b3480156100b657600080fd5b50610095610275565b3480156100cb57600080fd5b50610095610289565b3480156100e057600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200160405180910390f35b34801561011657600080fd5b506001546001600160a01b03166100ee565b34801561013457600080fd5b506100956101433660046105a1565b610300565b610095610156366004610676565b610371565b600080546040516001600160a01b03909116914780156108fc02929091818181858888f19350505050158015610195573d6000803e3d6000fd5b50565b6101a0610446565b633b9aca003410156101c557604051633b9b24db60e01b815260040160405180910390fd5b60006101d9602080840135908501356107b4565b6101e5833585356107b4565b6101ef91906107d3565b905034811461021f57604051635c6dd11360e11b8152600481018290523460248201526044015b60405180910390fd5b8367ffffffffffffffff16857f0733dc80f277e205edf5d913fa5d91fa0c4cc2635db600b365471c688356c034858560405161025c9291906107eb565b60405180910390a35061026f6001600255565b50505050565b61027d61049d565b61028760006104f7565b565b60015433906001600160a01b031681146102f75760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610216565b610195816104f7565b61030861049d565b600180546001600160a01b0383166001600160a01b031990911681179091556103396000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b610379610446565b633b9aca0034101561039e57604051633b9b24db60e01b815260040160405180910390fd5b7f8ab5595b5ac9231b64513ba86f6bd9fb73c51cae40c36083f7dfc2298e4429e687878787878787346040516103db9897969594939291906108e4565b60405180910390a16103ed6001600255565b50505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60028054036104975760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610216565b60028055565b6000546001600160a01b031633146102875760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610216565b600180546001600160a01b0319169055610195816103f6565b806040810183101561052157600080fd5b92915050565b60008060008060c0858703121561053d57600080fd5b84359350602085013567ffffffffffffffff8116811461055c57600080fd5b925061056b8660408701610510565b915061057a8660808701610510565b905092959194509250565b80356001600160a01b038116811461059c57600080fd5b919050565b6000602082840312156105b357600080fd5b6105bc82610585565b9392505050565b634e487b7160e01b600052604160045260246000fd5b80356003811061059c57600080fd5b60008083601f8401126105fa57600080fd5b50813567ffffffffffffffff81111561061257600080fd5b6020830191508360208260051b850101111561062d57600080fd5b9250929050565b60008083601f84011261064657600080fd5b50813567ffffffffffffffff81111561065e57600080fd5b60208301915083602082850101111561062d57600080fd5b600080600080600080600060a0888a03121561069157600080fd5b61069a88610585565b9650602088013567ffffffffffffffff808211156106b757600080fd5b818a0191508a601f8301126106cb57600080fd5b8135818111156106dd576106dd6105c3565b604051601f8201601f19908116603f01168101908382118183101715610705576107056105c3565b816040528281528d602084870101111561071e57600080fd5b82602086016020830137600060208483010152809a5050505061074360408b016105d9565b965060608a013591508082111561075957600080fd5b6107658b838c016105e8565b909650945060808a013591508082111561077e57600080fd5b5061078b8a828b01610634565b989b979a50959850939692959293505050565b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156107ce576107ce61079e565b500290565b600082198211156107e6576107e661079e565b500190565b6080810160408483376040836040840137600081529392505050565b6003811061082557634e487b7160e01b600052602160045260246000fd5b9052565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b81835260006020808501808196508560051b810191508460005b878110156108d75782840389528135601e1988360301811261088d57600080fd5b8701858101903567ffffffffffffffff8111156108a957600080fd5b8036038213156108b857600080fd5b6108c3868284610829565b9a87019a955050509084019060010161086c565b5091979650505050505050565b60018060a01b03891681526000602060c08184015289518060c085015260005b81811015610920578b810183015185820160e001528201610904565b8181111561093257600060e083870101525b50601f01601f19168301905061094b604084018a610807565b60e083820301606084015261096460e08201888a610852565b90508281036080840152610979818688610829565b9150508260a0830152999850505050505050505056fea264697066735822122001cd678ed5c129d8e0ac339228a23cdf728071ee33e29c62d73a54e7acaf89c064736f6c634300080f0033";

type FeeVaultConstructorParams =
| [signer?: Signer]
Expand Down
2 changes: 1 addition & 1 deletion src/evm/contracts/factories/IbcUtils__factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const _abi = [
] as const;

const _bytecode =
"0x61067e61003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100405760003560e01c8063a1ef9a9814610045578063d5c39a9d14610075575b600080fd5b6100586100533660046103a1565b610095565b6040516001600160a01b0390911681526020015b60405180910390f35b610088610083366004610452565b610260565b60405161006c91906104c4565b805160009082906028146100bc576040516305229b2360e41b815260040160405180910390fd5b6000600160285b801561025657806100d381610555565b915050600060308583815181106100ec576100ec61056c565b016020015160f81c1080159061011c575060398583815181106101115761011161056c565b016020015160f81c11155b156101515760308583815181106101355761013561056c565b0160200151610147919060f81c610582565b60ff169050610224565b60418583815181106101655761016561056c565b016020015160f81c108015906101955750604685838151811061018a5761018a61056c565b016020015160f81c11155b156101ae5760378583815181106101355761013561056c565b60618583815181106101c2576101c261056c565b016020015160f81c108015906101f2575060668583815181106101e7576101e761056c565b016020015160f81c11155b1561020b5760578583815181106101355761013561056c565b60405163f379095160e01b815260040160405180910390fd5b61022d8361031a565b61023790826105a5565b61024190856105d4565b935061024e6010846105ff565b9250506100c3565b5090949350505050565b604080516080810182526000808252602082018190529181019190915260608082015260008060006020866000376000519250602080870160003760005191506020604087016000375060005160408051608081018252848152602081018490529081018290526060808201906102da908890818b61061e565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152509695505050505050565b60006001600160a01b038211156103875760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663630206269747360c81b606482015260840160405180910390fd5b5090565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156103b357600080fd5b813567ffffffffffffffff808211156103cb57600080fd5b818401915084601f8301126103df57600080fd5b8135818111156103f1576103f161038b565b604051601f8201601f19908116603f011681019083821181831017156104195761041961038b565b8160405282815287602084870101111561043257600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000806020838503121561046557600080fd5b823567ffffffffffffffff8082111561047d57600080fd5b818501915085601f83011261049157600080fd5b8135818111156104a057600080fd5b8660208285010111156104b257600080fd5b60209290920196919550909350505050565b6000602080835283518184015280840151604084015260408401516060840152606084015160808085015280518060a086015260005b818110156105165782810184015186820160c0015283016104fa565b8181111561052857600060c083880101525b50601f01601f19169390930160c001949350505050565b634e487b7160e01b600052601160045260246000fd5b6000816105645761056461053f565b506000190190565b634e487b7160e01b600052603260045260246000fd5b600060ff821660ff84168082101561059c5761059c61053f565b90039392505050565b60006001600160a01b03828116848216811515828404821116156105cb576105cb61053f565b02949350505050565b60006001600160a01b038281168482168083038211156105f6576105f661053f565b01949350505050565b60008160001904831182151516156106195761061961053f565b500290565b6000808585111561062e57600080fd5b8386111561063b57600080fd5b505082019391909203915056fea264697066735822122079dd979e13228315fd9cb9058695caa4197f6233242b5a6519e10129a3762dba64736f6c634300080f0033";
"0x61067e61003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100405760003560e01c8063a1ef9a9814610045578063d5c39a9d14610075575b600080fd5b6100586100533660046103a1565b610095565b6040516001600160a01b0390911681526020015b60405180910390f35b610088610083366004610452565b610260565b60405161006c91906104c4565b805160009082906028146100bc576040516305229b2360e41b815260040160405180910390fd5b6000600160285b801561025657806100d381610555565b915050600060308583815181106100ec576100ec61056c565b016020015160f81c1080159061011c575060398583815181106101115761011161056c565b016020015160f81c11155b156101515760308583815181106101355761013561056c565b0160200151610147919060f81c610582565b60ff169050610224565b60418583815181106101655761016561056c565b016020015160f81c108015906101955750604685838151811061018a5761018a61056c565b016020015160f81c11155b156101ae5760378583815181106101355761013561056c565b60618583815181106101c2576101c261056c565b016020015160f81c108015906101f2575060668583815181106101e7576101e761056c565b016020015160f81c11155b1561020b5760578583815181106101355761013561056c565b60405163f379095160e01b815260040160405180910390fd5b61022d8361031a565b61023790826105a5565b61024190856105d4565b935061024e6010846105ff565b9250506100c3565b5090949350505050565b604080516080810182526000808252602082018190529181019190915260608082015260008060006020866000376000519250602080870160003760005191506020604087016000375060005160408051608081018252848152602081018490529081018290526060808201906102da908890818b61061e565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152509695505050505050565b60006001600160a01b038211156103875760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663630206269747360c81b606482015260840160405180910390fd5b5090565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156103b357600080fd5b813567ffffffffffffffff808211156103cb57600080fd5b818401915084601f8301126103df57600080fd5b8135818111156103f1576103f161038b565b604051601f8201601f19908116603f011681019083821181831017156104195761041961038b565b8160405282815287602084870101111561043257600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000806020838503121561046557600080fd5b823567ffffffffffffffff8082111561047d57600080fd5b818501915085601f83011261049157600080fd5b8135818111156104a057600080fd5b8660208285010111156104b257600080fd5b60209290920196919550909350505050565b6000602080835283518184015280840151604084015260408401516060840152606084015160808085015280518060a086015260005b818110156105165782810184015186820160c0015283016104fa565b8181111561052857600060c083880101525b50601f01601f19169390930160c001949350505050565b634e487b7160e01b600052601160045260246000fd5b6000816105645761056461053f565b506000190190565b634e487b7160e01b600052603260045260246000fd5b600060ff821660ff84168082101561059c5761059c61053f565b90039392505050565b60006001600160a01b03828116848216811515828404821116156105cb576105cb61053f565b02949350505050565b60006001600160a01b038281168482168083038211156105f6576105f661053f565b01949350505050565b60008160001904831182151516156106195761061961053f565b500290565b6000808585111561062e57600080fd5b8386111561063b57600080fd5b505082019391909203915056fea26469706673582212201f34776aed94ab15d9d2ee6f61f827e0dbb7b1958ccbec0023d6174f4921e86764736f6c634300080f0033";

type IbcUtilsConstructorParams =
| [signer?: Signer]
Expand Down
Loading

0 comments on commit 1dcd580

Please sign in to comment.