-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Payroll Milestone 1 - Addressing review comments #568
Conversation
…as other functions
- Make getters as public - Delete Migrations.sol since it's been imported in TestImports.sol - Remove unused migration file - Prune some public constants - Make employeeId uint256 - Fix some role params - Add _ prefix for function arguments - Move MAX_ACCRUED_VALUE check to _addAccruedValue function - Remove escapeHatch function - Some minor changes from code review - Transform getAllocation into a more generic getter - Improve gas efficiency when adding an employee - Increase minimun rate expiry time - Some minor changes from code review - Add dates check in _getOwnedSalary - Ammend _getExchangeRate docs - Add generic reference when calling finance newPayment - Bump some dependencies versions - Fix contract unit test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lmcorbalan Thanks for making the changes! It's looking really good!
I added a number of commits, mostly just to smooth some things out that were easier to do myself, like little comment tweaks or rewording :).
I think there's still three changes we could make (cc @bingen @izqui):
- Add a
recoverToVault()
orrecoverToFinance()
function, since it's nicer to do it this way to generate an event from the Vault rather than using the generic recoverability functionality. Debating if we should just deposit straight into the Vault that the Finance app's attached to (leaning towards it, since it's leaner as a recovery mechanism). - Decide if we should remove the deletion of terminated employees, or remove the
terminated
storage. Given the latter being leaner, and realistically there being very little chance you'd want to know if an employee was terminated on-chain rather than an employee simply existing, I'm also leaning on the latter.
⚠️ Note that the latter would mean you can do things like change someone's salary, add accrued value, or even change their termination date up to their actual termination date, rather when the call toterminate()
happened (as it is now). I find the current behaviour a bug. - Add the ability for an employee to withdraw their accrued value, without factoring in the time from their last pay date. I think this is a much more robust way to solve the denial of service issue that's somewhat mitigated by
MAX_ACCRUED_VALUE
.
I couldn't get coverage to run in a reasonable amount of time, due to how dependencies completely blow up the instrumentation, so it might be time to give up on it for the moment...
@@ -57,47 +58,42 @@ contract('Payroll, adding and removing employees,', function(accounts) { | |||
}) | |||
|
|||
it("adds employee", async () => { | |||
let name = '' | |||
let name = 'Kakaroto' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄 🐵
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I had to google it, I didn't know it has this name too, haha.
string private constant ERROR_EMPLOYEE_ALREADY_EXIST = "PAYROLL_EMPLOYEE_ALREADY_EXIST"; | ||
string private constant ERROR_NULL_ADDRESS = "PAYROLL_NULL_ADDRESS"; | ||
string private constant ERROR_NO_FORWARD = "PAYROLL_NO_FORWARD"; | ||
string private constant ERROR_RATE_EXPIRY_TIME_TOO_SHORT = "PAYROLL_RATE_EXPIRE_TIME_TOO_SHORT"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bingen can confirm, but I think we need to limit the error strings' length to be <= 32 chars to avoid eating up another 32 bytes of memory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, @izqui knows better, but that was the assumption when we added them to aragon OS.
uint256 initialDenominationSalary, | ||
string name, | ||
uint64 startDate | ||
function addEmployeeWithStartDate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just make this an overload of addEmployee()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function overload still not working with Truffle... 😞
trufflesuite/truffle#737
trufflesuite/truffle#569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yeah, we generally fix that with a mock, e.g. VotingMock
string private constant ERROR_RATE_EXPIRY_TIME_TOO_SHORT = "PAYROLL_RATE_EXPIRE_TIME_TOO_SHORT"; | ||
string private constant ERROR_EXCHANGE_RATE_ZERO = "PAYROLL_EXCHANGE_RATE_ZERO"; | ||
string private constant ERROR_PAST_TERMINATION_DATE = "PAYROLL_PAST_TERMINATION_DATE"; | ||
|
||
|
||
struct Employee { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed in #576 and in our designs we have a "role" field...
If this is going to work we'll need to add another param to addEmployee()
and capture the role
in an event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking about this, and I think we should either remove the "role" field entirely from the mock ups, or include a way to change an employee's title. Leaning towards the latter, as a function protected behind a MANAGE_EMPLOYEE_TITLE_ROLE
role, that could just emit an event with the employee's id and their new title.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd rather to do this change in #576, it will affect the app state management and we made a big change on it there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We finally made this change here, this is the most "updated" contract version, once it gets merged we can make the changes in the front end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good job indeed, @lmcorbalan !!
Replying to @sohkai:
- But this is what the old functions
escapeHatch
anddepositToFinance
were doing, isn't it? I thought you wanted to remove them. If we do a custom recovery here, I would go through Finance, as this way it gets properly registered there. - I would just remove terminated employees to avoid having to deal with re-enabling. I don't think I fully understand your Note there.
- It's quite a hard problem. I like this idea of being able to withdraw accrued value independently from Payroll. But we would still have the problem of the employer setting a value larger than existing funds. See discussion here
@@ -43,53 +61,56 @@ contract Payroll is AragonApp { //, IForwarder { // makes coverage crash (remove | |||
uint64 lastPayroll; | |||
uint64 endDate; | |||
bool terminated; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need terminated
? Isn't it enough with endDate
? See discussion here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, not really, see more discussion here
} | ||
} | ||
|
||
function _terminateEmployee(uint128 employeeId, uint64 endDate) internal { | ||
// prevent past termination dates | ||
require(endDate >= getTimestamp64()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See this comment. Pinging @izqui
I think a
Hmm, interesting note in #394 (comment). My warning was that right now, it would be impossible to change an employee's details once they've been terminated due to the Perhaps changing this modifier's behaviour may be better.
This seems like a general problem with this app and how it does accounting. Unless the employee can verify the employer's funds, they have no way to know if even Maybe instead of choosing whether |
Something like?
|
@lmcorbalan I've added a few commits that clean up some formatting and a bit of the testing. Going on the The remaining things left to think about, then, are:
And will be addressed later. |
Resolves protofire#48
This PR is meant for addressing @sohkai, @bingen and @Quazia comments on PR #479
Following there is the list of comments that we are going to address in this PR:
Payroll.sol
name
out of the struct and leave it in the eventrequire
escapeHatch
functiondepositToFinance
functionisInitialized
from functions that also check foremployeeMatches
payday
storage
empoyee ingetEmployeeByAddress
andgetEmployee
getAllocation
API, add_employeeId
paramisInitialized
from_addEmployee
_payTokens
_payTokens
)_getOwnedSalary
instead of using safe mathgetExchangeRate
docsPayrollKit.sol
vault
Unit Tests