From 8fb0afddfb89d3902fe2f5b2bf96bda837c4f51d Mon Sep 17 00:00:00 2001 From: nolash Date: Fri, 5 Feb 2021 19:02:01 +0100 Subject: [PATCH] To be safe, zero out participant data in redistribution on default case --- solidity/RedistributedDemurrageToken.sol | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/solidity/RedistributedDemurrageToken.sol b/solidity/RedistributedDemurrageToken.sol index 0552edb..142ae11 100644 --- a/solidity/RedistributedDemurrageToken.sol +++ b/solidity/RedistributedDemurrageToken.sol @@ -207,6 +207,8 @@ contract RedistributedDemurrageToken { return _sumWhole - truncatedResult; } + // Called in the edge case where participant number is 0. It will override the participant count to 1. + // Returns the remainder sent to the sink address function applyDefaultRedistribution(bytes32 _redistribution) private returns (uint256) { uint256 redistributionSupply; uint256 redistributionPeriod; @@ -221,7 +223,8 @@ contract RedistributedDemurrageToken { if (truncatedResult < redistributionSupply) { redistributionPeriod = toRedistributionPeriod(_redistribution); // since we reuse period here, can possibly be optimized by passing period instead - redistributions[redistributionPeriod-1] |= 0x8000000000000000000000000000000000000000000000000000000000000000; + redistributions[redistributionPeriod-1] &= 0x0000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffff; // just to be safe, zero out all participant count data, in this case there will be only one + redistributions[redistributionPeriod-1] |= 0x8000000001000000000000000000000000000000000000000000000000000000; } increaseBaseBalance(sinkAddress, unit); //truncatedResult);