Conversation
Codecov Report
@@ Coverage Diff @@
## master #1459 +/- ##
==========================================
+ Coverage 84.31% 84.48% +0.17%
==========================================
Files 72 72
Lines 11225 11293 +68
==========================================
+ Hits 9464 9541 +77
+ Misses 1761 1752 -9
Continue to review full report at Codecov.
|
6f4f2b4 to
38e9fa3
Compare
5de4194 to
09d11e3
Compare
27193e1 to
c3b995f
Compare
| duration_periods = calculate_period_duration(now=maya.MayaDT(now), | ||
| future_time=expiration, | ||
| seconds_per_period=self.economics.seconds_per_period) | ||
| duration_periods += 1 # Number of all included periods |
There was a problem hiding this comment.
Are we using +=1 because the current day counts as one? Should calculate_period_duration make this adjustment, instead of having to manually do it?
There was a problem hiding this comment.
Yeah, you're right, calculatePeriodDuration returns periodAt(expiration) - periodAt(now) and we add current period.
Should
calculate_period_durationmake this adjustment, instead of having to manually do it?
Good question, I'm still not sure what behaviour is more straightforward
There was a problem hiding this comment.
It would seem that it should to me, but it may depend on where else it is used, and whether that same +=1 logic applies.
There was a problem hiding this comment.
calculatePeriodDuratio used in initialize_stake without adding 1
Co-Authored-By: Derek Pierre <derek.pierre@gmail.com>
Co-Authored-By: Derek Pierre <derek.pierre@gmail.com>
tests/blockchain/eth/contracts/integration/test_intercontract_integration.py
Outdated
Show resolved
Hide resolved
| expiration = datetime_at_period(self.staking_agent.get_current_period() + duration_periods, | ||
| seconds_per_period=self.economics.seconds_per_period) | ||
| seconds_per_period=self.economics.seconds_per_period, | ||
| start_of_period=True) |
There was a problem hiding this comment.
The comment says "expiration date is the last second of the current period", but here we pass start_of_period=True - what am I missing?
There was a problem hiding this comment.
We take start of the next period and subtract 1 second (next line)
There was a problem hiding this comment.
I'm sorry, maybe I'm being thick here, but I still don't get it. How does subtracting one second from the MayaDT get us to the last second of the current period? And how does start_of_period=True relate to that?
There was a problem hiding this comment.
maybe comment is misleading, current period will be only for case when duration_periods==1, sort of example.
In that case start_of_period=True will return zero/first second of the next period and subtracting 1 second we will come to the last second of the previous period.
If duration_periods==2 then start_of_period=True will be period after next period and expiration after subtracting will be last second of the next period
start_of_period=True is sort of rounding, returns the beggining of calculated period
|
OK, after a first full read-through, here's what I think I'm seeing - correct me where I'm wrong and add what I'm missing:
|
|
@jMyles All good, I'll add some remarks:
|
| Payment should be added to the transaction in ETH and the amount is `firstReward * stakers.length + rewardRate * periods * stakers.length`. | ||
| The reward rate must be greater than or equal to the minimum reward for each staker in the list. The first period's reward is not refundable, and can be zero. | ||
| In order to place the fee for a policy, Alice calls the method `PolicyManager.createPolicy(bytes16, address, uint64, address[])`, | ||
| specifying the stakers' addresses, the policy ID (off-chain generation), the policy owner (could be zero address), and the end timestamp of the policy. |
There was a problem hiding this comment.
The address argument before the policy ID is missing.
There was a problem hiding this comment.
Not sure about address, maybe question with order in description? I've put stakers addresses to the end of the sentence
| event PolicyCreated( | ||
| bytes16 indexed policyId, | ||
| address indexed client | ||
| address indexed creator, |
There was a problem hiding this comment.
Rather than creator, it should be something like sponsor, payer, etc.
| * @return Revocation hash | ||
| */ | ||
| function getRevocationHash(bytes16 _policyId, address _node) public view returns (bytes32) { | ||
| return SignatureVerifier.hashEIP191(abi.encodePacked(_policyId, _node), byte(0x45)); |
There was a problem hiding this comment.
I think this line deserves a comment explaining we're using EIP191 version 0x45 ('E') for personal_sign
| expiration = maya.now() + datetime.timedelta(days=3) | ||
| days = 3 | ||
| now = testerchain.w3.eth.getBlock(block_identifier='latest').timestamp | ||
| expiration = maya.MayaDT(now).add(days=days-1) |
There was a problem hiding this comment.
This whole manually subtracting/adding a day is not intuitive at all.
There was a problem hiding this comment.
How about expiration = maya.now() - timedelta(days=1)?
There was a problem hiding this comment.
how about to rename days to days_to_pay or to something similar?
There was a problem hiding this comment.
I think I need to explain it better what is core of these changes:
Before this PR duration of policy was equal to periods for which Alice pays. Also was firstPartialReward, kind of alternative way to pay for current period.
Now duration in seconds and not in periods. But payment still in periods. Sort of border between Alice and staker/worker regarding fees. Also duration includes current period by default (start timestamp is block.timestamp), so we get payment periods == duration periods + 1 (I mean duration periods as ceiling of (endTimestamp - block.timestamp)/secondsPerPeriod). Of course it's possible that payment periods == duration periods in case when block.timestamp == first second of current period and end timestamp == last second of any period but this situation is not used in tests
Co-Authored-By: Derek Pierre <derek.pierre@gmail.com> Co-Authored-By: David Núñez <david@nucypher.com>
Co-Authored-By: Derek Pierre <derek.pierre@gmail.com> Co-Authored-By: David Núñez <david@nucypher.com>
Based on #1470
Refs #1188
Closes #1063
Refs #1406
Refs #1492
PolicyManager
v1.1.2->v 2.1.1StakingEscrow
v1.4.1->v2.1.1