Skip to content

Commit 3ed1dbf

Browse files
author
Naohiro Yoshida
committed
update relayer
Signed-off-by: Naohiro Yoshida <naohiro.yoshida@datachain.jp>
2 parents 06e929f + a2d85a8 commit 3ed1dbf

File tree

8 files changed

+25
-54
lines changed

8 files changed

+25
-54
lines changed

e2e/contracts/contracts/clients/ParliaClient.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ IbcLightclientsParliaV1ConsensusState as ConsensusState,
1010
IbcLightclientsParliaV1Header as Header
1111
} from "../ibc/lightclients/parlia/v1/parlia.sol";
1212
import {GoogleProtobufAny as Any} from "@hyperledger-labs/yui-ibc-solidity/contracts/proto/GoogleProtobufAny.sol";
13-
import "solidity-rlp/contracts/Helper.sol";
14-
import "solidity-mpt/src/MPTProof.sol";
13+
import {RLPReader} from "@hyperledger-labs/yui-ibc-solidity/contracts/clients/qbft/RLPReader.sol";
14+
import {MPTProof} from "@hyperledger-labs/yui-ibc-solidity/contracts/clients/qbft/MPTProof.sol";
1515

1616
contract ParliaClient is ILightClient {
1717
using MPTProof for bytes;
@@ -30,7 +30,7 @@ contract ParliaClient is ILightClient {
3030
bytes32 private constant CONSENSUS_STATE_TYPE_URL_HASH =
3131
keccak256(abi.encodePacked(CONSENSUS_STATE_TYPE_URL));
3232

33-
uint256 private constant COMMITMENT_SLOT = 0;
33+
bytes32 private constant COMMITMENT_SLOT = 0x1ee222554989dda120e26ecacf756fe1235cd8d726706b57517715dde4f0c900;
3434
uint8 private constant ACCOUNT_STORAGE_ROOT_INDEX = 2;
3535

3636
address internal ibcHandler;

e2e/contracts/package-lock.json

Lines changed: 4 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/contracts/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12-
"@hyperledger-labs/yui-ibc-solidity": "git+https://github.com/hyperledger-labs/yui-ibc-solidity.git#v0.3.34",
13-
"solidity-rlp": "2.0.8",
14-
"solidity-mpt": "0.1.0"
12+
"@hyperledger-labs/yui-ibc-solidity": "git+https://github.com/hyperledger-labs/yui-ibc-solidity.git#v0.3.35"
1513
},
1614
"devDependencies": {
1715
"@truffle/hdwallet-provider": "^2.1.2",

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ require (
77
github.com/cosmos/cosmos-sdk v0.50.5
88
github.com/cosmos/gogoproto v1.4.11
99
github.com/cosmos/ibc-go/v8 v8.2.0
10-
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.9
10+
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.10
1111
github.com/datachainlab/ibc-hd-signer v0.1.0
1212
github.com/ethereum/go-ethereum v1.13.15
13-
github.com/hyperledger-labs/yui-relayer v0.5.4
13+
github.com/hyperledger-labs/yui-relayer v0.5.8
1414
github.com/spf13/cobra v1.8.0
1515
github.com/stretchr/testify v1.9.0
1616
google.golang.org/protobuf v1.33.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
415415
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
416416
github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
417417
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
418-
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.9 h1:nV1KlnE07Kkug89VototWQs3jL3mmou1pWgGE0z29Jk=
419-
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.9/go.mod h1:ehlg1jKBVAW+JnFQIqRyCFGuzf4g0ZOECg58kV3uY2w=
418+
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.10 h1:ce7/EiUZDjTWGHr8VGwP8Maqqur0koxK2qCOLty6gJs=
419+
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.10/go.mod h1:7goF50HLpKyL6bmisyY7t9QV338WC+68GqGpaZ9Te24=
420420
github.com/datachainlab/ibc-hd-signer v0.1.0 h1:dmnFTAwFpl0m7Lx6+b+N/rrNpHQnXpyJAYnM25GhDi0=
421421
github.com/datachainlab/ibc-hd-signer v0.1.0/go.mod h1:wUbLb2EryMCY+GfEsziU0T032Gch04jmrN0D4XGAfOI=
422422
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -777,8 +777,8 @@ github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXM
777777
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
778778
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
779779
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
780-
github.com/hyperledger-labs/yui-relayer v0.5.4 h1:yhvWI28Rcel55UsdmYWX0QE0W3P9aBSRetQh1k8VpZA=
781-
github.com/hyperledger-labs/yui-relayer v0.5.4/go.mod h1:GeCb1dtZjtQdkBNw1L9+LAUHzNQQhQK+kkoOnZYffw0=
780+
github.com/hyperledger-labs/yui-relayer v0.5.8 h1:rIgWXSyKIVg/xjbfYjQ2biQaoL7jAoGIjJFgqLWWanY=
781+
github.com/hyperledger-labs/yui-relayer v0.5.8/go.mod h1:GeCb1dtZjtQdkBNw1L9+LAUHzNQQhQK+kkoOnZYffw0=
782782
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
783783
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
784784
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=

module/proof.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ func (pr *Prover) getAccountProof(height int64) ([]byte, common.Hash, error) {
3030

3131
func (pr *Prover) getStateCommitmentProof(path []byte, height exported.Height) ([]byte, error) {
3232
// calculate slot for commitment
33-
slot := crypto.Keccak256Hash(append(
33+
storageKey := crypto.Keccak256Hash(append(
3434
crypto.Keccak256Hash(path).Bytes(),
35-
common.Hash{}.Bytes()...,
35+
IBCCommitmentsSlot.Bytes()...,
3636
))
37-
marshaledSlot, err := slot.MarshalText()
37+
storageKeyHex, err := storageKey.MarshalText()
3838
if err != nil {
3939
return nil, fmt.Errorf("failed to marshal slot: height = %d, %+v", height.GetRevisionHeight(), err)
4040
}
4141

4242
// call eth_getProof
4343
stateProof, err := pr.chain.GetProof(
4444
pr.chain.IBCAddress(),
45-
[][]byte{marshaledSlot},
45+
[][]byte{storageKeyHex},
4646
big.NewInt(int64(height.GetRevisionHeight())),
4747
)
4848
if err != nil {
4949
return nil, fmt.Errorf("failed to get state commitment proof : address = %s, height = %d, slot = %v, %+v",
50-
pr.chain.IBCAddress(), height.GetRevisionHeight(), marshaledSlot, err)
50+
pr.chain.IBCAddress(), height.GetRevisionHeight(), storageKeyHex, err)
5151
}
5252
return stateProof.StorageProofRLP[0], nil
5353
}

module/prover.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package module
33
import (
44
"context"
55
"fmt"
6+
"github.com/ethereum/go-ethereum/common"
67
"github.com/hyperledger-labs/yui-relayer/log"
78
"time"
89

@@ -16,6 +17,9 @@ import (
1617

1718
var _ core.Prover = (*Prover)(nil)
1819

20+
// keccak256(abi.encode(uint256(keccak256("ibc.commitment")) - 1)) & ~bytes32(uint256(0xff))
21+
var IBCCommitmentsSlot = common.HexToHash("1ee222554989dda120e26ecacf756fe1235cd8d726706b57517715dde4f0c900")
22+
1923
type Prover struct {
2024
chain Chain
2125
config *ProverConfig
@@ -226,7 +230,6 @@ func (pr *Prover) buildInitialState(dstHeader core.Header) (exported.ClientState
226230
return nil, nil, err
227231
}
228232

229-
var commitmentsSlot [32]byte
230233
latestHeight := toHeight(dstHeader.GetHeight())
231234
clientState := ClientState{
232235
TrustingPeriod: pr.config.TrustingPeriod,
@@ -235,7 +238,7 @@ func (pr *Prover) buildInitialState(dstHeader core.Header) (exported.ClientState
235238
LatestHeight: &latestHeight,
236239
Frozen: false,
237240
IbcStoreAddress: pr.chain.IBCAddress().Bytes(),
238-
IbcCommitmentsSlot: commitmentsSlot[:],
241+
IbcCommitmentsSlot: IBCCommitmentsSlot[:],
239242
}
240243
consensusState := ConsensusState{
241244
Timestamp: header.Time,

tests/prover_network_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ func (ts *ProverNetworkTestSuite) TestSuccessCreateInitialLightClientState() {
8484
ts.Require().Equal(cs.MaxClockDrift, 1*time.Second)
8585
ts.Require().False(cs.Frozen)
8686
ts.Require().Equal(common.Bytes2Hex(cs.IbcStoreAddress), strings.ToLower(ts.chain.IBCAddress().String()[2:]))
87-
var commitment [32]byte
88-
ts.Require().Equal(common.Bytes2Hex(cs.IbcCommitmentsSlot), common.Bytes2Hex(commitment[:]))
87+
ts.Require().Equal(common.Bytes2Hex(cs.IbcCommitmentsSlot), common.Bytes2Hex(module.IBCCommitmentsSlot[:]))
8988

9089
header, err := ts.chain.Header(context.Background(), cs.GetLatestHeight().GetRevisionHeight())
9190
ts.Require().NoError(err)

0 commit comments

Comments
 (0)