Skip to content

Commit

Permalink
order arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanhNhann committed Sep 4, 2023
1 parent 81be4fe commit 2de3727
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 63 deletions.
20 changes: 10 additions & 10 deletions modules/core/03-connection/keeper/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ func (k Keeper) VerifyConnectionState(
// channel end, under the specified port, stored on the target machine.
func (k Keeper) VerifyChannelState(
ctx sdk.Context,
portID,
channelID string,
connection exported.ConnectionI,
height exported.Height,
proof []byte,
portID,
channelID string,
channel exported.ChannelI,
) error {
clientID := connection.GetClientID()
Expand Down Expand Up @@ -199,11 +199,11 @@ func (k Keeper) VerifyChannelState(
// the specified port, specified channel, and specified sequence.
func (k Keeper) VerifyPacketCommitment(
ctx sdk.Context,
portID,
channelID string,
connection exported.ConnectionI,
height exported.Height,
proof []byte,
portID,
channelID string,
sequence uint64,
commitmentBytes []byte,
) error {
Expand Down Expand Up @@ -242,11 +242,11 @@ func (k Keeper) VerifyPacketCommitment(
// acknowledgement at the specified port, specified channel, and specified sequence.
func (k Keeper) VerifyPacketAcknowledgement(
ctx sdk.Context,
portID,
channelID string,
connection exported.ConnectionI,
height exported.Height,
proof []byte,
portID,
channelID string,
sequence uint64,
acknowledgement []byte,
) error {
Expand Down Expand Up @@ -286,11 +286,11 @@ func (k Keeper) VerifyPacketAcknowledgement(
// specified sequence.
func (k Keeper) VerifyPacketReceiptAbsence(
ctx sdk.Context,
portID,
channelID string,
connection exported.ConnectionI,
height exported.Height,
proof []byte,
portID,
channelID string,
sequence uint64,
) error {
clientID := connection.GetClientID()
Expand Down Expand Up @@ -328,11 +328,11 @@ func (k Keeper) VerifyPacketReceiptAbsence(
// received of the specified channel at the specified port.
func (k Keeper) VerifyNextSequenceRecv(
ctx sdk.Context,
portID,
channelID string,
connection exported.ConnectionI,
height exported.Height,
proof []byte,
portID,
channelID string,
nextSequenceRecv uint64,
) error {
clientID := connection.GetClientID()
Expand Down
20 changes: 10 additions & 10 deletions modules/core/03-connection/keeper/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ func (suite *KeeperTestSuite) TestVerifyChannelState() {
channel := path.EndpointB.GetChannel()

err := suite.chainA.App.GetIBCKeeper().ConnectionKeeper.VerifyChannelState(
suite.chainA.GetContext(), connection, malleateHeight(proofHeight, heightDiff), proof,
path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, channel,
suite.chainA.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, connection,
malleateHeight(proofHeight, heightDiff), proof, channel,
)

if tc.expPass {
Expand Down Expand Up @@ -363,8 +363,8 @@ func (suite *KeeperTestSuite) TestVerifyPacketCommitment() {

commitment := channeltypes.CommitPacket(suite.chainB.App.GetIBCKeeper().Codec(), packet)
err = suite.chainB.App.GetIBCKeeper().ConnectionKeeper.VerifyPacketCommitment(
suite.chainB.GetContext(), connection, malleateHeight(proofHeight, heightDiff), proof,
packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence(), commitment,
suite.chainB.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), connection,
malleateHeight(proofHeight, heightDiff), proof, packet.GetSequence(), commitment,
)

if tc.expPass {
Expand Down Expand Up @@ -464,8 +464,8 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() {
}

err = suite.chainA.App.GetIBCKeeper().ConnectionKeeper.VerifyPacketAcknowledgement(
suite.chainA.GetContext(), connection, malleateHeight(proofHeight, heightDiff), proof,
packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), ack.Acknowledgement(),
suite.chainA.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), connection,
malleateHeight(proofHeight, heightDiff), proof, packet.GetSequence(), ack.Acknowledgement(),
)

if tc.expPass {
Expand Down Expand Up @@ -570,8 +570,8 @@ func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() {
}

err = suite.chainA.App.GetIBCKeeper().ConnectionKeeper.VerifyPacketReceiptAbsence(
suite.chainA.GetContext(), connection, malleateHeight(proofHeight, heightDiff), proof,
packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(),
suite.chainA.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), connection,
malleateHeight(proofHeight, heightDiff), proof, packet.GetSequence(),
)

if tc.expPass {
Expand Down Expand Up @@ -669,8 +669,8 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() {
connection := path.EndpointA.GetConnection()
connection.DelayPeriod = delayTimePeriod
err = suite.chainA.App.GetIBCKeeper().ConnectionKeeper.VerifyNextSequenceRecv(
suite.chainA.GetContext(), connection, malleateHeight(proofHeight, heightDiff), proof,
packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()+offsetSeq,
suite.chainA.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), connection,
malleateHeight(proofHeight, heightDiff), proof, packet.GetSequence()+offsetSeq,
)

if tc.expPass {
Expand Down
18 changes: 8 additions & 10 deletions modules/core/04-channel/keeper/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ func (k Keeper) ChanOpenTry(
)

if err := k.connectionKeeper.VerifyChannelState(
ctx, connectionEnd, proofHeight, proofInit,
counterparty.PortId, counterparty.ChannelId, expectedChannel,
ctx, counterparty.PortId, counterparty.ChannelId, connectionEnd,
proofHeight, proofInit, expectedChannel,
); err != nil {
return "", nil, err
}
Expand Down Expand Up @@ -259,9 +259,8 @@ func (k Keeper) ChanOpenAck(
)

return k.connectionKeeper.VerifyChannelState(
ctx, connectionEnd, proofHeight, proofTry,
channel.Counterparty.PortId, counterpartyChannelID,
expectedChannel)
ctx, channel.Counterparty.PortId, counterpartyChannelID,
connectionEnd, proofHeight, proofTry, expectedChannel)
}

// WriteOpenAckChannel writes an updated channel state for the successful OpenAck handshake step.
Expand Down Expand Up @@ -337,9 +336,8 @@ func (k Keeper) ChanOpenConfirm(
)

return k.connectionKeeper.VerifyChannelState(
ctx, connectionEnd, proofHeight, proofAck,
channel.Counterparty.PortId, channel.Counterparty.ChannelId,
expectedChannel)
ctx, channel.Counterparty.PortId, channel.Counterparty.ChannelId,
connectionEnd, proofHeight, proofAck, expectedChannel)
}

// WriteOpenConfirmChannel writes an updated channel state for the successful OpenConfirm handshake step.
Expand Down Expand Up @@ -466,8 +464,8 @@ func (k Keeper) ChanCloseConfirm(
)

if err := k.connectionKeeper.VerifyChannelState(
ctx, connectionEnd, proofHeight, proofInit,
channel.Counterparty.PortId, channel.Counterparty.ChannelId,
ctx, channel.Counterparty.PortId, channel.Counterparty.ChannelId,
connectionEnd, proofHeight, proofInit,
expectedChannel,
); err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions modules/core/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ func (k Keeper) RecvPacket(

// verify that the counterparty did commit to sending this packet
if err := k.connectionKeeper.VerifyPacketCommitment(
ctx, connectionEnd, proofHeight, proof,
packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence(),
ctx, packet.GetSourcePort(), packet.GetSourceChannel(), connectionEnd,
proofHeight, proof, packet.GetSequence(),
commitment,
); err != nil {
return errorsmod.Wrap(err, "couldn't verify counterparty packet commitment")
Expand Down Expand Up @@ -443,7 +443,7 @@ func (k Keeper) AcknowledgePacket(
}

if err := k.connectionKeeper.VerifyPacketAcknowledgement(
ctx, connectionEnd, proofHeight, proof, packet.GetDestPort(), packet.GetDestChannel(),
ctx, packet.GetDestPort(), packet.GetDestChannel(), connectionEnd, proofHeight, proof,
packet.GetSequence(), acknowledgement,
); err != nil {
return err
Expand Down
20 changes: 10 additions & 10 deletions modules/core/04-channel/keeper/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ func (k Keeper) TimeoutPacket(

// check that the recv sequence is as claimed
err = k.connectionKeeper.VerifyNextSequenceRecv(
ctx, connectionEnd, proofHeight, proof,
packet.GetDestPort(), packet.GetDestChannel(), nextSequenceRecv,
ctx, packet.GetDestPort(), packet.GetDestChannel(), connectionEnd,
proofHeight, proof, nextSequenceRecv,
)
case types.UNORDERED:
err = k.connectionKeeper.VerifyPacketReceiptAbsence(
ctx, connectionEnd, proofHeight, proof,
packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(),
ctx, packet.GetDestPort(), packet.GetDestChannel(), connectionEnd,
proofHeight, proof, packet.GetSequence(),
)
default:
panic(errorsmod.Wrapf(types.ErrInvalidChannelOrdering, channel.Ordering.String()))
Expand Down Expand Up @@ -276,8 +276,8 @@ func (k Keeper) TimeoutOnClose(

// check that the opposing channel end has closed
if err := k.connectionKeeper.VerifyChannelState(
ctx, connectionEnd, proofHeight, proofClosed,
channel.Counterparty.PortId, channel.Counterparty.ChannelId,
ctx, channel.Counterparty.PortId, channel.Counterparty.ChannelId,
connectionEnd, proofHeight, proofClosed,
expectedChannel,
); err != nil {
return err
Expand All @@ -293,13 +293,13 @@ func (k Keeper) TimeoutOnClose(

// check that the recv sequence is as claimed
err = k.connectionKeeper.VerifyNextSequenceRecv(
ctx, connectionEnd, proofHeight, proof,
packet.GetDestPort(), packet.GetDestChannel(), nextSequenceRecv,
ctx, packet.GetDestPort(), packet.GetDestChannel(), connectionEnd,
proofHeight, proof, nextSequenceRecv,
)
case types.UNORDERED:
err = k.connectionKeeper.VerifyPacketReceiptAbsence(
ctx, connectionEnd, proofHeight, proof,
packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(),
ctx, packet.GetDestPort(), packet.GetDestChannel(), connectionEnd,
proofHeight, proof, packet.GetSequence(),
)
default:
panic(errorsmod.Wrapf(types.ErrInvalidChannelOrdering, channel.Ordering.String()))
Expand Down
20 changes: 10 additions & 10 deletions modules/core/04-channel/keeper/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ func (k Keeper) ChanUpgradeTry(
// verify the counterparty channel state containing the upgrade sequence
if err := k.connectionKeeper.VerifyChannelState(
ctx,
connection,
proofHeight, proofCounterpartyChannel,
channel.Counterparty.PortId,
channel.Counterparty.ChannelId,
connection,
proofHeight, proofCounterpartyChannel,
counterpartyChannel,
); err != nil {
return types.Upgrade{}, errorsmod.Wrap(err, "failed to verify counterparty channel state")
Expand Down Expand Up @@ -249,10 +249,10 @@ func (k Keeper) ChanUpgradeAck(
// verify the counterparty channel state containing the upgrade sequence
if err := k.connectionKeeper.VerifyChannelState(
ctx,
connection,
proofHeight, proofChannel,
channel.Counterparty.PortId,
channel.Counterparty.ChannelId,
connection,
proofHeight, proofChannel,
counterpartyChannel,
); err != nil {
return errorsmod.Wrap(err, "failed to verify counterparty channel state")
Expand Down Expand Up @@ -378,10 +378,10 @@ func (k Keeper) ChanUpgradeConfirm(

if err := k.connectionKeeper.VerifyChannelState(
ctx,
connection,
proofHeight, proofChannel,
channel.Counterparty.PortId,
channel.Counterparty.ChannelId,
connection,
proofHeight, proofChannel,
counterpartyChannel,
); err != nil {
return errorsmod.Wrap(err, "failed to verify counterparty channel state")
Expand Down Expand Up @@ -502,10 +502,10 @@ func (k Keeper) ChanUpgradeOpen(

if err := k.connectionKeeper.VerifyChannelState(
ctx,
connection,
proofHeight, proofCounterpartyChannel,
channel.Counterparty.PortId,
channel.Counterparty.ChannelId,
connection,
proofHeight, proofCounterpartyChannel,
counterpartyChannel,
); err != nil {
return errorsmod.Wrap(err, "failed to verify counterparty channel")
Expand Down Expand Up @@ -706,10 +706,10 @@ func (k Keeper) ChanUpgradeTimeout(
// verify the counterparty channel state
if err := k.connectionKeeper.VerifyChannelState(
ctx,
connection,
proofHeight, proofCounterpartyChannel,
channel.Counterparty.PortId,
channel.Counterparty.ChannelId,
connection,
proofHeight, proofCounterpartyChannel,
counterpartyChannel,
); err != nil {
return errorsmod.Wrap(err, "failed to verify counterparty channel state")
Expand Down
20 changes: 10 additions & 10 deletions modules/core/04-channel/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,49 @@ type ConnectionKeeper interface {
) (uint64, error)
VerifyChannelState(
ctx sdk.Context,
portID,
channelID string,
connection exported.ConnectionI,
height exported.Height,
proof []byte,
portID,
channelID string,
channel exported.ChannelI,
) error
VerifyPacketCommitment(
ctx sdk.Context,
portID,
channelID string,
connection exported.ConnectionI,
height exported.Height,
proof []byte,
portID,
channelID string,
sequence uint64,
commitmentBytes []byte,
) error
VerifyPacketAcknowledgement(
ctx sdk.Context,
portID,
channelID string,
connection exported.ConnectionI,
height exported.Height,
proof []byte,
portID,
channelID string,
sequence uint64,
acknowledgement []byte,
) error
VerifyPacketReceiptAbsence(
ctx sdk.Context,
portID,
channelID string,
connection exported.ConnectionI,
height exported.Height,
proof []byte,
portID,
channelID string,
sequence uint64,
) error
VerifyNextSequenceRecv(
ctx sdk.Context,
portID,
channelID string,
connection exported.ConnectionI,
height exported.Height,
proof []byte,
portID,
channelID string,
nextSequenceRecv uint64,
) error
VerifyChannelUpgrade(
Expand Down

0 comments on commit 2de3727

Please sign in to comment.