-
Notifications
You must be signed in to change notification settings - Fork 212
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
Agent app: EVM #580
Conversation
future-apps/actor/test/vault.js
Outdated
@@ -0,0 +1,238 @@ | |||
// Test that Actor is a fully functioning Vault by running the same tests against the Actor app |
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.
Copy pasting this code from the Vault tests feels dirty. @sohkai suggestions on how to do this in a clean way?
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.
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))) |
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.
Having an explicit role for this function rather than require(canForward())
to make the role more explicit (and help our role extraction helpers!)
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.
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"; |
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 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); |
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.
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.
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.
Thanks to Actor inheriting from Vault, that can be done using the transfer
function. I just tried to separate role concerns here.
@sohkai do you think you can take a look this next or the next one? It is important for a concierge project |
/// @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) { |
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 should be <= 1
since mode is always required
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.
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 |
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.
Note that this was giving a warning; I guess solidity doesn't know this is known at compile-time
91ca782
to
3959ac0
Compare
The Vault now exports its tests via a sharable utility. See f41519a for the changes made to the original tests to make them sharable.
Branch ready. @sohkai PTAL and let's get this 🚢🚢🚢 |
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.
🌮 🎉
@@ -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 { |
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.
Let's use uint256
consistently 👍
assembly { | ||
let srcpart := and(mload(src), not(mask)) | ||
let destpart := and(mload(dest), mask) | ||
mstore(dest, or(destpart, srcpart)) |
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.
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 👍.
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 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); |
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 do you think about adding an error reason here?
* 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 [email protected] * 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
Spec and design discussion: https://forum.aragon.org/t/actor-app-arbitrary-actions-from-daos/275
TODO:
Closes #45.