Skip to content

Commit

Permalink
Merge pull request #41 from FastLane-Labs/size-cuts
Browse files Browse the repository at this point in the history
Reduce contracts to deployable size
  • Loading branch information
BenSparksCode authored Nov 17, 2023
2 parents 91f2627 + 1ee2cee commit 4cc3138
Show file tree
Hide file tree
Showing 31 changed files with 2,091 additions and 1,551 deletions.
3 changes: 2 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[profile.default]
bytecode_hash = "none"
optimizer_runs = 200
optimizer_runs = 20
timeout = 30000
block_gas_limit = 300000000
gas_limit = 3000000000
gas_price = 1500000000

solc_version = "0.8.18"
evm_version = 'paris'

fs_permissions = [{ access = "read-write", path = "./"}]
159 changes: 150 additions & 9 deletions script/deploy-atlas.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,77 @@ import "forge-std/Test.sol";
import {DeployBaseScript} from "script/base/deploy-base.s.sol";

import {Atlas} from "src/contracts/atlas/Atlas.sol";
import {AtlasFactory} from "src/contracts/atlas/AtlasFactory.sol";
import {AtlasVerification} from "src/contracts/atlas/AtlasVerification.sol";
import {GasAccountingLib} from "src/contracts/atlas/GasAccountingLib.sol";
import {SafetyLocksLib} from "src/contracts/atlas/SafetyLocksLib.sol";
import {SwapIntentController} from "src/contracts/examples/intents-example/SwapIntent.sol";
import {TxBuilder} from "src/contracts/helpers/TxBuilder.sol";
import {Simulator} from "src/contracts/helpers/Simulator.sol";

