Skip to content

fix: refetch missing packet #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 66 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
2c07f05
fix: add missing mutex in query proof
viveksharmapoudel Aug 22, 2023
244d363
chore: add retry logic in wasm query method
viveksharmapoudel Aug 22, 2023
fb281b4
fix: add delay for pathprocessor sync
viveksharmapoudel Aug 22, 2023
5c72d19
fix: remove tp when getting client state
viveksharmapoudel Aug 22, 2023
df20a84
fix: adding defer in queryWasmProof
viveksharmapoudel Aug 22, 2023
afbcf30
fix: change to processheight
viveksharmapoudel Aug 22, 2023
f581195
fix: limit max block fetch at a time in wasm processor
viveksharmapoudel Aug 22, 2023
a2b9187
fix: btp block update miss
viveksharmapoudel Aug 23, 2023
9c3d3bd
fix:add values
viveksharmapoudel Aug 23, 2023
4660bc8
fix: the logic
viveksharmapoudel Aug 23, 2023
95396e6
fix: queue logic
viveksharmapoudel Aug 23, 2023
6b8db31
fix:refractor
viveksharmapoudel Aug 23, 2023
5145d20
fix: implement mutex in queue
viveksharmapoudel Aug 23, 2023
87a9477
fix: add prevconsensusstateheight method and use it to fetch trusted …
viveksharmapoudel Aug 24, 2023
68f8257
fix: add method missing receipt methods
viveksharmapoudel Aug 9, 2023
ef7b18c
Merge branch 'main' of github.com:icon-project/ibc-relay into fix/ref…
viveksharmapoudel Sep 6, 2023
2b90d8b
build fix
viveksharmapoudel Sep 6, 2023
ed33f74
feat: flush logic for contract based chains
viveksharmapoudel Sep 6, 2023
aed90fe
feat: add query method in chain provider for flush logic
viveksharmapoudel Sep 6, 2023
544277e
feat: implement additional query method in cosmos & penumber
viveksharmapoudel Sep 6, 2023
73613e6
feat: implement additional queries in icon & wasm chain
viveksharmapoudel Sep 6, 2023
c05f1c6
feat: getNextSequence Improvize logic
viveksharmapoudel Sep 6, 2023
7efd902
refract: wasm types code optimize
viveksharmapoudel Sep 6, 2023
e08da36
feat: implement next sequence send method
viveksharmapoudel Sep 6, 2023
6776c85
refract: unmarshal of contract byte response
viveksharmapoudel Sep 6, 2023
c7e0534
feat: add querySendPacketByHeight wasm chain
viveksharmapoudel Sep 6, 2023
cb5cd9b
feat: query send packet by height query added
viveksharmapoudel Sep 6, 2023
60ef21f
fix: get next seq based on height
viveksharmapoudel Sep 7, 2023
807283c
fix: remove comment
viveksharmapoudel Sep 11, 2023
2e9818c
feat: new btp queue structure
viveksharmapoudel Sep 11, 2023
de85a36
feat: update client logic
viveksharmapoudel Sep 11, 2023
4f233d7
feat: add test btp queue
viveksharmapoudel Sep 11, 2023
b07f90e
fix: queryMissingPacketReceipts method icon provider
viveksharmapoudel Sep 11, 2023
53729e4
Merge branch 'main' of github.com:icon-project/ibc-relay into fix/ref…
viveksharmapoudel Sep 11, 2023
64cf31d
fix: filter packetHeights before
viveksharmapoudel Sep 11, 2023
a2f663a
chore: rename packetHeights to message heights
viveksharmapoudel Sep 11, 2023
bf19a0a
feat: add query ackHeights methods
viveksharmapoudel Sep 11, 2023
7fff473
refract: refractor query method wasm
viveksharmapoudel Sep 11, 2023
7e10932
feat: add flush unreceived ack logic
viveksharmapoudel Sep 11, 2023
4aca55c
Merge branch 'main' into fix/refetch-missing-packet
viveksharmapoudel Sep 11, 2023
fc991ed
fix: handle wasm query search based on latest height
viveksharmapoudel Sep 12, 2023
2cf0a6c
fix: query packet height based on fixed duration
viveksharmapoudel Sep 12, 2023
2098511
fix: implement pagination
viveksharmapoudel Sep 12, 2023
c310e79
fix: find proofContext change heights from last client state to lates…
viveksharmapoudel Sep 18, 2023
89b7406
fix: add btp block for all the missing packet if consensus state not …
viveksharmapoudel Sep 22, 2023
aa4ea1a
fix: add btp queue for missing block
viveksharmapoudel Sep 26, 2023
1ed3229
fix: flush ack not handled properly on icon side
viveksharmapoudel Oct 5, 2023
d262d5d
fix: ack on wasm not handled properly
viveksharmapoudel Oct 5, 2023
0150ed7
fix: active flush timer
viveksharmapoudel Oct 5, 2023
cb6fac2
Merge branch 'main' into fix/refetch-missing-packet
viveksharmapoudel Oct 5, 2023
07f4dbd
chore: fix merge conflict
viveksharmapoudel Nov 27, 2023
f92cede
feat: add btp proof context change flag
viveksharmapoudel Dec 1, 2023
3daee45
chore: remove unwanted
viveksharmapoudel Dec 1, 2023
539c435
chore: add flag for proof context from height
viveksharmapoudel Dec 4, 2023
5d06c2d
feat: update proof context change logic and remove timer to save height
viveksharmapoudel Dec 4, 2023
7183883
feat: add proof context update logic in start only
viveksharmapoudel Dec 4, 2023
274cd87
feat: iconchainprocessor startheight fetch from context
viveksharmapoudel Dec 4, 2023
6a83caa
feat: remove start height from IconproviderConfig-> always run from l…
viveksharmapoudel Dec 4, 2023
683a508
feat: icon find proofContextChange from height
viveksharmapoudel Dec 4, 2023
e857e48
feat: wasm chain add concurrency and remove start height
viveksharmapoudel Dec 4, 2023
e3a21f8
chore: add constant
viveksharmapoudel Dec 4, 2023
a902765
chore: helper method added
viveksharmapoudel Dec 4, 2023
b3b44e8
chore: removed HeightSnapshot logic
viveksharmapoudel Dec 4, 2023
c584766
chore: update example config
viveksharmapoudel Dec 4, 2023
c222afa
chore: reduce sleep time
viveksharmapoudel Dec 4, 2023
436d733
fix: add btp height of only it doesn't exist
viveksharmapoudel Dec 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 62 additions & 44 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,52 @@ import (
)

