-
Notifications
You must be signed in to change notification settings - Fork 44
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
MultiPartyEscrow contract #39
MultiPartyEscrow contract #39
Conversation
contracts/MultiPartyEscrow.sol
Outdated
require(amount <= channel.value); | ||
require(msg.sender == channel.recipient); | ||
|
||
//"this" will be added later |
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.
Could you please explain this comment further.
migrations/3_MultiPartyEscrow.js
Outdated
@@ -0,0 +1,12 @@ | |||
let test1 = artifacts.require("./MultiPartyEscrow.sol"); |
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 would propose renaming it to something verbose.
I will merge it tomorrow, if nobody is against it. |
Looks good for me. |
|
||
contract MultiPartyEscrow { | ||
|
||
//it seems we don't need SafeMath |
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, we need. When using the SafeMath library, an error will be thrown stopping the execution of the contract and it conforms to the existent codebase.
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.
Using SafeMath for MultiPartyEscrow is a big question. I will open an Issue and explain why. And I don't understand your last part. If there is an error in the contract it must revert, there is not other possible behavior.... Ok we continue in an issue
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.
What do you mean "codebase"? If it is signet/platform-contract then I am the first who consider using it (please make "grep SafeMath contracts/*"). And please use issue #45 for this discussion...
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.
And Marco have you read what I've wrote in #45 ? That we are already checking for it, But still I'm hesitating to use SafeMax ? What's the point to write it here?
contracts/MultiPartyEscrow.sol
Outdated
struct PaymentChannel { | ||
address sender; // The account sending payments. | ||
address recipient; // The account receiving the payments. | ||
uint256 replica_id; // id of particular service replica |
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.
Code Style: I think we should adhere to the existent codebase (camelCase) and in general keep code style changes as separated PRs if needed.
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 should define the style... (I will follow it, even though I don't like camelCase :) ). I will open an Issue.
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.
Yeah, I mean it's not about personal preference. If we decide to refactor the style, let's do it in a separate merge request.
As a "golden" rule, we should follow closely the master practices/styles which already exists, to make it consistent.
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.
Nope, I mean the code already merged in master is the style to follow. Always.
It's better to change the majority of old code to adapt to this PR or make sure this looks consistent with the already merged code? ;)
If @pennachin wants to change the code style and he allows to spend time on that ok to me to work on #43, otherwise let's fix only this PR to match the codebase and move on.
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.
Please define codestyle in #43 . I cannot fix codestyle without definition of codestyle... What exactly? Only names of public function or what? All those discussions are starting really pulling me backward..
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.
Wait, there are two separate tasks here:
- Merge this pull request
- Define code-style
The 1 cannot go through here, because we want a consistent code style. This PR has a different style introduced in naming variables/functions like this (name_of_var) instead of the existent nameOfVar camelCase style.
The 2 came out since (maybe) we want to change and write in stone the rules (in order to setup a solidity linter/formatter in CI I presume)
The 1 and 2 can go in parallel, for the 1 the most obvious and quicker solution to me would adhere to the existent codebase, and not the other way. Moreover, I do think it's better to isolate code style changes in a specific PR.
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.
@tiero , am I right that converting functions and variables names to camelCase will be enough for this PR?
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.
Exactly.
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.
And camelCase is the "official" style advocated by the Solidity docs.
contracts/MultiPartyEscrow.sol
Outdated
} | ||
|
||
|
||
function isValidSignature_open_channel_replaysafe(address recipient, uint256 value, uint256 expiration, uint256 replica_id, uint256 message_nonce, bytes memory signature, address sender) |
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 would decouple the logic of isValidSiganture and move the business logic where is used instead of having a specific function. They are both used once in the whole code, useless as specific helpers
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.
agree! And it make contract a little bit cheaper :) (35884 vs 36027 ) ... Will commit this evening. In airport now.
contracts/MultiPartyEscrow.sol
Outdated
{ | ||
require(msg.sender == channels[channel_id].sender); | ||
require(now >= channels[channel_id].expiration); | ||
_channel_sendback_and_reopen(channel_id); |
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.
It seems strange that we claim the timeout, mostly because the service provider is not reachable or trying to cheat, and we want to open back a channel. Should not be only closed?
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.
One of the main ideas of such design is that we can have single channel for each client/service provider pair and we don't have to close it. When one of the parties gets money then channel none is incremented and channel can be used again. @astroseger please correct me if I am wrong.
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.
Makes sense, but you agree that in this situation, most of the time the sender will not do business again with this recipient. Ok for me to leave the feature but at least we should emit an event at least. It's very important to keep track of this case, for reputation especially cc/ @pennachin (metaphorically, you are opting out your stake from the service provider)
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.
Marco! It is the name of function which is confusing you. I will rename it to _channel_sendback_and_suspend . Because it reopen the channel but change value and expiration to zero. So in order to start to use it the client should put money in it.
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.
but it is actually reopen ... so I will call the function _channel_sendback_and_reopen_suspended
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.
Ok then.
I've opened several issues and I've made several changes... It seems all questions have been answered. |
Ok guys... I will do the following steps
|
MultiPartEscrow contract. Unit tests for MultiPartEscrow contract. js interface for this contract for sender and recipient (in test/sign_mpe_funs.js).