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

PR: demo with change order sign and Unit-Test #66

Merged
merged 21 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ce9572f
ADD: first draft new approach execution On Behalf, aligned with Safe …
alfredolopez80 Jan 26, 2024
e0c46c9
Merge branch 'dev' into feature/improve-executionOnBehalf-method
alfredolopez80 Jan 26, 2024
270b05e
FIX: fix comments and order to check if SuperSafe has or hasn't Permi…
alfredolopez80 Jan 26, 2024
316d6d9
FIX: fix all Unit-Test associate to Execution on Behalf wit new approach
alfredolopez80 Jan 26, 2024
17de0a8
FIX: add Reentrancy Test for Exectution on Behalf
alfredolopez80 Jan 26, 2024
b5dbf8c
FIX: update script to deploy new version of KeyperModule, Roles and G…
alfredolopez80 Jan 29, 2024
6e5a857
DOC: add comments about how to handle nonce
alfredolopez80 Jan 31, 2024
3eff723
FIX: fix .env.example
alfredolopez80 Feb 9, 2024
a117515
Merge pull request #64 from keyper-labs/feature/improve-executionOnBe…
alfredolopez80 Feb 9, 2024
b26fd47
FIX: adjust for Run Unit-Test in Fork-Polygon
alfredolopez80 Feb 12, 2024
20a322c
FIX: fix naming and order of unit-test switch to script
alfredolopez80 Feb 13, 2024
43ff4d3
FIX: fix format
alfredolopez80 Feb 13, 2024
4633db7
FIX: fix order of signatures
alfredolopez80 Feb 14, 2024
a3b4175
FIX: eliminate useless code
alfredolopez80 Feb 14, 2024
c8f6ad6
ADD: add unit-test additional for verify how to work the executionOnB…
alfredolopez80 Feb 14, 2024
f8fa637
FIX: eliminate console import
alfredolopez80 Feb 15, 2024
591021c
ADD: fix deploy in polygon
alfredolopez80 Feb 15, 2024
e94b88f
ADD: add salt unique for each deployment in DeployKeyperEnv
alfredolopez80 Feb 15, 2024
91cd87d
Merge pull request #65 from keyper-labs/feature/improve-executionOnBe…
alfredolopez80 Mar 25, 2024
bbe53d8
FIX: update test
alfredolopez80 Mar 25, 2024
7587e96
FIX: fix comments
alfredolopez80 Mar 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ MNEMONIC=
# Used for infura based network
INFURA_KEY=
# Used for custom network
NODE_URL=
ETHERSCAN_KEY=
GOERLI_RPC_URL=
SEPOLIA_RPC_URL=
PRIVATE_KEY=

DEPLOYER_ADDRESS=
### Keyper Contracts deployed
# # Kovan deployed versions
Copy link
Contributor

Choose a reason for hiding this comment

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

kovan or sepolia?

# MASTER_COPY_ADDRESS=0xd4a1E956fFe2D07CD71c8fABf538f2BfC0e3899B
# PROXY_FACTORY_ADDRESS=0xEAb613456d3efD309101BB02872BEdCecE2879E2
# KEYPER_MODULE_ADDRESS=0xc74f6cAFb3e89006FE9c0E8Be8Dc06888e178F1b

# Polygon deployed versions
MASTER_COPY_ADDRESS=
PROXY_FACTORY_ADDRESS=

# Goerli deployed versions
# MASTER_COPY_ADDRESS=0xEeb3dD1aD28A449D838d85ddD2c8d3B2a1eAA0f8
Expand Down
318 changes: 156 additions & 162 deletions .gas-snapshot

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
run: forge test --no-match-contract 'Skip*'

- name: Run Coverage
run: forge coverage --no-match-contract 'Skip*'
run: forge test --gas-report -vvv --no-match-contract='Skip*'
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ install :; forge install
update:; forge update

# Builds
build:; forge build
build:; forge clean && forge build

build-size-report :; forge build --sizes
build-size-report :; forge clean && forge build --sizes