const (
flagHome = "home"
flagURL = "url"
flagSkip = "skip"
flagTimeout = "timeout"
flagJSON = "json"
flagYAML = "yaml"
flagFile = "file"
flagPath = "path"
flagMaxTxSize = "max-tx-size"
flagMaxMsgLength = "max-msgs"
flagIBCDenoms = "ibc-denoms"
flagTimeoutHeightOffset = "timeout-height-offset"
flagTimeoutTimeOffset = "timeout-time-offset"
flagMaxRetries = "max-retries"
flagThresholdTime = "time-threshold"
flagUpdateAfterExpiry = "update-after-expiry"
flagUpdateAfterMisbehaviour = "update-after-misbehaviour"
flagClientTrustingPeriod = "client-tp"
flagOverride = "override"
flagSrcPort = "src-port"
flagDstPort = "dst-port"
flagOrder = "order"
flagVersion = "version"
flagDebugAddr = "debug-addr"
flagOverwriteConfig = "overwrite"
flagLimit = "limit"
flagHeight = "height"
flagPage = "page"
flagPageKey = "page-key"
flagCountTotal = "count-total"
flagReverse = "reverse"
flagProcessor = "processor"
flagInitialBlockHistory = "block-history"
flagFlushInterval = "flush-interval"
flagMemo = "memo"
flagFilterRule = "filter-rule"
flagFilterChannels = "filter-channels"
flagSrcChainID = "src-chain-id"
flagDstChainID = "dst-chain-id"
flagSrcClientID = "src-client-id"
flagDstClientID = "dst-client-id"
flagSrcConnID = "src-connection-id"
flagDstConnID = "dst-connection-id"
flagBtpBlockHeight = "btp-block-height"
flagHome = "home"
flagURL = "url"
flagSkip = "skip"
flagTimeout = "timeout"
flagJSON = "json"
flagYAML = "yaml"
flagFile = "file"
flagPath = "path"
flagMaxTxSize = "max-tx-size"
flagMaxMsgLength = "max-msgs"
flagIBCDenoms = "ibc-denoms"
flagTimeoutHeightOffset = "timeout-height-offset"
flagTimeoutTimeOffset = "timeout-time-offset"
flagMaxRetries = "max-retries"
flagThresholdTime = "time-threshold"
flagUpdateAfterExpiry = "update-after-expiry"
flagUpdateAfterMisbehaviour = "update-after-misbehaviour"
flagClientTrustingPeriod = "client-tp"
flagOverride = "override"
flagSrcPort = "src-port"
flagDstPort = "dst-port"
flagOrder = "order"
flagVersion = "version"
flagDebugAddr = "debug-addr"
flagOverwriteConfig = "overwrite"
flagLimit = "limit"
flagHeight = "height"
flagPage = "page"
flagPageKey = "page-key"
flagCountTotal = "count-total"
flagReverse = "reverse"
flagProcessor = "processor"
flagInitialBlockHistory = "block-history"
flagFlushInterval = "flush-interval"
flagMemo = "memo"
flagFilterRule = "filter-rule"
flagFilterChannels = "filter-channels"
flagSrcChainID = "src-chain-id"
flagDstChainID = "dst-chain-id"
flagSrcClientID = "src-client-id"
flagDstClientID = "dst-client-id"
flagSrcConnID = "src-connection-id"
flagDstConnID = "dst-connection-id"
flagBtpBlockHeight = "btp-block-height"
flagBtpUpdateProofContext = "btp-update-proof-context"
flagBTPUpdateProofContextFromHeight = "btp-update-proof-context-from-height"
)

