Skip to content

Commit

Permalink
Added rogue mode for missingIDs and extraIds dispute
Browse files Browse the repository at this point in the history
  • Loading branch information
Yashk767 committed Apr 7, 2022
1 parent a0fb9bb commit 8eb3a93
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/dispute.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (*UtilsStruct) GetLocalMediansData(client *ethclient.Client, account types.
_revealedCollectionIds = proposedata.RevealedCollectionIds
}
CalculateMedian:
if _mediansData == nil || _revealedCollectionIds == nil || _revealedDataMaps == nil {
if _mediansData == nil || _revealedCollectionIds == nil || _revealedDataMaps == nil || rogueData.IsRogue {
medians, revealedCollectionIds, revealedDataMaps, err := cmdUtils.MakeBlock(client, blockNumber, epoch, types.Rogue{IsRogue: false})
if err != nil {
log.Error("Error in calculating block medians")
Expand Down Expand Up @@ -224,6 +224,12 @@ func (*UtilsStruct) CheckDisputeForIds(client *ethclient.Client, transactionOpts
transactionOpts.MethodName = "disputeCollectionIdShouldBeAbsent"
transactionOpts.Parameters = []interface{}{epoch, blockIndex, presentCollectionId, big.NewInt(int64(positionOfPresentValue))}
txnOpts := razorUtils.GetTxnOpts(transactionOpts)
gasLimit := txnOpts.GasLimit
incrementedGasLimit, err := utilsInterface.IncreaseGasLimitValue(client, gasLimit, 5.5)
if err != nil {
return nil, err
}
txnOpts.GasLimit = incrementedGasLimit
log.Debug("Disputing collection id should be absent!")
log.Debugf("Epoch: %d, blockIndex: %d, presentCollectionId: %d, positionOfPresentValue: %d", epoch, blockIndex, presentCollectionId, positionOfPresentValue)
return blockManagerUtils.DisputeCollectionIdShouldBeAbsent(client, txnOpts, epoch, blockIndex, presentCollectionId, big.NewInt(int64(positionOfPresentValue)))
Expand Down
10 changes: 10 additions & 0 deletions cmd/propose.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ func (*UtilsStruct) MakeBlock(client *ethclient.Client, blockNumber *big.Int, ep
}
}
}
if rogueData.IsRogue && utils.Contains(rogueData.RogueMode, "missingIds") {
//Replacing the last ID: id with id+1 in idsRevealed array if rogueMode == missingIds
idsRevealedInThisEpoch[len(idsRevealedInThisEpoch)-1] = idsRevealedInThisEpoch[len(idsRevealedInThisEpoch)-1] + 1
}
if rogueData.IsRogue && utils.Contains(rogueData.RogueMode, "extraIds") {
//Adding a dummy median and appending extra id to idsRevealed array if rogueMode == extraIds
medians = append(medians, rand.Uint32())
idsRevealedInThisEpoch = append(idsRevealedInThisEpoch, idsRevealedInThisEpoch[len(idsRevealedInThisEpoch)-1]+1)

}
return medians, idsRevealedInThisEpoch, revealedDataMaps, nil
}

Expand Down

0 comments on commit 8eb3a93

Please sign in to comment.