# chmod scripts
scripts :; chmod +x ./scripts/*
Expand All @@ -41,8 +41,17 @@ rename :; chmod +x ./scripts/* && ./scripts/rename.sh
# Generate typescript bindings
ts-binding :; npx typechain --target ethers-v5 --out-dir out/types/ './out/**/*.json'

# Deploy module in Polygon
deploy-keyper-env-polygon :; source .env && forge script script/DeployKeyperEnv.s.sol:DeployKeyperEnv --rpc-url ${POLYGON_RPC_URL} --private-key ${PRIVATE_KEY} --skip-simulation --broadcast --verify --etherscan-api-key ${POLYGONSCAN_KEY} -vvvv --with-gas-price 120000000000

# Deploy module
deploy-module :; source .env && forge script script/DeployModule.t.sol:DeployModule --rpc-url ${GOERLI_RPC_URL} --private-key ${PRIVATE_KEY} --broadcast --verify --etherscan-api-key ${ETHERSCAN_KEY} -vvvv
deploy-keyper-env :; source .env && forge script script/DeployKeyperEnv.s.sol:DeployKeyperEnv --rpc-url ${SEPOLIA_RPC_URL} --private-key ${PRIVATE_KEY} --broadcast --verify --etherscan-api-key ${ETHERSCAN_KEY} -vvvv

# Deploy module in fork-polygon
deploy-keyper-env-fork-polygon :; source .env && forge script script/DeployKeyperEnv.s.sol:DeployKeyperEnv --fork-url http://localhost:8545 --private-key ${PRIVATE_KEY}

# Deploy New Safe
deploy-new-safe :; source .env && forge script script/DeployKeyperSafe.t.sol:DeployKeyperSafe --rpc-url ${GOERLI_RPC_URL} --private-key ${PRIVATE_KEY} --broadcast -vvvv

# Run Unit-Test in Fork polygon
test-fork-polygon :; source .env && forge script script/SkipExecutionOnBehalf.s.sol:SkipSeveralScenarios --fork-url http://localhost:8545 --private-key ${PRIVATE_KEY} --broadcast -vvvv
6 changes: 4 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ src = 'src'
out = 'out'
libs = ['lib']
# Fixed Version
solc-version = "0.8.17"
solc-version = "0.8.23"
optimizer = true
optimizer-runs = 200
optimizer-runs = 150
via_ir = true
ffi=true

