Skip to content
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

Fix: add handle errors and timeouts in IBC #70

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ require (
cosmossdk.io/depinject v1.0.0 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/log v1.3.1 // indirect
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/math v1.4.0 // indirect
cosmossdk.io/store v1.1.0 // indirect
cosmossdk.io/x/tx v0.13.4 // indirect
cosmossdk.io/x/upgrade v0.1.4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U=
cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI=
cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM=
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ=
cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk=
cosmossdk.io/store v1.1.0 h1:LnKwgYMc9BInn9PhpTFEQVbL9UK475G2H911CGGnWHk=
cosmossdk.io/store v1.1.0/go.mod h1:oZfW/4Fc/zYqu3JmQcQdUJ3fqu5vnYTn3LZFFy8P8ng=
cosmossdk.io/x/tx v0.13.4 h1:Eg0PbJgeO0gM8p5wx6xa0fKR7hIV6+8lC56UrsvSo0Y=
Expand Down
48 changes: 48 additions & 0 deletions pkg/indexer/decode/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ func parseIbcAction(body *astria.Action_Ibc, ctx *Context, action *storage.Actio
action.Data["raw"] = base64.StdEncoding.EncodeToString(data)
action.Data["type"] = typ

if ctx.HasWriteAckError {
return nil
}

switch typ {
case "/ibc.core.channel.v1.MsgRecvPacket":
var msg channelTypes.MsgRecvPacket
Expand Down Expand Up @@ -201,6 +205,50 @@ func parseIbcAction(body *astria.Action_Ibc, ctx *Context, action *storage.Actio
Update: amount,
})
}
case "/ibc.core.channel.v1.MsgTimeout":
var msg channelTypes.MsgTimeout
if err := proto.Unmarshal(data, &msg); err != nil {
return err
}
var transfer IbcTransfer
if err := json.Unmarshal(msg.Packet.Data, &transfer); err != nil {
return nil
}
var addr string
var amount decimal.Decimal

switch {
case internalAstria.IsAddress(transfer.Receiver):
addr = transfer.Receiver
amount = transfer.Amount.Neg()
case internalAstria.IsCompatAddress(transfer.Receiver):
a, err := internalAstria.CompatToAstria(transfer.Receiver)
if err != nil {
return err
}
addr = a
amount = transfer.Amount.Neg()
case internalAstria.IsAddress(transfer.Sender):
addr = transfer.Sender
amount = transfer.Amount.Copy()
case internalAstria.IsCompatAddress(transfer.Sender):
a, err := internalAstria.CompatToAstria(transfer.Sender)
if err != nil {
return err
}
addr = a
amount = transfer.Amount.Copy()
}

if addr != "" {
address := ctx.Addresses.Set(addr, action.Height, amount, transfer.Denom, 0, 0)
action.BalanceUpdates = append(action.BalanceUpdates, storage.BalanceUpdate{
Address: address,
Height: action.Height,
Currency: transfer.Denom,
Update: amount,
})
}
default:
}
}
Expand Down
50 changes: 50 additions & 0 deletions pkg/indexer/decode/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,56 @@ func TestDecodeActions(t *testing.T) {
require.Len(t, ctx.Addresses, 1)
})

