From 3f88013bcfed2509bad12ea8503a751e458b656c Mon Sep 17 00:00:00 2001 From: Mehdi Valinejad <6095314+vjdmhd@users.noreply.github.com> Date: Tue, 11 Oct 2022 23:50:37 +0330 Subject: [PATCH] Feature/ implement SubstrateIBCHeader (#986) * feat: add SubstrateIBCHeader type and implementation * fix: ibctest go mod tidy * feature/ implement substrate event parser (#923) * feat: implement substrate event parser * fix: event parser switch fallthrough * fix: go-schnorrkel version fix * fix: go mod update for dcokertest * create helper functions between substrate <> ibc events * use intoIBCEventType * fix: event parser accumulation support * fix: spearate parsing and handling of ibc messages * feat: parachain header parse * fix: packet accumulator separate switch case * fix: go.mod docker issue * fix: ics11-beefy repo version fix * fix: accumulator events to messages * fix: add connection event type conversion * fix: ibctest go.mod fix Co-authored-by: Blas Rodriguez Irizar Co-authored-by: Blas Rodriguez Irizar --- relayer/chains/substrate/provider.go | 11 +++++------ relayer/chains/substrate/substrate_chain_processor.go | 9 ++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/relayer/chains/substrate/provider.go b/relayer/chains/substrate/provider.go index f87859ab0..80808f362 100644 --- a/relayer/chains/substrate/provider.go +++ b/relayer/chains/substrate/provider.go @@ -8,6 +8,7 @@ import ( "time" rpcclient "github.com/ComposableFi/go-substrate-rpc-client/v4" + beefyclienttypes "github.com/ComposableFi/ics11-beefy/types" sdk "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types" @@ -93,6 +94,8 @@ type SubstrateProvider struct { } type SubstrateIBCHeader struct { + height uint64 + SignedHeader *beefyclienttypes.Header } // noop to implement processor.IBCHeader @@ -102,15 +105,11 @@ func (h SubstrateIBCHeader) IBCHeaderIndicator() { } func (h SubstrateIBCHeader) Height() uint64 { - //TODO implement me - panic("implement me") - return 0 + return h.height } func (h SubstrateIBCHeader) ConsensusState() ibcexported.ConsensusState { - //TODO implement me - panic("implement me") - return nil + return h.SignedHeader.ConsensusState() } func (sp *SubstrateProvider) BlockTime(ctx context.Context, height int64) (time.Time, error) { diff --git a/relayer/chains/substrate/substrate_chain_processor.go b/relayer/chains/substrate/substrate_chain_processor.go index 1d179b060..744186d6a 100644 --- a/relayer/chains/substrate/substrate_chain_processor.go +++ b/relayer/chains/substrate/substrate_chain_processor.go @@ -320,11 +320,10 @@ func (scp *SubstrateChainProcessor) queryCycle(ctx context.Context, persistence latestHeader = ibcHeader.(SubstrateIBCHeader) - // TODO: update latest bolock - // scp.latestBlock = provider.LatestBlock{ - // Height: heightUint64, - // Time: latestHeader.SignedHeader.Time, - // } + scp.latestBlock = provider.LatestBlock{ + Height: heightUint64, + Time: latestHeader.SignedHeader.ConsensusState().Timestamp, + } ibcHeaderCache[heightUint64] = latestHeader ppChanged = true