Skip to content
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

Agent app: EVM #580

Merged
merged 45 commits into from
Feb 15, 2019
Merged

Agent app: EVM #580

merged 45 commits into from
Feb 15, 2019

Conversation

izqui
Copy link
Contributor

@izqui izqui commented Nov 16, 2018

Spec and design discussion: https://forum.aragon.org/t/actor-app-arbitrary-actions-from-daos/275

  • 1. Vault inheritance
  • 2. Arbitrary call execution
  • 3. Forwarding interface
  • 4. Signature handling

TODO:

  • Roles in arapp

Closes #45.

future-apps/actor/arapp.json Outdated Show resolved Hide resolved
future-apps/actor/contracts/Actor.sol Outdated Show resolved Hide resolved
future-apps/actor/contracts/Actor.sol Outdated Show resolved Hide resolved
@@ -0,0 +1,238 @@
// Test that Actor is a fully functioning Vault by running the same tests against the Actor app
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy pasting this code from the Vault tests feels dirty. @sohkai suggestions on how to do this in a clean way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this is quite a special case, but we could change the Vault tests to take in a contract artifact as an argument and export it as part of the package.

}

function forward(bytes _evmScript)
authP(RUN_SCRIPT_ROLE, arr(getScriptACLParam(_evmScript)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having an explicit role for this function rather than require(canForward()) to make the role more explicit (and help our role extraction helpers!)

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.124% when pulling 9830981 on actor-app into f6df8d0 on master.

@coveralls
Copy link

coveralls commented Nov 16, 2018

Coverage Status

Coverage remained the same at 96.484% when pulling 2a293d1 on actor-app into 7fb014b on next.

@sohkai sohkai requested review from sohkai and bingen and removed request for sohkai November 19, 2018 16:31
@izqui izqui added app: agent and removed new-app labels Nov 23, 2018
Copy link
Contributor

@bingen bingen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a first glance and it looks good to me. I will try to do another one more thorough though.

bytes4 public constant ISVALIDSIG_INTERFACE_ID = 0xabababab; // TODO: Add actual interfaceId

string private constant ERROR_EXECUTE_ETH_NO_DATA = "VAULT_EXECUTE_ETH_NO_DATA";
string private constant ERROR_EXECUTE_TARGET_NOT_CONTRACT = "VAULT_EXECUTE_TARGET_NOT_CONTRACT";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 33 chars long, I seem to recall we were using up to 32 to avoid using extra storage.

authP(EXECUTE_ROLE, arr(_target, _ethValue, uint256(getSig(_data)))) // TODO: Test that sig bytes are the least significant bytes
{
require(_ethValue == 0 || _data.length > 0, ERROR_EXECUTE_ETH_NO_DATA); // if ETH value is sent, there must be data
require(isContract(_target), ERROR_EXECUTE_TARGET_NOT_CONTRACT);
Copy link

@jvluso jvluso Jan 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we don't want the actor app to be able to send eth to someone without calling a function? Anyone able to call the execute function will be able to send funds anyway, and this makes compatibility with external dapps slightly more difficult.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to Actor inheriting from Vault, that can be done using the transfer function. I just tried to separate role concerns here.

@izqui izqui requested a review from sohkai January 11, 2019 09:35
@izqui
Copy link
Contributor Author

izqui commented Jan 11, 2019

@sohkai do you think you can take a look this next or the next one? It is important for a concierge project

@sohkai sohkai modified the milestone: A1 Sprint: 3.2 Jan 11, 2019
/// @return Returns whether signature is from a specified user.
function isValidSignature(bytes32 hash, address signer, bytes signature) internal pure returns (bool) {
function isValidSignature(bytes32 hash, address signer, bytes signature) internal view returns (bool) {
if (signature.length == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be <= 1 since mode is always required

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Length being 1 is valid for ERC1271 mode signatures. We could perform the check before sending it over to the erc1271 contract, but that contract may have logic which allows empty signatures

@@ -5,7 +5,7 @@ pragma solidity 0.4.24;
// Rationale: https://github.com/ethereum/EIPs/issues/1271#issuecomment-462719728

contract ERC1271 {
bytes4 constant public ERC1271_INTERFACE_ID = this.isValidSignature.selector;
bytes4 constant public ERC1271_INTERFACE_ID = 0xfb855dc9; // this.isValidSignature.selector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this was giving a warning; I guess solidity doesn't know this is known at compile-time

@sohkai sohkai force-pushed the actor-app branch 4 times, most recently from 91ca782 to 3959ac0 Compare February 13, 2019 20:51
@izqui
Copy link
Contributor Author

izqui commented Feb 15, 2019

Branch ready. @sohkai PTAL and let's get this 🚢🚢🚢

Copy link
Contributor

@sohkai sohkai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌮 🎉

@@ -134,4 +131,24 @@ library SignatureValidator {

return ret;
}

// From: https://github.com/Arachnid/solidity-stringutils/blob/master/src/strings.sol
function memcpy(uint dest, uint src, uint len) private pure {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use uint256 consistently 👍

assembly {
let srcpart := and(mload(src), not(mask))
let destpart := and(mload(dest), mask)
mstore(dest, or(destpart, srcpart))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this could be optimized since we don't need to make sure the remaining bytes in dest are kept, but let's keep it the same as the library 👍.

Copy link
Contributor Author

@izqui izqui Feb 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation, but I would rather not modify the code

function popFirstByte(bytes memory input) internal pure returns (bytes memory output, byte firstByte) {
function popFirstByte(bytes memory input) private pure returns (bytes memory output) {
uint256 inputLength = input.length;
require(inputLength > 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding an error reason here?

@izqui izqui merged commit a2a7ac5 into next Feb 15, 2019
@sohkai sohkai deleted the actor-app branch September 10, 2019 18:13
ramilexe pushed a commit to ConsiderItDone/aragon-apps that referenced this pull request Dec 9, 2021
* Actor app: inherit Vault and test vault functionality

* Actor app: implement execute action

* Actor app: implement permissioned forwarding

* Actor app: improve tests

* Actor app: signatures

* CI: travis wait on npm install

* Actor app: lint and enable CI

* Add max gas for static calls

* chore: upgrade to web3-eth-abi@1.0.0-beta.38

* Address review comments

* Lint

* test: add comments, cosmetic changes, and more tests

* SignatureValidator: fix compile warnings

* test: add context headers

* Metadata: add roles to arapp, remove webapp artifacts

* Radspec strings

* Travis: allow actor coverage to fail, tracking fix in aragon#658

* Prevent infinite loop by prohibiting setting itself as the designated signer

* Radspec

* Actor -> Agent rename

* Add status to arapp and rename constants

* Update ERC1271 implementation

* Add ERC1271 interfaceId

* Rename constants

* Rename calldata

* Refactor SignatureValidator.sol

* Refactor signature validation tests and test EIP712 signatures

* Handle empty signatures and undefined signature modes

* Refactor SignatureValidator: handle ERC1271 checks in library

* Test ERC1271 signature wrapping

* cosmetic: fix whitespace

* Agent: always allow execute to transfer ETH (aragon#651)

* cosmetic: fix whitespace and add EIPs hash

* chore: upgrade aragonOS and use test-helper's contracts

* cosmetic: fix compile errors

* cosmetic: fix linter

* chore: fix travis allowed to fail matrix

* test: ignore all test contracts from coverage

* Actor: reuse Vault tests (aragon#668)

The Vault now exports its tests via a sharable utility.

See f41519a for the changes made to the original tests to make them sharable.

* Move agent from future-apps/ to apps/

* Refactor popFirstByte to copy to a new array

* Address last review comments

* Lint

* Address very last review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants