From 6fd155b031c879fce4c9bcfc4fec939c44a7a957 Mon Sep 17 00:00:00 2001 From: nuco-shidokht Date: Wed, 16 Oct 2019 17:12:48 -0400 Subject: [PATCH] Added additional documentation --- pool-registry/src/main/java/org/aion/unity/PoolRegistry.java | 4 +++- .../main/java/org/aion/unity/PoolRewardsStateMachine.java | 5 +++-- .../src/main/java/org/aion/unity/StakerRegistry.java | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pool-registry/src/main/java/org/aion/unity/PoolRegistry.java b/pool-registry/src/main/java/org/aion/unity/PoolRegistry.java index 5747774..294be3f 100644 --- a/pool-registry/src/main/java/org/aion/unity/PoolRegistry.java +++ b/pool-registry/src/main/java/org/aion/unity/PoolRegistry.java @@ -22,7 +22,6 @@ public class PoolRegistry { private static final BigInteger MIN_SELF_STAKE; // 1000 Aions private static final BigInteger MIN_SELF_STAKE_PERCENTAGE; // 1% - // todo check value private static final long COMMISSION_RATE_CHANGE_TIME_LOCK_PERIOD; // 6 * 60 * 24 * 7 private static final Address STAKER_REGISTRY; @@ -804,6 +803,9 @@ private static Result secureCall(Address targetAddress, BigInteger value, byte[] } private static void detectBlockRewards(PoolRewardsStateMachine rewardsStateMachine) { + // This address represents the coinbase contract that was deployed by the PoolRegistry. + // PoolRegistry stores the contract bytecode and deploys it for each new pool, and thus this a trusted contract. + // Pool operators are unable to deploy their own custom contract or change their coinbase address. Address coinbaseAddress = rewardsStateMachine.currentPoolRewards.coinbaseAddress; BigInteger balance = Blockchain.getBalance(coinbaseAddress); // balance > 0 diff --git a/pool-registry/src/main/java/org/aion/unity/PoolRewardsStateMachine.java b/pool-registry/src/main/java/org/aion/unity/PoolRewardsStateMachine.java index 909ed58..ad0cfcc 100644 --- a/pool-registry/src/main/java/org/aion/unity/PoolRewardsStateMachine.java +++ b/pool-registry/src/main/java/org/aion/unity/PoolRewardsStateMachine.java @@ -5,8 +5,9 @@ import java.math.BigInteger; /** - * See https://github.com/ali-sharif/f1-fee-distribution for a PoC implementation of the F1 algorithm - * TODO: need more tests for this class + * Note that asserts are used in this class instead of Blockchain.require(), since at this stage of a call all the parameters and the state of + * the contract have been validated. We don't expect any of these conditions to be false. + * Also, assertions in AVM are always enabled. */ public class PoolRewardsStateMachine { diff --git a/staker-registry/src/main/java/org/aion/unity/StakerRegistry.java b/staker-registry/src/main/java/org/aion/unity/StakerRegistry.java index 361c80f..f757c86 100644 --- a/staker-registry/src/main/java/org/aion/unity/StakerRegistry.java +++ b/staker-registry/src/main/java/org/aion/unity/StakerRegistry.java @@ -16,7 +16,7 @@ public class StakerRegistry { private static final BigInteger MIN_STAKE; // 1000 Aions private static final long SIGNING_ADDRESS_COOLING_PERIOD; // 6 * 60 * 24 * 7; - private static final long UNBOND_LOCK_UP_PERIOD; // 6 * 60 * 24 * 7; + private static final long UNBOND_LOCK_UP_PERIOD; // 6 * 60 * 24; private static final long TRANSFER_LOCK_UP_PERIOD; // 6 * 10; private static long nextUnbondId = 0;