Skip to content

Commit

Permalink
update relayer
Browse files Browse the repository at this point in the history
Signed-off-by: Naohiro Yoshida <[email protected]>
  • Loading branch information
Naohiro Yoshida committed Sep 3, 2024
2 parents 06e929f + a2d85a8 commit 3ed1dbf
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 54 deletions.
6 changes: 3 additions & 3 deletions e2e/contracts/contracts/clients/ParliaClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ IbcLightclientsParliaV1ConsensusState as ConsensusState,
IbcLightclientsParliaV1Header as Header
} from "../ibc/lightclients/parlia/v1/parlia.sol";
import {GoogleProtobufAny as Any} from "@hyperledger-labs/yui-ibc-solidity/contracts/proto/GoogleProtobufAny.sol";
import "solidity-rlp/contracts/Helper.sol";
import "solidity-mpt/src/MPTProof.sol";
import {RLPReader} from "@hyperledger-labs/yui-ibc-solidity/contracts/clients/qbft/RLPReader.sol";
import {MPTProof} from "@hyperledger-labs/yui-ibc-solidity/contracts/clients/qbft/MPTProof.sol";

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

uint256 private constant COMMITMENT_SLOT = 0;
bytes32 private constant COMMITMENT_SLOT = 0x1ee222554989dda120e26ecacf756fe1235cd8d726706b57517715dde4f0c900;
uint8 private constant ACCOUNT_STORAGE_ROOT_INDEX = 2;

address internal ibcHandler;
Expand Down
37 changes: 4 additions & 33 deletions e2e/contracts/package-lock.json

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

4 changes: 1 addition & 3 deletions e2e/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@hyperledger-labs/yui-ibc-solidity": "git+https://github.com/hyperledger-labs/yui-ibc-solidity.git#v0.3.34",
"solidity-rlp": "2.0.8",
"solidity-mpt": "0.1.0"
"@hyperledger-labs/yui-ibc-solidity": "git+https://github.com/hyperledger-labs/yui-ibc-solidity.git#v0.3.35"
},
"devDependencies": {
"@truffle/hdwallet-provider": "^2.1.2",
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ require (
github.com/cosmos/cosmos-sdk v0.50.5
github.com/cosmos/gogoproto v1.4.11
github.com/cosmos/ibc-go/v8 v8.2.0
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.9
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.10
github.com/datachainlab/ibc-hd-signer v0.1.0
github.com/ethereum/go-ethereum v1.13.15
github.com/hyperledger-labs/yui-relayer v0.5.4
github.com/hyperledger-labs/yui-relayer v0.5.8
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.9.0
google.golang.org/protobuf v1.33.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ 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/ethereum-ibc-relay-chain v0.3.9 h1:nV1KlnE07Kkug89VototWQs3jL3mmou1pWgGE0z29Jk=
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.9/go.mod h1:ehlg1jKBVAW+JnFQIqRyCFGuzf4g0ZOECg58kV3uY2w=
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.10 h1:ce7/EiUZDjTWGHr8VGwP8Maqqur0koxK2qCOLty6gJs=
github.com/datachainlab/ethereum-ibc-relay-chain v0.3.10/go.mod h1:7goF50HLpKyL6bmisyY7t9QV338WC+68GqGpaZ9Te24=
github.com/datachainlab/ibc-hd-signer v0.1.0 h1:dmnFTAwFpl0m7Lx6+b+N/rrNpHQnXpyJAYnM25GhDi0=
github.com/datachainlab/ibc-hd-signer v0.1.0/go.mod h1:wUbLb2EryMCY+GfEsziU0T032Gch04jmrN0D4XGAfOI=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -777,8 +777,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.8 h1:rIgWXSyKIVg/xjbfYjQ2biQaoL7jAoGIjJFgqLWWanY=
github.com/hyperledger-labs/yui-relayer v0.5.8/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
10 changes: 5 additions & 5 deletions module/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ func (pr *Prover) getAccountProof(height int64) ([]byte, common.Hash, error) {

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

// call eth_getProof
stateProof, err := pr.chain.GetProof(
pr.chain.IBCAddress(),
[][]byte{marshaledSlot},
[][]byte{storageKeyHex},
big.NewInt(int64(height.GetRevisionHeight())),
)
if err != nil {
return nil, fmt.Errorf("failed to get state commitment proof : address = %s, height = %d, slot = %v, %+v",
pr.chain.IBCAddress(), height.GetRevisionHeight(), marshaledSlot, err)
pr.chain.IBCAddress(), height.GetRevisionHeight(), storageKeyHex, err)
}
return stateProof.StorageProofRLP[0], nil
}
Expand Down
7 changes: 5 additions & 2 deletions module/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package module
import (
"context"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/hyperledger-labs/yui-relayer/log"
"time"

Expand All @@ -16,6 +17,9 @@ import (

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

// keccak256(abi.encode(uint256(keccak256("ibc.commitment")) - 1)) & ~bytes32(uint256(0xff))
var IBCCommitmentsSlot = common.HexToHash("1ee222554989dda120e26ecacf756fe1235cd8d726706b57517715dde4f0c900")

type Prover struct {
chain Chain
config *ProverConfig
Expand Down Expand Up @@ -226,7 +230,6 @@ func (pr *Prover) buildInitialState(dstHeader core.Header) (exported.ClientState
return nil, nil, err
}

var commitmentsSlot [32]byte
latestHeight := toHeight(dstHeader.GetHeight())
clientState := ClientState{
TrustingPeriod: pr.config.TrustingPeriod,
Expand All @@ -235,7 +238,7 @@ func (pr *Prover) buildInitialState(dstHeader core.Header) (exported.ClientState
LatestHeight: &latestHeight,
Frozen: false,
IbcStoreAddress: pr.chain.IBCAddress().Bytes(),
IbcCommitmentsSlot: commitmentsSlot[:],
IbcCommitmentsSlot: IBCCommitmentsSlot[:],
}
consensusState := ConsensusState{
Timestamp: header.Time,
Expand Down
3 changes: 1 addition & 2 deletions tests/prover_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ func (ts *ProverNetworkTestSuite) TestSuccessCreateInitialLightClientState() {
ts.Require().Equal(cs.MaxClockDrift, 1*time.Second)
ts.Require().False(cs.Frozen)
ts.Require().Equal(common.Bytes2Hex(cs.IbcStoreAddress), strings.ToLower(ts.chain.IBCAddress().String()[2:]))
var commitment [32]byte
ts.Require().Equal(common.Bytes2Hex(cs.IbcCommitmentsSlot), common.Bytes2Hex(commitment[:]))
ts.Require().Equal(common.Bytes2Hex(cs.IbcCommitmentsSlot), common.Bytes2Hex(module.IBCCommitmentsSlot[:]))

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

0 comments on commit 3ed1dbf

Please sign in to comment.