daostack/migration

Pickup Where You Left Off: Maintain Internal Deployment State

dOrgJelli opened this issue · 7 comments

In order to facilitate these two features:

  • Pick-up deployment where you left off
  • Recover from failed transactions

The migration script could maintain an internal state (think state-machine) of the DAO's setup process. This way if something goes wrong part way through, the current state can be serialized, and picked up once the problem is fixed.

This can be used for solving:

  • dao-params.json issues that result in a crash
  • Javascript bugs
  • Failed transactions

That can be a useful feature, but I need to think on how to implement that. Maybe write to an output file after every transaction and check against that when running the script again, need to think that through...

truffle migrate supports this capability.

I did not know that, do you know how/ where they implemented it?

@ben-kaufman as each migration step completes (1_...js, 2_...js, etc) the "last_completed_migration" uint it incremented in he migration.sol contract. I don't know if using truffle migrate directly is the best approach, but the migration script could do something different with an on-chain contract. I think having everything off-chain could work too :p

https://www.trufflesuite.com/docs/truffle/getting-started/running-migrations

Yeah I'm not sure how truffle implement it, but doesn't really make sense to me to use a contract for that... I'll try to go with my approach of writing the state to some file.

@dOrgJelli I created this PR which should provide a state management to allow recovery if the script crash. The way it works is that I inserted all relevant state variables needed for a recovery into a JSON object. After each step in the deployment where this object changes I save it as a JSON file, and when the script starts it search for such a file and loads it if it exists. Please take a look at the PR and let me know your thoughts and comments on that.

Looks awesome @ben-kaufman, just left some comments.