Skip to content

Commit

Permalink
Merge pull request #6 from datachainlab/fix-ibc-commitments
Browse files Browse the repository at this point in the history
Fix ibc commitments slot

Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele authored Aug 23, 2024
2 parents f98a784 + 46403ba commit 9e22c23
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
1 change: 1 addition & 0 deletions e2e/enclave/Cargo.lock

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

10 changes: 5 additions & 5 deletions e2e/package-lock.json

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

2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"description": "A hardhat example project with ibc-solidity",
"devDependencies": {
"@hyperledger-labs/yui-ibc-solidity": "git+https://github.com/hyperledger-labs/yui-ibc-solidity.git#v0.3.34",
"@hyperledger-labs/yui-ibc-solidity": "git+https://github.com/hyperledger-labs/yui-ibc-solidity.git#semver:=v0.3.35",
"@datachainlab/lcp-solidity": "git+https://github.com/datachainlab/lcp-solidity.git#v0.1.14",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"chai": "^4.3.10",
Expand Down
6 changes: 3 additions & 3 deletions e2e/relayer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/datachainlab/besu-qbft-elc/e2e/relayer
go 1.21

require (
github.com/datachainlab/besu-ibc-relay-prover v0.2.3
github.com/datachainlab/besu-ibc-relay-prover v0.2.4
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.4
github.com/datachainlab/lcp-go v0.2.8
github.com/hyperledger-labs/yui-relayer v0.5.4
github.com/datachainlab/lcp-go v0.2.10
github.com/hyperledger-labs/yui-relayer v0.5.7
)

require (
Expand Down
12 changes: 6 additions & 6 deletions e2e/relayer/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,12 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
github.com/datachainlab/besu-ibc-relay-prover v0.2.3 h1:PDs6Zsl7MpZycCFALl6ada/hhY70me+GcXe8j5ECM34=
github.com/datachainlab/besu-ibc-relay-prover v0.2.3/go.mod h1:iGGXFJPvchz6iQSgqK5CrjHwVyWxzwCzIrBE6qiX0Kc=
github.com/datachainlab/besu-ibc-relay-prover v0.2.4 h1:dtAk1TRDCFYwqfIat0cJnPYGEsZ1hIH3xnjyTzrmo1c=
github.com/datachainlab/besu-ibc-relay-prover v0.2.4/go.mod h1:iGGXFJPvchz6iQSgqK5CrjHwVyWxzwCzIrBE6qiX0Kc=
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.4 h1:2mbvy6W/lm11SeQBgj1100A6D/70Wk9DooMoZfE8oXU=
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.4/go.mod h1:PdSsegkRJiMWVGq+afDtXKRKg4p8hnmR1Yj5BgXkit0=
github.com/datachainlab/lcp-go v0.2.8 h1:Bd6w4CetoUibPuuwWJ75XT6Q/s69gcXfvUS5ffnpYmg=
github.com/datachainlab/lcp-go v0.2.8/go.mod h1:0ivRb4qUiZz5UQxsbRKygQyFz0XC6TIC6YpEUdOc1So=
github.com/datachainlab/lcp-go v0.2.10 h1:1c8C+HR+tC/4NjCjpuz+Nkk3I/uIQ3PNRcvJKsSU948=
github.com/datachainlab/lcp-go v0.2.10/go.mod h1:0ivRb4qUiZz5UQxsbRKygQyFz0XC6TIC6YpEUdOc1So=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -779,8 +779,8 @@ github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXM
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
github.com/hyperledger-labs/yui-relayer v0.5.4 h1:yhvWI28Rcel55UsdmYWX0QE0W3P9aBSRetQh1k8VpZA=
github.com/hyperledger-labs/yui-relayer v0.5.4/go.mod h1:GeCb1dtZjtQdkBNw1L9+LAUHzNQQhQK+kkoOnZYffw0=
github.com/hyperledger-labs/yui-relayer v0.5.7 h1:ib1Q+l+lP+3MtvSy9w4GJQ0EiJbMnF5caQ4Px9byDZo=
github.com/hyperledger-labs/yui-relayer v0.5.7/go.mod h1:GeCb1dtZjtQdkBNw1L9+LAUHzNQQhQK+kkoOnZYffw0=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
4 changes: 1 addition & 3 deletions elc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ tiny-keccak = { version = "1.4" }
libsecp256k1 = { version = "0.7.1", default-features = false, features = ["static-context", "hmac"] }
rlp = { version = "0.5.2", default-features = false }
ruint = { version = "1.12.3", default-features = false, features = ["serde"] }
hex-literal = "0.4.1"

light-client = { git = "https://github.com/datachainlab/lcp", rev = "v0.2.9", default-features = false }
ethereum-light-client-verifier = { git = "https://github.com/datachainlab/ethereum-light-client-rs", rev = "186c5b1d9935f15428ca8b209ad99ed20eaf81c6", default-features = false }
Expand All @@ -20,8 +21,5 @@ besu-qbft-proto = { path = "../proto", default-features = false }
parity-scale-codec = { version = "=3.6.4", default-features = false }
parity-scale-codec-derive = { version = "=3.6.4", default-features = false }

[dev-dependencies]
hex-literal = "0.4.1"

[package.metadata.cargo-machete]
ignored = ["parity-scale-codec", "parity-scale-codec-derive"]
4 changes: 2 additions & 2 deletions elc/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl ClientState {
value: Vec<u8>,
) -> Result<(), Error> {
let proof = decode_eip1184_rlp_proof(&proof)?;
let key = calculate_ibc_commitment_storage_key(U256::default(), path.as_bytes());
let key = calculate_ibc_commitment_storage_key(path.as_bytes());

self.execution_verifier.verify_membership(
root.to_be_bytes().into(),
Expand All @@ -139,7 +139,7 @@ impl ClientState {
path: String,
) -> Result<(), Error> {
let proof = decode_eip1184_rlp_proof(&proof)?;
let key = calculate_ibc_commitment_storage_key(U256::default(), path.as_bytes());
let key = calculate_ibc_commitment_storage_key(path.as_bytes());

self.execution_verifier.verify_non_membership(
root.to_be_bytes().into(),
Expand Down
5 changes: 3 additions & 2 deletions elc/src/commitment.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::errors::Error;
use crate::internal_prelude::*;
use crate::types::{Address, H256, U256};
use hex_literal::hex;
use libsecp256k1::{curve::Scalar, Message, PublicKey, RecoveryId, Signature};
use rlp::Rlp;
use tiny_keccak::Keccak;
Expand All @@ -20,11 +21,11 @@ pub fn decode_eip1184_rlp_proof(proof: &[u8]) -> Result<Vec<Vec<u8>>, Error> {
}
}

pub fn calculate_ibc_commitment_storage_key(ibc_commitments_slot: U256, path: &[u8]) -> U256 {
pub fn calculate_ibc_commitment_storage_key(path: &[u8]) -> U256 {
let h = keccak256(
&[
keccak256(path).as_slice(),
ibc_commitments_slot.to_be_bytes_vec().as_slice(),
hex!("1ee222554989dda120e26ecacf756fe1235cd8d726706b57517715dde4f0c900").as_slice(),
]
.concat(),
);
Expand Down

0 comments on commit 9e22c23

Please sign in to comment.