Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ Deterministic deployment:

- Set `ESCROW_DEPLOY_SALT=<bytes32>` when running `GitBondEscrowScript`
(CREATE2 is now used by default).
- The same deployer address, same salt, same implementation bytecode and same initializer args produce
deterministic addresses on each chain.
- This script deploys both implementation and proxy with CREATE2 (`ERC1967Proxy`), making
proxy/implementation addresses predictable across chains.
- The same deployer address, same salt, and same initializer args produce a deterministic proxy address
on each chain.
- This script deploys the proxy with CREATE2 (`ERC1967Proxy`) for deterministic proxy addresses.
The implementation is deployed normally (non-CREATE2).

Whitelist trust assumption:

Expand Down
4 changes: 4 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ build_info = true
extra_output = ["storageLayout"]
fs_permissions = [{ access = "read", path = "./out" }]

# Silence solc warnings emitted from dependencies (e.g. OpenZeppelin foundry helpers under lib/).
# Warnings from src/ and script/ are still shown.
ignored_warnings_from = ["lib"]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
15 changes: 5 additions & 10 deletions script/GitBondEscrow.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ contract GitBondEscrowScript is Script {

address escrowImplementation;
address escrowProxy;
bytes32 implementationSalt = _saltForDeployment(deploymentSalt, "implementation");
bytes32 proxySalt = _saltForDeployment(deploymentSalt, "proxy");
escrowImplementation = _deployImplementation(implementationFile, implementationSalt);
escrowImplementation = _deployImplementation(implementationFile);
escrowProxy = _deployProxy(escrowImplementation, initData, proxySalt);

console.log("CREATE2 mode: enabled");
console.log("Salt:", vm.toString(deploymentSalt));
console.log("CREATE2 impl salt:", vm.toString(implementationSalt));
console.log("CREATE2 proxy salt:", vm.toString(proxySalt));

GitBondEscrow escrow = GitBondEscrow(escrowProxy);
Expand All @@ -41,8 +39,8 @@ contract GitBondEscrowScript is Script {
require(escrow.treasury() == treasury && implementation != address(0), "Deployment post-conditions failed");
require(escrowImplementation == implementation, "Implementation address mismatch");

console.log("GitBondEscrow implementation:", implementation);
console.log("CREATE2 implementation:", escrowImplementation);
console.log("Proxy-reported implementation:", implementation);
console.log("Locally deployed implementation:", escrowImplementation);
console.log("GitBondEscrow proxy deployed:", escrowProxy);
console.log("Escrow treasury:", escrow.treasury());
console.log("Escrow owner:", escrow.owner());
Expand All @@ -52,11 +50,8 @@ contract GitBondEscrowScript is Script {
vm.stopBroadcast();
}

function _deployImplementation(string memory implementationFile, bytes32 implementationSalt)
internal
returns (address)
{
return vm.deployCode(implementationFile, bytes(""), implementationSalt);
function _deployImplementation(string memory implementationFile) internal returns (address) {
return vm.deployCode(implementationFile, bytes(""));
}

function _deployProxy(address escrowImplementation, bytes memory initData, bytes32 proxySalt)
Expand Down
6 changes: 3 additions & 3 deletions src/GitBondEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ contract GitBondEscrow is
_createEscrowFrom(payer, key, counterparty, beneficiary, token, amount, true, permit_);
}

function refundEscrow(bytes32 key) external virtual whenNotPaused {
function refundEscrow(bytes32 key) external virtual whenNotPaused nonReentrant {
GitBondEscrowStorage.Layout storage s = _layout();
GitBondEscrowStorage.Escrow storage e = s.escrows[key];

Expand All @@ -194,7 +194,7 @@ contract GitBondEscrow is
emit EscrowRefunded(key, e.payer, e.beneficiary, e.token, amountToReturn);
}

function slashEscrow(bytes32 key) external virtual whenNotPaused {
function slashEscrow(bytes32 key) external virtual whenNotPaused nonReentrant {
GitBondEscrowStorage.Layout storage s = _layout();
GitBondEscrowStorage.Escrow storage e = s.escrows[key];

Expand All @@ -218,7 +218,7 @@ contract GitBondEscrow is
emit EscrowSlashed(key, e.beneficiary, e.counterparty, e.token, amountToCounterparty, platformCut);
}

function claim(address token) external virtual whenNotPaused {
function claim(address token) external virtual whenNotPaused nonReentrant {
GitBondEscrowStorage.Layout storage s = _layout();
uint256 amount = s.claimAmounts[msg.sender][token];

Expand Down
Loading