Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into set_fee_payee
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Oct 23, 2024
2 parents 826b206 + 1ca4595 commit daa0448
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 192 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* (testground)[#1650](https://github.com/crypto-org-chain/cronos/pull/1650) Benchmark support batch mode.
* [#1658](https://github.com/crypto-org-chain/cronos/pull/1658) Optimize when block-list is empty.
* (testground)[#1659](https://github.com/crypto-org-chain/cronos/pull/1659) Support skip check-tx in benchmark.
* [#1662](https://github.com/crypto-org-chain/cronos/pull/1662) Emit more packet info for ibc relayer event.

*Oct 14, 2024*

Expand Down
22 changes: 14 additions & 8 deletions integration_tests/test_ibc_rly.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ def coin_spent(spender, amt, denom):
def distribute_fee(receiver, fee):
return {
"receiver": receiver,
"fee": keccak(text=fee),
"fee": fee,
}


def fungible(dst, src, amt, denom):
return {
"receiver": dst,
"sender": src,
"denom": keccak(text=denom),
"denom": denom,
"amount": amt,
}

Expand All @@ -122,9 +122,11 @@ def burn(burner, amt, denom):

def recv_packet(seq, src, dst, amt, denom):
return {
"packetSequence": keccak(text=f"{seq}"),
"packetSequence": seq,
"packetSrcPort": keccak(text="transfer"),
"packetSrcChannel": keccak(text=channel),
"packetSrcPortInfo": "transfer",
"packetSrcChannelInfo": channel,
"packetDstPort": "transfer",
"packetDstChannel": channel,
"connectionId": "connection-0",
Expand All @@ -140,9 +142,11 @@ def recv_packet(seq, src, dst, amt, denom):

def acknowledge_packet(seq):
return {
"packetSequence": keccak(text=f"{seq}"),
"packetSequence": seq,
"packetSrcPort": keccak(text="transfer"),
"packetSrcChannel": keccak(text=channel),
"packetSrcPortInfo": "transfer",
"packetSrcChannelInfo": channel,
"packetDstPort": "transfer",
"packetDstChannel": channel,
"connectionId": "connection-0",
Expand All @@ -151,15 +155,17 @@ def acknowledge_packet(seq):

def denom_trace(denom):
return {
"denom": keccak(text=denom),
"denom": denom,
}


def write_ack(seq, src, dst, amt, denom):
return {
"packetSequence": keccak(text=f"{seq}"),
"packetSequence": seq,
"packetSrcPort": keccak(text="transfer"),
"packetSrcChannel": keccak(text=channel),
"packetSrcPortInfo": "transfer",
"packetSrcChannelInfo": channel,
"packetDstPort": "transfer",
"packetDstChannel": channel,
"connectionId": "connection-0",
Expand Down Expand Up @@ -208,7 +214,7 @@ def get_send_packet_seq(
events = parse_events_rpc(res["events"])
target = events.get("send_packet")
if target and target["packet_sequence"]:
return target["packet_sequence"]
return int(target["packet_sequence"])
return None


Expand All @@ -219,7 +225,7 @@ def filter_logs_since(w3, start, name, seq):
{
"fromBlock": start,
"address": [CONTRACT],
"topics": [topic, "0x" + keccak(text=f"{seq}").hex()],
"topics": [topic, "0x{:064x}".format(seq)],
}
)

Expand Down
2 changes: 1 addition & 1 deletion x/cronos/events/bindings/cosmos/lib/cosmos_types.abigen.go

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

Large diffs are not rendered by default.

26 changes: 17 additions & 9 deletions x/cronos/events/bindings/src/Relayer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,63 +10,71 @@ interface IRelayerModule {
Cosmos.Coin[] amount;
}
event RecvPacket(
string indexed packetSequence,
uint256 indexed packetSequence,
string indexed packetSrcPort,
string indexed packetSrcChannel,
string packetSrcPortInfo,
string packetSrcChannelInfo,
string packetDstPort,
string packetDstChannel,
string connectionId,
PacketData packetDataHex
);
event WriteAcknowledgement(
string indexed packetSequence,
uint256 indexed packetSequence,
string indexed packetSrcPort,
string indexed packetSrcChannel,
string packetSrcPortInfo,
string packetSrcChannelInfo,
string packetDstPort,
string packetDstChannel,
string connectionId,
PacketData packetDataHex
);
event AcknowledgePacket(
string indexed packetSequence,
uint256 indexed packetSequence,
string indexed packetSrcPort,
string indexed packetSrcChannel,
string packetSrcPortInfo,
string packetSrcChannelInfo,
string packetDstPort,
string packetDstChannel,
string connectionId
);
event TimeoutPacket(
string indexed packetSequence,
uint256 indexed packetSequence,
string indexed packetSrcPort,
string indexed packetSrcChannel,
string packetSrcPortInfo,
string packetSrcChannelInfo,
string packetDstPort,
string packetDstChannel,
string connectionId
);
// IBC transfer
event Timeout(
address indexed refundReceiver,
string indexed refundDenom,
string refundDenom,
uint256 amount
);
event FungibleTokenPacket(
address indexed receiver,
address indexed sender,
string indexed denom,
string denom,
uint256 amount
);
event IbcTransfer(
address indexed sender,
address indexed receiver,
string indexed denom,
string denom,
uint256 amount
);
event ChannelClosed();
event DenominationTrace(string indexed denom);
event DenominationTrace(string denom);
// 29-fee
event DistributeFee(
address indexed receiver,
string indexed fee
string fee
);
// Bank
event Transfer(
Expand Down
5 changes: 4 additions & 1 deletion x/cronos/events/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ func makeFilter(
func (desc *EventDescriptor) ConvertEvent(
event []abci.EventAttribute,
valueDecoders ValueDecoders,
replaceAttrs map[string]string,
) (*ethtypes.Log, error) {
attrs := make(map[string]string, len(event))
for _, attr := range event {
attrs[toUnderScore(attr.Key)] = attr.Value
}

for k, v := range replaceAttrs {
attrs[k] = attrs[v]
}
filterQuery, err := makeFilter(valueDecoders, attrs, desc.indexed, true)
if err != nil {
return nil, err
Expand Down
42 changes: 24 additions & 18 deletions x/cronos/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@ var (
RelayerEvents map[string]*EventDescriptor
IcaEvents map[string]*EventDescriptor
RelayerValueDecoders = ValueDecoders{
channeltypes.AttributeKeyDataHex: ConvertPacketData,
transfertypes.AttributeKeyAmount: ConvertAmount,
banktypes.AttributeKeyRecipient: ConvertAccAddressFromBech32,
banktypes.AttributeKeySpender: ConvertAccAddressFromBech32,
banktypes.AttributeKeyReceiver: ConvertAccAddressFromBech32,
banktypes.AttributeKeySender: ConvertAccAddressFromBech32,
banktypes.AttributeKeyMinter: ConvertAccAddressFromBech32,
banktypes.AttributeKeyBurner: ConvertAccAddressFromBech32,
channeltypes.AttributeKeySequence: ReturnStringAsIs,
channeltypes.AttributeKeySrcPort: ReturnStringAsIs,
channeltypes.AttributeKeySrcChannel: ReturnStringAsIs,
channeltypes.AttributeKeyDstPort: ReturnStringAsIs,
channeltypes.AttributeKeyDstChannel: ReturnStringAsIs,
channeltypes.AttributeKeyConnectionID: ReturnStringAsIs,
ibcfeetypes.AttributeKeyFee: ReturnStringAsIs,
transfertypes.AttributeKeyDenom: ReturnStringAsIs,
channeltypes.AttributeKeyDataHex: ConvertPacketData,
transfertypes.AttributeKeyAmount: ConvertAmount,
banktypes.AttributeKeyRecipient: ConvertAccAddressFromBech32,
banktypes.AttributeKeySpender: ConvertAccAddressFromBech32,
banktypes.AttributeKeyReceiver: ConvertAccAddressFromBech32,
banktypes.AttributeKeySender: ConvertAccAddressFromBech32,
banktypes.AttributeKeyMinter: ConvertAccAddressFromBech32,
banktypes.AttributeKeyBurner: ConvertAccAddressFromBech32,
channeltypes.AttributeKeySequence: ConvertUint64,
channeltypes.AttributeKeySrcPort: ReturnStringAsIs,
cronoseventstypes.AttributeKeySrcPortInfo: ReturnStringAsIs,
channeltypes.AttributeKeySrcChannel: ReturnStringAsIs,
cronoseventstypes.AttributeKeySrcChannelInfo: ReturnStringAsIs,
channeltypes.AttributeKeyDstPort: ReturnStringAsIs,
channeltypes.AttributeKeyDstChannel: ReturnStringAsIs,
channeltypes.AttributeKeyConnectionID: ReturnStringAsIs,
ibcfeetypes.AttributeKeyFee: ReturnStringAsIs,
transfertypes.AttributeKeyDenom: ReturnStringAsIs,
}
IcaValueDecoders = ValueDecoders{
cronoseventstypes.AttributeKeySeq: ConvertUint64,
Expand All @@ -59,13 +61,17 @@ func RelayerConvertEvent(event sdk.Event) (*ethtypes.Log, error) {
if !ok {
return nil, nil
}
return desc.ConvertEvent(event.Attributes, RelayerValueDecoders)
replaceAttrs := map[string]string{
cronoseventstypes.AttributeKeySrcPortInfo: channeltypes.AttributeKeySrcPort,
cronoseventstypes.AttributeKeySrcChannelInfo: channeltypes.AttributeKeySrcChannel,
}
return desc.ConvertEvent(event.Attributes, RelayerValueDecoders, replaceAttrs)
}

func IcaConvertEvent(event sdk.Event) (*ethtypes.Log, error) {
desc, ok := IcaEvents[event.Type]
if !ok {
return nil, nil
}
return desc.ConvertEvent(event.Attributes, IcaValueDecoders)
return desc.ConvertEvent(event.Attributes, IcaValueDecoders, map[string]string{})
}
6 changes: 4 additions & 2 deletions x/cronos/events/types/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package types

const (
EventTypeSubmitMsgsResult = "submit_msgs_result"
AttributeKeySeq = "seq"
EventTypeSubmitMsgsResult = "submit_msgs_result"
AttributeKeySeq = "seq"
AttributeKeySrcPortInfo = "packet_src_port_info"
AttributeKeySrcChannelInfo = "packet_src_channel_info"
)

0 comments on commit daa0448

Please sign in to comment.