Remove missing proof leniency

This commit is contained in:
Arnaud 2025-01-14 12:16:47 +01:00
parent dfab6102e7
commit 917ad50837
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
7 changed files with 23 additions and 32 deletions

View File

@ -6,7 +6,6 @@ const DEFAULT_CONFIGURATION = {
collateral: {
repairRewardPercentage: 10,
maxNumberOfSlashes: 2,
slashCriterion: 2,
slashPercentage: 20,
},
proofs: {
@ -14,16 +13,16 @@ const DEFAULT_CONFIGURATION = {
period: 120, // seconds
timeout: 30, // seconds
downtime: 64, // number of blocks
downtimeProduct: 67 // number of blocks
downtimeProduct: 67, // number of blocks
},
reservations: {
maxReservations: 3
}
maxReservations: 3,
},
}
function loadConfiguration(name) {
const path = `${BASE_PATH}/${name}/configuration.js`
if(fs.existsSync(path)) {
if (fs.existsSync(path)) {
return require(path)
} else {
return DEFAULT_CONFIGURATION

View File

@ -2,7 +2,6 @@ module.exports = {
collateral: {
repairRewardPercentage: 10,
maxNumberOfSlashes: 2,
slashCriterion: 2,
slashPercentage: 20,
},
proofs: {
@ -11,9 +10,9 @@ module.exports = {
period: 90, // seconds
timeout: 30, // seconds
downtime: 96, // number of blocks
downtimeProduct: 97 // number of blocks
downtimeProduct: 97, // number of blocks
},
reservations: {
maxReservations: 3
}
maxReservations: 3,
},
}

View File

@ -13,7 +13,6 @@ struct CollateralConfig {
/// @dev percentage of collateral that is used as repair reward
uint8 repairRewardPercentage;
uint8 maxNumberOfSlashes; // frees slot when the number of slashing reaches this value
uint16 slashCriterion; // amount of proofs missed that lead to slashing
uint8 slashPercentage; // percentage of the collateral that is slashed
}

View File

@ -9,7 +9,7 @@ contract FuzzMarketplace is Marketplace {
constructor()
Marketplace(
MarketplaceConfig(
CollateralConfig(10, 5, 3, 10),
CollateralConfig(10, 5, 10),
ProofConfig(10, 5, 64, "", 67),
SlotReservationsConfig(20)
),

View File

@ -283,18 +283,13 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
// TODO: Reward for validator that calls this function
if (missingProofs(slotId) % _config.collateral.slashCriterion == 0) {
uint256 slashedAmount = (request.ask.collateral *
_config.collateral.slashPercentage) / 100;
slot.currentCollateral -= slashedAmount;
if (
missingProofs(slotId) / _config.collateral.slashCriterion >=
_config.collateral.maxNumberOfSlashes
) {
// When the number of slashings is at or above the allowed amount,
// free the slot.
_forciblyFreeSlot(slotId);
}
uint256 slashedAmount = (request.ask.collateral *
_config.collateral.slashPercentage) / 100;
slot.currentCollateral -= slashedAmount;
if (missingProofs(slotId) >= _config.collateral.maxNumberOfSlashes) {
// When the number of slashings is at or above the allowed amount,
// free the slot.
_forciblyFreeSlot(slotId);
}
}

View File

@ -1260,17 +1260,17 @@ describe("Marketplace", function () {
})
describe("slashing when missing proofs", function () {
it("reduces collateral when too many proofs are missing", async function () {
it("reduces collateral when a proof is missing", async function () {
const id = slotId(slot)
const { slashCriterion, slashPercentage } = config.collateral
const { slashPercentage } = config.collateral
await marketplace.reserveSlot(slot.request, slot.index)
await marketplace.fillSlot(slot.request, slot.index, proof)
for (let i = 0; i < slashCriterion; i++) {
await waitUntilProofIsRequired(id)
let missedPeriod = periodOf(await currentTime())
await advanceTimeForNextBlock(period + 1)
await marketplace.markProofAsMissing(id, missedPeriod)
}
await waitUntilProofIsRequired(id)
let missedPeriod = periodOf(await currentTime())
await advanceTimeForNextBlock(period + 1)
await marketplace.markProofAsMissing(id, missedPeriod)
const expectedBalance =
(request.ask.collateral * (100 - slashPercentage)) / 100

View File

@ -6,7 +6,6 @@ const exampleConfiguration = () => ({
collateral: {
repairRewardPercentage: 10,
maxNumberOfSlashes: 5,
slashCriterion: 3,
slashPercentage: 10,
},
proofs: {