Skip to content

Commit

Permalink
review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaSripal committed Jan 17, 2025
1 parent b0c1f22 commit b759f29
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions modules/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ func (k *Keeper) DeleteClientCreator(ctx context.Context, clientID string) {
store.Delete(types.CreatorKey())
}

// SetClientCounterparty sets counterpartyInfo for a given clientID
func (k *Keeper) SetClientCounterparty(ctx context.Context, clientID string, counterparty types.CounterpartyInfo) {
store := k.ClientStore(ctx, clientID)
store.Set(types.CounterpartyKey(), k.cdc.MustMarshal(&counterparty))
}

// GetClientCounterparty gets counterpartyInfo for a given clientID
func (k *Keeper) GetClientCounterparty(ctx context.Context, clientID string) (types.CounterpartyInfo, bool) {
store := k.ClientStore(ctx, clientID)
bz := store.Get(types.CounterpartyKey())
Expand Down
1 change: 1 addition & 0 deletions modules/core/02-client/types/counterparty.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package types

// NewCounterpartyInfo creates a new counterparty info instance from merlePrefix and clientID
func NewCounterpartyInfo(merklePrefix [][]byte, clientID string) CounterpartyInfo {
return CounterpartyInfo{
MerklePrefix: merklePrefix,
Expand Down
4 changes: 4 additions & 0 deletions modules/core/02-client/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ const (
// ParamsKey is the store key for the IBC client parameters
ParamsKey = "clientParams"

// KeyCreator is the key for the creator in the client-specific store
KeyCreator = "creator"

// KeyCounterparty is the key for the counterpartyInfo in the client-specific store
KeyCounterparty = "counterparty"

// AllowAllClients is the value that if set in AllowedClients param
Expand Down Expand Up @@ -96,10 +98,12 @@ func MustParseClientIdentifier(clientID string) string {
return clientType
}

// CreatorKey returns the key under which the client creator is stored in the client store
func CreatorKey() []byte {
return []byte(KeyCreator)
}

// CounterpartyKey returns the key under which the counterparty is stored in the client store
func CounterpartyKey() []byte {
return []byte(KeyCounterparty)
}
12 changes: 6 additions & 6 deletions modules/core/04-channel/v2/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (k *Keeper) sendPacket(
timeoutTimestamp uint64,
payloads []types.Payload,
) (uint64, string, error) {
// lookup counterparty from packet identifiers
// lookup counterparty from client identifiers
counterparty, ok := k.ClientKeeper.GetClientCounterparty(ctx, sourceClient)
if !ok {
return 0, "", errorsmod.Wrapf(clienttypes.ErrCounterpartyNotFound, "counterparty not found for client: %s", sourceClient)
Expand Down Expand Up @@ -91,7 +91,7 @@ func (k *Keeper) recvPacket(
proof []byte,
proofHeight exported.Height,
) error {
// lookup counterparty from packet identifiers
// lookup counterparty from client identifiers
counterparty, ok := k.ClientKeeper.GetClientCounterparty(ctx, packet.DestinationClient)
if !ok {
return errorsmod.Wrapf(clienttypes.ErrCounterpartyNotFound, "counterparty not found for client: %s", packet.DestinationClient)
Expand All @@ -109,7 +109,7 @@ func (k *Keeper) recvPacket(
}

// REPLAY PROTECTION: Packet receipts will indicate that a packet has already been received
// on unordered channels. Packet receipts must not be pruned, unless it has been marked stale
// Packet receipts must not be pruned, unless it has been marked stale
// by the increase of the recvStartSequence.
if k.HasPacketReceipt(ctx, packet.DestinationClient, packet.Sequence) {
// This error indicates that the packet has already been relayed. Core IBC will
Expand Down Expand Up @@ -153,7 +153,7 @@ func (k Keeper) WriteAcknowledgement(
packet types.Packet,
ack types.Acknowledgement,
) error {
// lookup counterparty from packet identifiers
// lookup counterparty from client identifiers
counterparty, ok := k.ClientKeeper.GetClientCounterparty(ctx, packet.DestinationClient)
if !ok {
return errorsmod.Wrapf(clienttypes.ErrCounterpartyNotFound, "counterparty not found for client: %s", packet.DestinationClient)
Expand Down Expand Up @@ -190,7 +190,7 @@ func (k Keeper) WriteAcknowledgement(
}

func (k *Keeper) acknowledgePacket(ctx context.Context, packet types.Packet, acknowledgement types.Acknowledgement, proof []byte, proofHeight exported.Height) error {
// lookup counterparty from packet identifiers
// lookup counterparty from client identifiers
counterparty, ok := k.ClientKeeper.GetClientCounterparty(ctx, packet.SourceClient)
if !ok {
return errorsmod.Wrapf(clienttypes.ErrCounterpartyNotFound, "counterparty not found for client: %s", packet.SourceClient)
Expand Down Expand Up @@ -254,7 +254,7 @@ func (k *Keeper) timeoutPacket(
proof []byte,
proofHeight exported.Height,
) error {
// lookup counterparty from packet identifiers
// lookup counterparty from client identifiers
counterparty, ok := k.ClientKeeper.GetClientCounterparty(ctx, packet.SourceClient)
if !ok {
return errorsmod.Wrapf(clienttypes.ErrCounterpartyNotFound, "counterparty not found for client: %s", packet.SourceClient)
Expand Down

0 comments on commit b759f29

Please sign in to comment.