t.Run("ibc action: MsgTimeout", func(t *testing.T) {
raw := "CrAECJABEgh0cmFuc2ZlchoJY2hhbm5lbC0wIgh0cmFuc2ZlcioKY2hhbm5lbC00ODLdA3siZGVub20iOiJ0cmFuc2Zlci9jaGFubmVsLTAvdXRpYSIsImFtb3VudCI6IjEwMDAwMDAiLCJzZW5kZXIiOiJhc3RyaWExM3ZwdGRhZnl0dHBtbHdwcHQwczg0NGVmZXkyY3BjMG1ldnk5MnAiLCJyZWNlaXZlciI6ImNlbGVzdGlhMTV6bTJxZWR3eGdsc2d1ZXBwbTdrNnNkNzVsNTlrNzJxaG1yd2ZnIiwibWVtbyI6IntcInJvbGx1cEJsb2NrTnVtYmVyXCI6XCIxNTMwNjVcIixcInJvbGx1cFdpdGhkcmF3YWxFdmVudElkXCI6XCIweDU5ODgzNGU0ZjYwNTkzYTdiNDFmNTVhY2RhNjEyNWUzMDg4ZTU1ZTc1NmNkYzNmMWQ5YjdhOTkxMTAyMzRmNDYuMHgwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwXCIsXCJyb2xsdXBSZXR1cm5BZGRyZXNzXCI6XCIweDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMGE5NDAzMDFjNTk3OGNiYzlkNzkxOThlY2E0YzE3NDRjMWViN2UyNmVcIn0ifToWCP///////////wEQ////////////AUD3x7a90r/mgRgSrhQKqhISpxIKOXJlY2VpcHRzL3BvcnRzL3RyYW5zZmVyL2NoYW5uZWxzL2NoYW5uZWwtN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ARogYS6kd/Ac5hCidoF6XmCGwDuEi6MZvRajOJAws1eVDj0iJQgBEiEBVnOiCroUoMax9oz2ilFCs7iIFe0ni3Vdy3MEfF6k3RoiJwgBEgEBGiCQmlC8SbarXrXTwcOSuJAle63l425Pc/IrMCe5m8zZhxoFEPiRpAEgkAEqLWFzdHJpYTFwejB0eHh3Y2VuYzk4dng2YWxucHJjZWY0Nmt5cnZyeWE4Y3M4cA=="
data, err := base64.StdEncoding.DecodeString(raw)
require.NoError(t, err)

message := &astria.Action_Ibc{
Ibc: &v1.IbcRelay{
RawAction: &anypb.Any{
Value: data,
TypeUrl: "/ibc.core.channel.v1.MsgTimeout",
},
},
}

wantAction := storage.Action{
Height: 1000,
Type: types.ActionTypeIbcRelay,
Data: map[string]any{
"raw": raw,
"type": "/ibc.core.channel.v1.MsgTimeout",
},
BalanceUpdates: []storage.BalanceUpdate{
{
Height: 1000,
Currency: "transfer/channel-0/utia",
Address: &storage.Address{
Hash: "astria13vptdafyttpmlwppt0s844efey2cpc0mevy92p",
Height: 1000,
Balance: []*storage.Balance{
{
Currency: "transfer/channel-0/utia",
Total: decimal.RequireFromString("1000000"),
},
},
},
Update: decimal.RequireFromString("1000000"),
},
},
}

action := storage.Action{
Height: 1000,
}
ctx := NewContext(nil)
err = parseIbcAction(message, &ctx, &action)
require.NoError(t, err)
require.Equal(t, wantAction, action)
require.Len(t, ctx.Addresses, 1)
})

