Skip to content

Commit

Permalink
remove header before insert it into fail ack package
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoyangLiu committed Dec 31, 2020
1 parent cf24678 commit 11c033f
Show file tree
Hide file tree
Showing 2 changed files with 13 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
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 11c033f

Please sign in to comment.