# Local Testnet
# libraries = ['./libraries/Constants.sol:Constants:0x2e234DAe75C793f67A35089C9d99245E1C58470b', './libraries/DataTypes.sol:DataTypes:0xF62849F9A0B5Bf2913b396098F7c7019b51A820a', './libraries/Errors.sol:Errors:0x5991A2dF15A8F6A256D3Ec51E99254Cd3fb576A9', './libraries/Events.sol:Events:0xc7183455a4C133Ae270771860664b6B7ec320bB1']
# Goerli Testnet
# libraries = ['./libraries/Constants.sol:Constants:0xc0f208cD760C472476A4Af93cf889aa79A70bb51', './libraries/DataTypes.sol:DataTypes:0xF2313a501B15Ee53a56a4A252864a7c7d53ced88', './libraries/Errors.sol:Errors:0x056a1258E952A5C9B85404C8cD77Fdea627D0362', './libraries/Events.sol:Events:0xA27939f95b4e8DC298B43ACaef4Fd4E7502FEE76']
# Polygon Mainnet
libraries = ['./libraries/Constants.sol:Constants:0x5F9Ae7E3aF99D13B14324b35E9Ed8E34B72f8973', './libraries/DataTypes.sol:DataTypes:0xC25Fd55932406626EE6133c5CD251ede6ef57df1', './libraries/Errors.sol:Errors:0xD5cc19aBa54FC64811D3050a52dbd274e998b916', './libraries/Events.sol:Events:0xBE874E3f8c49C8976Cf8B80f92B7f6Cc844dE032']

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
# Gas Report
Expand Down
6 changes: 3 additions & 3 deletions libraries/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ library Constants {
0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;

// keccak256(
// "KeyperTx(address org,address safe,address to,uint256 value,bytes data,uint8 operation,uint256 nonce)"
// "KeyperTx(address org,address superSafe,address targetSafe,address to,uint256 value,bytes data,uint8 operation,uint256 _nonce)"
// );
bytes32 internal constant KEYPER_TX_TYPEHASH =
0xbb667b7bf67815e546e48fb8d0e6af5c31fe53b9967ed45225c9d55be21652da;
0x5576bff5f05f6e5452f02e4fe418b1519cb08f54fae3564c3a4d2a4706584d4e;

address internal constant FALLBACK_HANDLER =
0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4;
Expand Down Expand Up @@ -68,7 +68,7 @@ library Constants {
bytes4(
keccak256(
bytes(
"execTransactionOnBehalf(bytes32,address,address,uint256,bytes,uint8,bytes)"
"execTransactionOnBehalf(bytes32,address,address,address,uint256,bytes,uint8,bytes)"
)
)
);
Expand Down
1 change: 1 addition & 0 deletions libraries/Events.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ library Events {
event TxOnBehalfExecuted(
bytes32 indexed org,
address indexed executor,
address superSafe,
address indexed target,
bool result
);
Expand Down
2 changes: 1 addition & 1 deletion libraries/Random.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ library Random {
keccak256(
abi.encodePacked(
block.timestamp +
block.difficulty +
block.prevrandao +
((
uint256(keccak256(abi.encodePacked(block.coinbase)))
) / (_seed)) +
Expand Down
11 changes: 7 additions & 4 deletions script/DeployKeyperEnv.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.15;

import "forge-std/Script.sol";
import "@solenv/Solenv.sol";
import "../src/KeyperRoles.sol";
import "../src/KeyperModule.sol";
import {KeyperGuard} from "../src/KeyperGuard.sol";
Expand All @@ -15,19 +16,21 @@ contract DeployKeyperEnv is Script {
function run() public {
vm.startBroadcast();
// Using CREATE3Factory to be able to predic deployment address for KeyperModule
// More info https://github.com/ZeframLou/create3-factory
// The address https://goerli.etherscan.io/address/0x9fBB3DF7C40Da2e5A0dE984fFE2CCB7C47cd0ABf#code, is the address of the CREATE3Factory in Goerli
// More info https://github.com/lifinance/create3-factory
// The address https://sepolia.etherscan.io/address/0x93FEC2C00BfE902F733B57c5a6CeeD7CD1384AE1#code, is the address of the CREATE3Factory in Sepolia
CREATE3Factory factory =
CREATE3Factory(0x9fBB3DF7C40Da2e5A0dE984fFE2CCB7C47cd0ABf);
bytes32 salt = keccak256(abi.encode(0xdfff));
CREATE3Factory(0x93FEC2C00BfE902F733B57c5a6CeeD7CD1384AE1);
bytes32 salt = keccak256(abi.encode(0xddff)); // need to be unique to avoid collision
address keyperModulePredicted = factory.getDeployed(msg.sender, salt);

// Deploy Safe contracts in goerli
Solenv.config();
address masterCopy = vm.envAddress("MASTER_COPY_ADDRESS");
address proxyFactory = vm.envAddress("PROXY_FACTORY_ADDRESS");
uint256 maxTreeDepth = 50;

// Deploy KeyperRoles: KeyperModule is set as owner of KeyperRoles authority
console.log("KeyperModulePredicted: ", keyperModulePredicted);
KeyperRoles keyperRoles = new KeyperRoles(keyperModulePredicted);
console.log("KeyperRoles deployed at: ", address(keyperRoles));

Expand Down
2 changes: 1 addition & 1 deletion script/DeployKeyperSafe.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract DeployKeyperSafe is Script {

vm.startBroadcast();
KeyperModule keyper = KeyperModule(keyperModuleAddress);
keyper.createSafeProxy(owners, threshold);
// keyper.createSafeProxy(owners, threshold);
vm.stopBroadcast();
}
}
Loading
Loading