t.Run("ibc action: MsgRecvPacket without astria address", func(t *testing.T) {
raw := "CtsBCAoSCHRyYW5zZmVyGgtjaGFubmVsLTE1OSIIdHJhbnNmZXIqCWNoYW5uZWwtMDKYAXsiYW1vdW50IjoiMTAwMDAwMCIsImRlbm9tIjoidXRpYSIsInJlY2VpdmVyIjoibm9ibGUxMjhwZmhlejRxZ3hwcHNzcnJ2bHVkM3c1ZHRzbWFlNmQzdWxlcTMiLCJzZW5kZXIiOiJjZWxlc3RpYTE5M21xc24zaG5hYWRjdTB2MjRleHFlMnRtc2ZucGp0N3Yye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h7akQHKlesCIBhX60I7dKkHLhCsblc4i25nsRH8aoEvnlosHfLiLgjMICIwCAESCSDmsgLKlesCIBohIGjAlyFlC1aoLcdXCj8BZ6fbvAH8RsZHqiNTNzTf6UXrIi4IARIqJPLDBcqV6wIglad+Ebaw5tzEdHImJ7T2UKA/JGdHIfL8OWQpZz+6p9QgIjAIARIJJrDLCcqV6wIgGiEgfbGbOzyKWjZGK+ZvupT/3N9+G67cmTm7vqduK46EPGIK/gEK+wEKA2liYxIgPo6XHEZu4bDq1YnG+rjQlfHaeOaJpE5mgJ7GRT7u+woaCQgBGAEgASoBACIlCAESIQFc8LCXIH/ReynuGPU2hd+7XpwozF25Cg2lAmKb/BmnHCInCAESAQEaIGCg+C171gjmvrp9OkKH5uaMMYv2ZUNybiq88hDdeRCWIicIARIBARog+z00X5Su+pD47ctWDweapZwqg6KKF4iD+4+WeupwIpYiJQgBEiEBq/c+ibThhnm2Z6BJLs8LFRnWXksaWAuhNBVKyPW5nQYiJwgBEgEBGiCxKF6OMNnOP4DPRNLEM0JTeSnAqhKhUWYtc3NvrA0rphoHCAQQ5sq1ASItYXN0cmlhMW5zcjl0ZWQ2OWUwdms5Y3JoZnlzZ3loZTh1cTJqYzN5MGtzZDR4"
data, err := base64.StdEncoding.DecodeString(raw)
Expand Down
38 changes: 20 additions & 18 deletions pkg/indexer/decode/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ import (
)

type Context struct {
Addresses Addresses
Rollups Rollups
Validators Validators
RollupAddress map[string]*storage.RollupAddress
AddressActions map[string]*storage.AddressAction
SupplyChange decimal.Decimal
BytesInBlock int64
GasUsed int64
GasWanted int64
DataSize int64
ActionTypes storageTypes.Bits
Constants map[string]*storage.Constant
Bridges map[string]*storage.Bridge
Fees map[int64]*storage.Fee
Transfers []*storage.Transfer
Deposits map[int64]*storage.Deposit
Proposer string
Addresses Addresses
Rollups Rollups
Validators Validators
RollupAddress map[string]*storage.RollupAddress
AddressActions map[string]*storage.AddressAction
SupplyChange decimal.Decimal
BytesInBlock int64
GasUsed int64
GasWanted int64
DataSize int64
ActionTypes storageTypes.Bits
Constants map[string]*storage.Constant
Bridges map[string]*storage.Bridge
Fees map[int64]*storage.Fee
Transfers []*storage.Transfer
Deposits map[int64]*storage.Deposit
HasWriteAckError bool
Proposer string

bridgeAssets map[string]string
}
Expand Down Expand Up @@ -83,8 +84,9 @@ func (ctx *Context) AddFee(idx int64, fee *storage.Fee) {
ctx.Fees[idx] = fee
}

func (ctx *Context) ClearFee() {
func (ctx *Context) ClearTx() {
clear(ctx.Fees)
ctx.HasWriteAckError = false
}

func (ctx *Context) AddBridgeAsset(bridge, asset string) {
Expand Down
13 changes: 13 additions & 0 deletions pkg/indexer/parser/parseEvents.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func parseEvents(ctx context.Context, events []types.Event, height types.Level,
err = parseTxFees(ctx, events[i].Attributes, decodeCtx, api)
case "tx.deposit":
err = parseTxDeposit(events[i].Attributes, height, decodeCtx)
case "write_acknowledgement":
err = parseWriteAck(events[i].Attributes, decodeCtx)
default:
continue
}
Expand Down Expand Up @@ -155,3 +157,14 @@ func parseTxDeposit(attrs []types.EventAttribute, height types.Level, decodeCtx
decodeCtx.AddDeposit(idx, deposit)
return nil
}

func parseWriteAck(attrs []types.EventAttribute, decodeCtx *decode.Context) error {
for i := range attrs {
switch attrs[i].Key {
case "packet_ack":
decodeCtx.HasWriteAckError = strings.Contains(attrs[i].Value, "error")
default:
}
}
return nil
}
48 changes: 48 additions & 0 deletions pkg/indexer/parser/parseEvents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,51 @@ func Test_parseTxFee(t *testing.T) {
require.EqualValues(t, "astria.protocol.transaction.v1.RollupDataSubmission", fee.ActionType)
})
}

func Test_parseWriteAck(t *testing.T) {
t.Run("test write_acknowledgement event", func(t *testing.T) {
attrs := []types.EventAttribute{
{
Key: "packet_ack",
Value: `{\"error\":\"{\"0\": \"failed to execute ics20 transfer to bridge account\", \"1\": \"failed to parse memo as Ics20TransferDepositMemo\", \"2\": \"EOF while parsing a value at line 1 column 0\"}\"}`,
}, {
Key: "packet_data",
Value: `{"amount":"100000","denom":"uusdc","receiver":"astriacompat13vptdafyttpmlwppt0s844efey2cpc0mw6dhm2","sender":"noble1rmhdkl3aaw95zdecnj5paaqcjavm8sylftznrs"}`,
}, {
Key: "packet_sequence",
Value: "1",
}, {
Key: "packet_dst_port",
Value: "transfer",
},
}

decodeCtx := decode.NewContext(map[string]string{})
err := parseWriteAck(attrs, &decodeCtx)
require.NoError(t, err)
require.True(t, decodeCtx.HasWriteAckError)
})

t.Run("test write_acknowledgement success event", func(t *testing.T) {
attrs := []types.EventAttribute{
{
Key: "packet_ack",
Value: `{\"result\":\"AQ==\"}`,
}, {
Key: "packet_data",
Value: `{"amount":"100000","denom":"uusdc","receiver":"astriacompat13vptdafyttpmlwppt0s844efey2cpc0mw6dhm2","sender":"noble1rmhdkl3aaw95zdecnj5paaqcjavm8sylftznrs"}`,
}, {
Key: "packet_sequence",
Value: "1",
}, {
Key: "packet_dst_port",
Value: "transfer",
},
}

decodeCtx := decode.NewContext(map[string]string{})
err := parseWriteAck(attrs, &decodeCtx)
require.NoError(t, err)
require.False(t, decodeCtx.HasWriteAckError)
})
}
2 changes: 1 addition & 1 deletion pkg/indexer/parser/parseTxs.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func parseTxs(ctx context.Context, b types.BlockData, decodeCtx *decode.Context,
}
txs[i-index] = &t

decodeCtx.ClearFee()
decodeCtx.ClearTx()
}

return txs, nil
Expand Down
Loading