Skip to content

Commit

Permalink
R4R: Fix failack payload (#247)
Browse files Browse the repository at this point in the history
* remove header before insert it into fail ack package

* add missed proposal type
  • Loading branch information
HaoyangLiu authored Jan 4, 2021
1 parent cf24678 commit 32ba1b5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions types/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const (
BEP8 = "BEP8" // Mini-BEP2 token
LaunchBscUpgrade = "LaunchBscUpgrade"
BEP82 = "BEP82" // https://github.com/binance-chain/BEPs/pull/82
FixFailAckPackage = "FixFailAckPackage"
)

var MainNetConfig = UpgradeConfig{
Expand Down
6 changes: 6 additions & 0 deletions x/gov/client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func NormalizeProposalType(proposalType string) string {
return "CreateValidator"
case "RemoveValidator", "remove_validator":
return "RemoveValidator"
case "SCParamsChange", "sc_params_change":
return "SCParamsChange"
case "CSCParamsChange", "csc_params_change":
return "CSCParamsChange"
case "ManageChanPermission", "manage_chan_permission":
return "ManageChanPermission"
}
return ""
}
Expand Down
16 changes: 12 additions & 4 deletions x/oracle/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,19 @@ func handlePackage(ctx sdk.Context, oracleKeeper Keeper, chainId sdk.ChainID, pa
var sendSequence int64 = -1
if packageType == sdk.SynCrossChainPackageType {
if crash {
sendSeq, err := oracleKeeper.IbcKeeper.CreateRawIBCPackageById(ctx, chainId,
pack.ChannelId, sdk.FailAckCrossChainPackageType, pack.Payload)
if err != nil {
var ibcErr sdk.Error
var sendSeq uint64
if sdk.IsUpgrade(sdk.FixFailAckPackage) && len(pack.Payload) >= sTypes.PackageHeaderLength {
sendSeq, ibcErr = oracleKeeper.IbcKeeper.CreateRawIBCPackageById(ctx, chainId,
pack.ChannelId, sdk.FailAckCrossChainPackageType, pack.Payload[sTypes.PackageHeaderLength:])
} else {
logger.Error("found payload without header", "channelID", pack.ChannelId, "sequence", pack.Sequence, "payload", hex.EncodeToString(pack.Payload))
sendSeq, ibcErr = oracleKeeper.IbcKeeper.CreateRawIBCPackageById(ctx, chainId,
pack.ChannelId, sdk.FailAckCrossChainPackageType, pack.Payload)
}
if ibcErr != nil {
logger.Error("failed to write FailAckCrossChainPackage", "err", err)
return sdk.Event{}, err
return sdk.Event{}, ibcErr
}
sendSequence = int64(sendSeq)
} else {
Expand Down

0 comments on commit 32ba1b5

Please sign in to comment.