Giter Club home page Giter Club logo

trust-deal's Introduction

trust-deal

To be done:

  1. Optimizations and security changes in accordance to what was stated in tech docs

Test

Run local tests with:

ganache-cli -p 7545 -i 5777 
npx truffle migrate --reset --network development
npx truffle test --network development

# with events
npx truffle test --show-events --network development

Make sure you have npx package.

trust-deal's People

Contributors

eenae avatar techraed avatar

Watchers

 avatar  avatar  avatar

trust-deal's Issues

More event based deal

I suggest deelply using event based development.
One great feature is that although we do not save some data into contract storage, we still retrieve data from blockchain (from contract state) using events. Consequently, we do not "save" anything on front-end.

More specifically:

  • minutes delivered and logTimestamp (ITERATION state) could be emitted (ApplicationAdded event) and retrieved from the contract events. This data is view only for front-end, so we can remove it from contract storage.
  • getState, getReviewer, getClient, getContractor and other view functions could be replaced with event handling. For example: for each contract we have a number of events that signals current contract state. So on front-end this task ends-up in getting last state signaling event. Just for now we have DealInitialized, ReviewerProposed, ReviewerAcceptedConditions and ReviewerDeclinedConditions, ContractorChosen, LoggedWork, IterationFinished, DealTaskReviewedPositively, DealEndedUp(currentState). So, we can use them as state flags. These events also contain information, related to deal current state: client/contractor/reviewer addresses, minutes logged, iteration stats and e.t.c.

re-INIT and toEnd from INIT state

I suggest adding deal options (task description, short name, iteration duration in seconds, mean of payment) update behaviour. Also finishing deal from INIT state will be more suitable for UX.

Case: contractor/reviewer/client are contracts

It seems that there are some issues, when contractor/client/reviewer are contracts. It is ok if they have fallback functions, because transfer method is considered safe: it reverts if exception is met, it gives very few gas, so re-entrant call can't be performed.But we can really face problems if deals currency is ether and one of those actors is a contract without fallback function - deadlock.

Possible improvements:

  • checking if address is a contract;
  • change logic of reward transfer to "pull" over "push".

reviewer and iteration start timestamps can be omitted

One of our projects (pchela-computing) had similar to trust-deal (on ITERATION and REVIEW states) timeout constraints. Logic there was implemented with _stageTransitionDeadlineVar which was rewritten to now every time state was moved forward.

For example, when we move to ITERATION state, we write to storage iterationStart = now. Every time work is logged, we check, that iterationStart.add(iterationDuration) > now. Same logic with REVIEW state. So, I suggest using one _stageTransitionDeadlineVar, which is assigned to now every time state goes forward (in newIteration and finishIteration funcs)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.