const (
Expand Down Expand Up @@ -390,3 +392,19 @@ func OverwriteConfigFlag(v *viper.Viper, cmd *cobra.Command) *cobra.Command {
}
return cmd
}

func BtpUpdateProofContextFlag(v *viper.Viper, cmd *cobra.Command) *cobra.Command {
cmd.Flags().BoolP(flagBtpUpdateProofContext, "u", false, "update all proof context change")
if err := v.BindPFlag(flagFlushInterval, cmd.Flags().Lookup(flagFlushInterval)); err != nil {
panic(err)
}
return cmd
}

func BtpUpdateProofContextFromHeightFlag(v *viper.Viper, cmd *cobra.Command) *cobra.Command {
cmd.Flags().Int64(flagBTPUpdateProofContextFromHeight, 0, "btp update proof context from height")
if err := v.BindPFlag(flagFlushInterval, cmd.Flags().Lookup(flagFlushInterval)); err != nil {
panic(err)
}
return cmd
}
21 changes: 20 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/cosmos/relayer/v2/internal/relaydebug"
"github.com/cosmos/relayer/v2/relayer"
"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
"github.com/cosmos/relayer/v2/relayer/common"
"github.com/cosmos/relayer/v2/relayer/processor"
"github.com/spf13/cobra"
"go.uber.org/zap"
Expand Down Expand Up @@ -143,8 +144,24 @@ $ %s start demo-path2 --max-tx-size 10`, appName, appName, appName, appName)),
return err
}

btpProofContextUpdateFrom, err := cmd.Flags().GetInt64(flagBTPUpdateProofContextFromHeight)
if err != nil {
return err
}

ctx := cmd.Context()
shouldUpdateProofContext, err := cmd.Flags().GetBool(flagBtpUpdateProofContext)
// runUsing the flag
if shouldUpdateProofContext {
iconStartHeight, err := relayer.RunProofContextUpdate(cmd.Context(), a.log, chains, paths, btpProofContextUpdateFrom)
if err != nil {
return fmt.Errorf("unable to complete proofContextUpdate error: %v", err)
}
ctx = context.WithValue(ctx, common.IconStartHeightFromPreRunContext, iconStartHeight)
}

rlyErrCh := relayer.StartRelayer(
cmd.Context(),
ctx,
a.log,
chains,
paths,
Expand Down Expand Up @@ -179,5 +196,7 @@ $ %s start demo-path2 --max-tx-size 10`, appName, appName, appName, appName)),
cmd = initBlockFlag(a.viper, cmd)
cmd = flushIntervalFlag(a.viper, cmd)
cmd = memoFlag(a.viper, cmd)
cmd = BtpUpdateProofContextFlag(a.viper, cmd)
cmd = BtpUpdateProofContextFromHeightFlag(a.viper, cmd)
return cmd
}
110 changes: 54 additions & 56 deletions examples/config_IBC_ICON.yaml
Original file line number Diff line number Diff line change
@@ -1,59 +1,57 @@
global:
api-listen-addr: :5183
timeout: 10s
memo: ""
light-cache-size: 20
api-listen-addr: :5183
timeout: 10s
memo: ""
light-cache-size: 20
chains:
archway:
type: wasm
value:
key-directory: /home/user/.relayer/keys
key: relayWallet
chain-id: localnet
rpc-addr: http://localhost:26657
account-prefix: archway
keyring-backend: test
gas-adjustment: 1.5
gas-prices: 0.025stake
min-gas-amount: 1000000
debug: true
timeout: 20s
block-timeout: ""
output-format: json
sign-mode: direct
extra-codecs: []
coin-type: 0
broadcast-mode: batch
ibc-handler-address: archway1pvrwmjuusn9wh34j7y520g8gumuy9xtl3gvprlljfdpwju3x7ucszwhc7n
first-retry-block-after: 0
start-height: 0
block-interval: 3000
icon:
type: icon
value:
key-directory: /home/user/.relayer/keys
chain-id: ibc-icon
rpc-addr: http://localhost:9082/api/v3/
timeout: 30s
keystore: godWallet
password: gochain
icon-network-id: 3
btp-network-id: 1
btp-network-type-id: 1
start-height: 0
ibc-handler-address: cxbeb5929616e0dbd2fec1e6e950ab09e45e6fb25a
first-retry-block-after: 0
block-interval: 2000
archway:
type: wasm
value:
key-directory: /home/user/.relayer/keys
key: relayWallet
chain-id: localnet
rpc-addr: http://localhost:26657
account-prefix: archway
keyring-backend: test
gas-adjustment: 1.5
gas-prices: 0.025stake
min-gas-amount: 1000000
debug: true
timeout: 20s
block-timeout: ""
output-format: json
sign-mode: direct
extra-codecs: []
coin-type: 0
broadcast-mode: batch
ibc-handler-address: archway1pvrwmjuusn9wh34j7y520g8gumuy9xtl3gvprlljfdpwju3x7ucszwhc7n
first-retry-block-after: 0
block-interval: 3000
icon:
type: icon
value:
key-directory: /home/user/.relayer/keys
chain-id: ibc-icon
rpc-addr: http://localhost:9082/api/v3/
timeout: 30s
keystore: godWallet
password: gochain
icon-network-id: 3
btp-network-id: 1
btp-network-type-id: 1
ibc-handler-address: cxbeb5929616e0dbd2fec1e6e950ab09e45e6fb25a
first-retry-block-after: 0
block-interval: 2000
paths:
icon-archway:
src:
chain-id: ibc-icon
client-id: 07-tendermint-0
connection-id: connection-0
dst:
chain-id: localnet
client-id: iconclient-0
connection-id: connection-0
src-channel-filter:
rule: ""
channel-list: []
icon-archway:
src:
chain-id: ibc-icon
client-id: 07-tendermint-0
connection-id: connection-0
dst:
chain-id: localnet
client-id: iconclient-0
connection-id: connection-0
src-channel-filter:
rule: ""
channel-list: []
1 change: 0 additions & 1 deletion examples/demo/configs/chains/ibc-icon.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"icon-network-id": 3,
"btp-network-id": 2,
"btp-network-type-id": 1,
"start-height": 0,
"ibc-handler-address": "cxbeb5929616e0dbd2fec1e6e950ab09e45e6fb25a",
"first-retry-block-after": 0,
"block-interval": 2000
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/configs/chains/ibc-wasm.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"broadcast-mode": "batch",
"ibc-handler-address": "archway1pvrwmjuusn9wh34j7y520g8gumuy9xtl3gvprlljfdpwju3x7ucszwhc7n",
"first-retry-block-after": 0,
"start-height": 0,
"block-interval": 3000
"block-interval": 3000,
"concurrency": 100
}
}
16 changes: 16 additions & 0 deletions relayer/chains/cosmos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,5 +1173,21 @@ func (cc *CosmosProvider) QueryConsensusStateABCI(ctx context.Context, clientID

func (ap *CosmosProvider) QueryClientPrevConsensusStateHeight(ctx context.Context, chainHeight int64, clientId string, clientHeight int64) (exported.Height, error) {
panic("QueryClientPrevConsensusStateHeight not implemented")
}

func (ap *CosmosProvider) QueryPacketMessageByEventHeight(ctx context.Context, eventType, srcChanID, srcPortID string, sequence uint64, seqHeight uint64) (provider.PacketInfo, error) {
panic("QuerySendPacketByHeight not implemented")
}

func (ap *CosmosProvider) QueryPacketHeights(ctx context.Context, latestHeight int64, channelId, portId string, startSeq, endSeq uint64) (packetHeights provider.MessageHeights, err error) {
panic("QueryPacketHeights not implemented")
}
func (ap *CosmosProvider) QueryAckHeights(ctx context.Context, latestHeight int64, channelId, portId string, startSeq, endSeq uint64) (packetHeights provider.MessageHeights, err error) {
panic("QueryAckHeights not implemented")
}
func (ap *CosmosProvider) QueryMissingPacketReceipts(ctx context.Context, latestHeight int64, channelId, portId string, startSeq, endSeq uint64) (missingReceipts []uint64, err error) {
panic("QueryMissingPacketReceipts not implemented")
}
func (ap *CosmosProvider) QueryNextSeqSend(ctx context.Context, height int64, channelid, portid string) (seq uint64, err error) {
panic("QueryNextSeqSend not implemented")
}
20 changes: 20 additions & 0 deletions relayer/chains/icon/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type IClient interface {
GetLastBlock() (*types.Block, error)
GetBlockHeaderByHeight(height int64) (*types.BlockHeader, error)
GetValidatorsByHash(hash common.HexHash) ([]common.Address, error)
GetPrepTerm() (*types.PrepTerm, error)
}

type Client struct {
Expand Down Expand Up @@ -622,6 +623,25 @@ func (c *Client) EstimateStep(param *types.TransactionParamForEstimate) (*types.
return &result, nil
}

func (c *Client) GetPrepTerm() (*types.PrepTerm, error) {

param := types.CallParam{
FromAddress: types.Address(fmt.Sprintf("hx%s", strings.Repeat("0", 40))),
ToAddress: types.Address(genesisContract),
DataType: "call",
Data: &types.CallData{
Method: MethodGetPrepTerm,
Params: map[string]string{},
},
}

var op types.PrepTerm
if err := c.Call(&param, &op); err != nil {
return nil, err
}
return &op, nil
}

func NewClient(uri string, l *zap.Logger) *Client {
//TODO options {MaxRetrySendTx, MaxRetryGetResult, MaxIdleConnsPerHost, Debug, Dump}
tr := &http.Transport{MaxIdleConnsPerHost: 1000}
Expand Down
Loading