-
Notifications
You must be signed in to change notification settings - Fork 646
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
Escrow support. #866
Escrow support. #866
Conversation
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.
Good job.
Firstly, I think it's not the correct time to discuss or work on this in detail now, better do it after we tagged a hard fork release for testnet.
Things to be done that I've thought of:
- automatically release funds and / or do other actions after reached every expiration time involved
- Initial fee need to be peg to one of the existing operations on chain
- hardfork guard for new operations nested inside a proposal
- new / update database APIs for query
- CLI commands / APIs
esc.to = o.to; | ||
esc.agent = o.agent; | ||
esc.amount = o.amount; | ||
esc.pending_fee = o.agent_fee; |
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.
If put a pending fee here, I think we can't add it to agent's balance above.
libraries/chain/db_balance.cpp
Outdated
@@ -186,4 +187,13 @@ void database::deposit_witness_pay(const witness_object& wit, share_type amount) | |||
return; | |||
} | |||
|
|||
// adding the escrow call here to dont create a new file | |||
// change this to where it correspond | |||
const escrow_object& database::get_escrow( account_id_type account, uint32_t escrow_id )const { |
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.
Perhaps better move it to db_getter.cpp.
libraries/chain/escrow_evaluator.cpp
Outdated
|
||
FC_ASSERT( o.ratification_deadline > db().head_block_time() ); | ||
FC_ASSERT( o.escrow_expiration > db().head_block_time() ); | ||
FC_ASSERT( db().get_balance( o.from, o.amount.asset_id ) >= (o.amount + o.fee + o.agent_fee) ); |
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 if amount, fee and agent_fee have different asset_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.
those checks are done in validate()
at escrow.cpp
however the fee==bts was not enforced. added here cb779d1 this is temporal until we can make the escrow works with other asset than bts, then some of this rules will need to change.
@@ -327,6 +327,9 @@ namespace graphene { namespace chain { | |||
// helper to handle witness pay | |||
void deposit_witness_pay(const witness_object& wit, share_type amount); | |||
|
|||
// escrow call here | |||
const escrow_object& get_escrow( account_id_type account, uint32_t escrow_id )const; | |||
|
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.
Move this as well.
typedef escrow_transfer_operation operation_type; | ||
|
||
void_result do_evaluate( const escrow_transfer_operation& o ); | ||
void_result do_apply( const escrow_transfer_operation& o ); |
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.
Don't use void_result here when creating a new object.
libraries/chain/protocol/escrow.cpp
Outdated
FC_ASSERT( from != to ); | ||
FC_ASSERT( from != agent && to != agent ); | ||
FC_ASSERT( agent_fee.asset_id == amount.asset_id ); // agent fee only in bts | ||
FC_ASSERT( amount.asset_id == asset_id_type()); // only bts is allowed by now |
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.
IMHO don't enforce this. This feature is more useful for bitUSD etc.
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.
this is temporally disabled as current code don't work with other coin than core, check Limitation section of first message. I can remove, add the test case for escrow MPA and you can see the error i am referring to more in detail.
Will be great if you can take a look to that with me as i got stuck there and one of the features that will make the difference is definitely allow all assets to be in escrow.
@oxarbitrage sorry, I didn't realize that impl object type is used here, which made the situation a bit hard to judge. There are some differences about design philosophy between Steem and BitShares. BitShares uses object IDs in API (e.g.
Steem avoided object IDs in API and protocol. All objects have additional IDs whose values are decided by users who sign transactions, and internal IDs is hidden from API, so not visible to client software.
I'm not going to judge which one is better at this moment. Anyway, when designing, need to think about compatibility as well as ease of use. Need more discussion. |
i can change this to outside the impl. was not sure what to do at the beginning and followed the steem path but this can be changed if needed. |
@oxarbitrage best if we have more discussions on why and how. |
I like this!
I think this should be considered the right way of doing it. What is important to consider is if an escrow should expire if it is in dispute and if setting an escrow into dispute may require a higher fee to prevent abuse. |
|
|
Lacking specification / BSIP, no progress. Closing. |
This PR introduces one object and four new operations(with corresponding validations and evaluators) to equip the bitshares-core with support for native escrow smart contracts.
The code included is an adapted version of the escrow system implemented for steem(steemit/steem#143).
It will put bitshares in the same level of steem in regards to escrow support, nothing more, nothing less however; bitshares can and should do a better job. The code presented here attempts to boost development of escrow features in graphene blockchains in general and bitshares in particular.
The code is complainant with escrow bsip 40(bitshares/bsips#76).
This is not final code and of course require hardfork. I will leave the community to decide if we will have time for reviewing and improving this for the next consensus release or if it should be included in a future one. BSIP40 needs to be voted in in order for this to be included, the code is the result of a research in bitshares new operations i made to present in the Shanghai Graphene conference that i decided to submit now.
I understand our top devs are very busy and this may not be the best time, i also understand BSIP should came first, my apologies for not taking the most formal path but i don't want this work to just die.
Limitations:
Improvements:
Discussion:
commits in this pull should be squashed as they are messy.