contract DeployAtlasScript is DeployBaseScript {
// TODO move commons vars like these to base deploy script
Atlas public atlas;
AtlasFactory public atlasFactory;
AtlasVerification public atlasVerification;
GasAccountingLib public gasAccountingLib;
SafetyLocksLib public safetyLocksLib;
Simulator public simulator;

function run() external {
console.log("\n=== DEPLOYING Atlas ===\n");

uint256 deployerPrivateKey = vm.envUint("GOV_PRIVATE_KEY");
address deployer = vm.addr(deployerPrivateKey);
// Computes the addresses at which AtlasFactory and AtlasVerification will be deployed
address expectedAtlasFactoryAddr = computeCreateAddress(
deployer,
vm.getNonce(deployer) + 1
);
address expectedAtlasVerificationAddr = computeCreateAddress(
deployer,
vm.getNonce(deployer) + 2
);
address expectedGasAccountingLibAddr = computeCreateAddress(
deployer,
vm.getNonce(deployer) + 3
);
address expectedSafetyLocksLibAddr = computeCreateAddress(
deployer,
vm.getNonce(deployer) + 4
);

console.log("Deployer address: \t\t\t\t", deployer);

vm.startBroadcast(deployerPrivateKey);

simulator = new Simulator();
atlas = new Atlas(64, address(simulator));
atlas = new Atlas({
_escrowDuration: 64,
_factory: expectedAtlasFactoryAddr,
_verification: expectedAtlasVerificationAddr,
_gasAccLib: expectedGasAccountingLibAddr,
_safetyLocksLib: expectedSafetyLocksLibAddr,
_simulator: address(simulator)
});
atlasFactory = new AtlasFactory(address(atlas));
atlasVerification = new AtlasVerification(address(atlas));
gasAccountingLib = new GasAccountingLib({
_escrowDuration: 64,
_factory: expectedAtlasFactoryAddr,
_verification: expectedAtlasVerificationAddr,
_safetyLocksLib: expectedSafetyLocksLibAddr,
_simulator: address(simulator),
_atlas: address(atlas)
});
safetyLocksLib = new SafetyLocksLib({
_escrowDuration: 64,
_factory: expectedAtlasFactoryAddr,
_verification: expectedAtlasVerificationAddr,
_gasAccLib: expectedGasAccountingLibAddr,
_simulator: address(simulator),
_atlas: address(atlas)
});

vm.stopBroadcast();

Expand All @@ -41,6 +92,10 @@ contract DeployAtlasScript is DeployBaseScript {

contract DeployAtlasAndSwapIntentDAppControlScript is DeployBaseScript {
Atlas public atlas;
AtlasFactory public atlasFactory;
AtlasVerification public atlasVerification;
GasAccountingLib public gasAccountingLib;
SafetyLocksLib public safetyLocksLib;
Simulator public simulator;
SwapIntentController public swapIntentControl;

Expand All @@ -49,21 +104,62 @@ contract DeployAtlasAndSwapIntentDAppControlScript is DeployBaseScript {

uint256 deployerPrivateKey = vm.envUint("GOV_PRIVATE_KEY");
address deployer = vm.addr(deployerPrivateKey);
// Computes the addresses at which AtlasFactory and AtlasVerification will be deployed
address expectedAtlasFactoryAddr = computeCreateAddress(
deployer,
vm.getNonce(deployer) + 1
);
address expectedAtlasVerificationAddr = computeCreateAddress(
deployer,
vm.getNonce(deployer) + 2
);
address expectedGasAccountingLibAddr = computeCreateAddress(
deployer,
vm.getNonce(deployer) + 3
);
address expectedSafetyLocksLibAddr = computeCreateAddress(
deployer,
vm.getNonce(deployer) + 4
);

console.log("Deployer address: \t\t\t\t", deployer);

vm.startBroadcast(deployerPrivateKey);

// Deploy the Atlas contract
simulator = new Simulator();
atlas = new Atlas(64, address(simulator));
atlas = new Atlas({
_escrowDuration: 64,
_factory: expectedAtlasFactoryAddr,
_verification: expectedAtlasVerificationAddr,
_gasAccLib: expectedGasAccountingLibAddr,
_safetyLocksLib: expectedSafetyLocksLibAddr,
_simulator: address(simulator)
});
atlasFactory = new AtlasFactory(address(atlas));
atlasVerification = new AtlasVerification(address(atlas));
gasAccountingLib = new GasAccountingLib({
_escrowDuration: 64,
_factory: expectedAtlasFactoryAddr,
_verification: expectedAtlasVerificationAddr,
_safetyLocksLib: expectedSafetyLocksLibAddr,
_simulator: address(simulator),
_atlas: address(atlas)
});
safetyLocksLib = new SafetyLocksLib({
_escrowDuration: 64,
_factory: expectedAtlasFactoryAddr,
_verification: expectedAtlasVerificationAddr,
_gasAccLib: expectedGasAccountingLibAddr,
_simulator: address(simulator),
_atlas: address(atlas)
});

// Deploy the SwapIntent DAppControl contract
swapIntentControl = new SwapIntentController(address(atlas));

// Integrate SwapIntent with Atlas
atlas.initializeGovernance(address(swapIntentControl));
atlas.integrateDApp(address(swapIntentControl));
atlasVerification.initializeGovernance(address(swapIntentControl));
atlasVerification.integrateDApp(address(swapIntentControl));

vm.stopBroadcast();

Expand All @@ -80,6 +176,10 @@ contract DeployAtlasAndSwapIntentDAppControlScript is DeployBaseScript {

contract DeployAtlasAndSwapIntentDAppControlAndTxBuilderScript is DeployBaseScript {
Atlas public atlas;
AtlasFactory public atlasFactory;
AtlasVerification public atlasVerification;
GasAccountingLib public gasAccountingLib;
SafetyLocksLib public safetyLocksLib;
Simulator public simulator;
SwapIntentController public swapIntentControl;
TxBuilder public txBuilder;
Expand All @@ -89,21 +189,62 @@ contract DeployAtlasAndSwapIntentDAppControlAndTxBuilderScript is DeployBaseScri

uint256 deployerPrivateKey = vm.envUint("GOV_PRIVATE_KEY");
address deployer = vm.addr(deployerPrivateKey);
// Computes the addresses at which AtlasFactory and AtlasVerification will be deployed
address expectedAtlasFactoryAddr = computeCreateAddress(
deployer,
vm.getNonce(deployer) + 1
);
address expectedAtlasVerificationAddr = computeCreateAddress(
deployer,
vm.getNonce(deployer) + 2
);
address expectedGasAccountingLibAddr = computeCreateAddress(
deployer,
vm.getNonce(deployer) + 3
);
address expectedSafetyLocksLibAddr = computeCreateAddress(
deployer,
vm.getNonce(deployer) + 4
);

console.log("Deployer address: \t\t\t\t", deployer);

vm.startBroadcast(deployerPrivateKey);

// Deploy the Atlas contract
simulator = new Simulator();
atlas = new Atlas(64, address(simulator));
atlas = new Atlas({
_escrowDuration: 64,
_factory: expectedAtlasFactoryAddr,
_verification: expectedAtlasVerificationAddr,
_gasAccLib: expectedGasAccountingLibAddr,
_safetyLocksLib: expectedSafetyLocksLibAddr,
_simulator: address(simulator)
});
atlasFactory = new AtlasFactory(address(atlas));
atlasVerification = new AtlasVerification(address(atlas));
gasAccountingLib = new GasAccountingLib({
_escrowDuration: 64,
_factory: expectedAtlasFactoryAddr,
_verification: expectedAtlasVerificationAddr,
_safetyLocksLib: expectedSafetyLocksLibAddr,
_simulator: address(simulator),
_atlas: address(atlas)
});
safetyLocksLib = new SafetyLocksLib({
_escrowDuration: 64,
_factory: expectedAtlasFactoryAddr,
_verification: expectedAtlasVerificationAddr,
_gasAccLib: expectedGasAccountingLibAddr,
_simulator: address(simulator),
_atlas: address(atlas)
});

// Deploy the SwapIntent DAppControl contract
swapIntentControl = new SwapIntentController(address(atlas));

// Integrate SwapIntent with Atlas
atlas.initializeGovernance(address(swapIntentControl));
atlas.integrateDApp(address(swapIntentControl));
atlasVerification.initializeGovernance(address(swapIntentControl));
atlasVerification.integrateDApp(address(swapIntentControl));

// Deploy the TxBuilder
txBuilder = new TxBuilder(address(swapIntentControl), address(atlas), address(atlas));
Expand Down
Loading

0 comments on commit 4cc3138

Please sign in to comment.