Skip to content

Commit

Permalink
gpush
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt committed Jun 10, 2024
1 parent 68f75f6 commit 8631573
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion x/rollapp/keeper/transfer_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (k Keeper) VerifyAndRecordGenesisTransfer(ctx sdk.Context, rollappID string
if ra.GenesisState.TransfersEnabled {
// Could plausibly occur if a chain sends too many genesis transfers (not matching their memo)
// or if a chain which registered with the bridge enabled tries to send some genesis transfers
return 0, errorsmod.Wrap(dymerror.ErrFraud, "received genesis transfer but transfers are already enabled")
return 0, errorsmod.Wrap(dymerror.ErrFraud, "received genesis transfer but all bridge transfers are already enabled")
}

store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TransferGenesisMapKeyPrefix))
Expand Down
15 changes: 14 additions & 1 deletion x/rollapp/transfergenesis/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ func (w IBCMiddleware) OnRecvPacket(

nTransfersDone, err := w.rollappKeeper.VerifyAndRecordGenesisTransfer(ctx, ra.RollappId, m.ThisTransferIx, m.TotalNumTransfers)
if errorsmod.IsOf(err, dymerror.ErrFraud) {
// TODO: emit event or freeze rollapp, or something else?
l.Info("rollapp fraud: verify and record genesis transfer", "err", err)
// The rollapp has deviated from the protocol!
err = w.handleFraud(ra.RollappId)
if err != nil {
l.Error("handle fraud", "error", err)
}
}
if err != nil {
l.Error("verify and record transfer", "error", err)
Expand Down Expand Up @@ -202,6 +207,14 @@ func (w IBCMiddleware) OnRecvPacket(
return w.Middleware.OnRecvPacket(delayedacktypes.SkipContext(ctx), packet, relayer)
}

func (w IBCMiddleware) handleFraud(raID string) error {
// TODO: assumes we have a robust mechanism to freeze and rollback
// NOTE: this may not be a fraud in the sense that the sequencer posted the wrong state root
// it might be that the canonical state transition function for the RA is wrong somehow
// and resulted in a protocol breakage
return nil
}

func allTransfersReceivedEvent(raID string, nReceived uint64) sdk.Event {
return sdk.NewEvent(types.EventTypeTransferGenesisAllReceived,
sdk.NewAttribute(types.AttributeKeyRollappId, raID),
Expand Down

0 comments on commit 8631573

Please sign in to comment.