GithubHelp home page GithubHelp logo

dapphub / ds-pause Goto Github PK

View Code? Open in Web Editor NEW
26.0 13.0 27.0 178 KB

Schedule function calls that can only be executed once some delay has elapsed

License: GNU Affero General Public License v3.0

Makefile 0.39% Solidity 99.61%

ds-pause's Introduction

ds-pause

delegatecall based proxy with an enforced delay

ds-pause allows authorized users to schedule function calls that can only be executed once some predetermined waiting period has elapsed. The configurable delay attribute sets the minimum wait time.

ds-pause is designed to be used as a component in a governance system, to give affected parties time to respond to decisions. If those affected by governance decisions have e.g. exit or veto rights, then the pause can serve as an effective check on governance power.

Plans

A plan describes a single delegatecall operation and a unix timestamp eta before which it cannot be executed.

A plan consists of:

  • usr: address to delegatecall into
  • tag: the expected codehash of usr
  • fax: calldata to use
  • eta: first possible time of execution (as seconds since unix epoch)

Each plan has a unique id, defined as keccack256(abi.encode(usr, tag, fax, eta))

Operations

Plans can be manipulated in the following ways:

  • plot: schedule a plan
  • exec: execute a plan
  • drop: cancel a plan

Invariants

A break of any of the following would be classified as a critical issue. Please submit bug reports to [email protected].

high level

  • There is no way to bypass the delay
  • The code executed by the delegatecall cannot directly modify storage on the pause
  • The pause will always retain ownership of it's proxy

admin

  • authority, owner, and delay can only be changed if an authorized user plots a plan to do so

plot

  • A plan can only be plotted if its eta is after block.timestamp + delay
  • A plan can only be plotted by authorized users

exec

  • A plan can only be executed if it has previously been plotted
  • A plan can only be executed once it's eta has passed
  • A plan can only be executed if its tag matches extcodehash(usr)
  • A plan can only be executed once
  • A plan can be executed by anyone

drop

  • A plan can only be dropped by authorized users

Identity & Trust

In order to protect the internal storage of the pause from malicious writes during plan execution, we perform the actual delegatecall operation in a seperate contract with an isolated storage context (DSPauseProxy). Each pause has it's own individual proxy.

This means that plan's are executed with the identity of the proxy, and when integrating the pause into some auth scheme, you probably want to trust the pause's proxy and not the pause itself.

Example Usage

// construct the pause

uint delay            = 2 days;
address owner         = address(0);
DSAuthority authority = new DSAuthority();

DSPause pause = new DSPause(delay, owner, authority);

// plot the plan

address      usr = address(0x0);
bytes32      tag;  assembly { tag := extcodehash(usr) }
bytes memory fax = abi.encodeWithSignature("sig()");
uint         eta = now + delay;

pause.plot(usr, tag, fax, eta);
// wait until block.timestamp is at least now + delay...
// and then execute the plan

bytes memory out = pause.exec(usr, tag, fax, eta);

Tests

ds-pause's People

Contributors

d-xo avatar gbalabasquer avatar mrchico avatar xwvvvvwx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ds-pause's Issues

Changing delay

Changing the value of delay is not currently supported.

i assume this is a design decision based on the fact that it would be difficult to deal with the already scheduled proposals. If that's the case, maybe it's worth mentioning this in the README.

Have you considered allowing changes that strictly increase the delay? One benefit could be that, in cases when governance decides that all proposals in a ds-pause should be evaluated for longer, changing delay has less overhead than canceling each proposal and voting it back in on a different ds-pause.

execute should not be payable

I don't think the payable modifier should be in a function that can be called by anyone.
It's like leaving that door open to the public to add a custom value to the proposal elected. I know in most of cases will be just a waste of ETH value, but there might be actions tight to what is received in msg.value.
I think there shouldn't be a value at all or the value should be defined and saved at the moment the execution is scheduled by the owner. So basically the msg.value is part of the execution scheduled.

Code reuse

Any particular reason this code is copy/pasted instead of inheriting from DSProxy? We are going to give DSProxy some love soon and I see potential trouble if we make separate changes

// delegatecall implementation from ds-proxy

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.