-
Notifications
You must be signed in to change notification settings - Fork 19
feat: added additional checks for call contract with token #249
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
Merged
milapsheth
merged 36 commits into
main
from
feat/additional-checks-for-execute-with-token
Apr 12, 2024
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
48f60e5
Added additional checks but code size is too large
Foivos fc8cb1a
Added value for contractCallWithToken and optimized contract size
Foivos ead719d
trying to fix tests
Foivos 800ae3d
Update the create3address of ITS to use a custom bytecodehash.
Foivos cf016b0
prettier
Foivos ad53bc2
fix tests
Foivos 7f610e7
Added a few tests
Foivos 7a926fc
fixed one more test
Foivos 83a396a
fixed all tests
Foivos c326d57
prettier
Foivos ca2bd91
made lint happy
Foivos 1468d7e
working on slither
Foivos dccaf3c
made slither happy
Foivos 927e1ce
prettier
Foivos 1fc47a8
Using constant for the hash as well
Foivos f5823cc
addressed comments
Foivos c562c6a
added some tests
Foivos 684fda9
Merge remote-tracking branch 'origin/main' into feat/additional-check…
Foivos f133cc9
added some coverage tests, found a bug too!
Foivos 76a2545
a small style fix
Foivos 74f09c6
fixed a bug
Foivos e896028
addressed some comments
Foivos b57cefc
prettier
Foivos 5e311f2
fixed a test
Foivos f92443b
Merge branch 'main' into feat/additional-checks-for-execute-with-token
milapsheth 0fcba29
remove modifier that should not exist
Foivos c5a5ba5
rename a function
Foivos dbc605d
Update contracts/InterchainTokenService.sol
Foivos b1c9266
reinteroduce the modifiers since they are needed after all
Foivos 515be9c
Update contracts/utils/Create3AddressFixed.sol
milapsheth f787f13
add a docstring
Foivos 10ed394
prettier and fixed tests
Foivos 52c75e6
Merge remote-tracking branch 'origin/main' into feat/additional-check…
Foivos 72fd642
Merge branch 'main' into feat/additional-checks-for-execute-with-token
milapsheth a2b9e47
address comments
milapsheth 9d5c152
fix factory import
milapsheth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import { Create3Fixed } from '../../utils/Create3Fixed.sol'; | ||
|
||
contract TestCreate3Fixed is Create3Fixed { | ||
event Deployed(address addr); | ||
|
||
function deploy(bytes memory code, bytes32 salt) public payable returns (address addr) { | ||
addr = _create3(code, salt); | ||
|
||
emit Deployed(addr); | ||
} | ||
|
||
function deployedAddress(bytes32 salt) public view returns (address addr) { | ||
addr = _create3Address(salt); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
/** | ||
* @title Create3AddressFixed contract | ||
* @notice This contract can be used to predict the deterministic deployment address of a contract deployed with the `CREATE3` technique. | ||
* It is equivalent to the Create3Address found in axelar-gmp-sdk-solidity repo but uses a fixed bytecode for CreateDeploy, | ||
* which allows changing compilation options (like number of runs) without affecting the future deployment addresses. | ||
*/ | ||
contract Create3AddressFixed { | ||
// slither-disable-next-line too-many-digits | ||
bytes internal constant CREATE_DEPLOY_BYTECODE = | ||
hex'608060405234801561001057600080fd5b50610162806100206000396000f3fe60806040526004361061001d5760003560e01c806277436014610022575b600080fd5b61003561003036600461007b565b610037565b005b8051602082016000f061004957600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561008d57600080fd5b813567ffffffffffffffff808211156100a557600080fd5b818401915084601f8301126100b957600080fd5b8135818111156100cb576100cb61004c565b604051601f8201601f19908116603f011681019083821181831017156100f3576100f361004c565b8160405282815287602084870101111561010c57600080fd5b82602086016020830137600092810160200192909252509594505050505056fea264697066735822122094780ce55d28f1d568f4e0ab1b9dc230b96e952b73d2e06456fbff2289fa27f464736f6c63430008150033'; | ||
bytes32 internal constant CREATE_DEPLOY_BYTECODE_HASH = keccak256(CREATE_DEPLOY_BYTECODE); | ||
|
||
/** | ||
* @notice Compute the deployed address that will result from the `CREATE3` method. | ||
* @param deploySalt A salt to influence the contract address | ||
* @return deployed The deterministic contract address if it was deployed | ||
*/ | ||
function _create3Address(bytes32 deploySalt) internal view returns (address deployed) { | ||
address deployer = address( | ||
uint160(uint256(keccak256(abi.encodePacked(hex'ff', address(this), deploySalt, CREATE_DEPLOY_BYTECODE_HASH)))) | ||
); | ||
|
||
deployed = address(uint160(uint256(keccak256(abi.encodePacked(hex'd6_94', deployer, hex'01'))))); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import { IDeploy } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IDeploy.sol'; | ||
import { ContractAddress } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/ContractAddress.sol'; | ||
import { CreateDeploy } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/deploy/CreateDeploy.sol'; | ||
import { Create3AddressFixed } from './Create3AddressFixed.sol'; | ||
|
||
/** | ||
* @title Create3Fixed contract | ||
* @notice This contract can be used to deploy a contract with a deterministic address that depends only on | ||
* the deployer address and deployment salt, not the contract bytecode and constructor parameters. | ||
milapsheth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* It uses a fixed bytecode to allow changing the compilation settings without affecting the deployment address in the future. | ||
*/ | ||
contract Create3Fixed is Create3AddressFixed, IDeploy { | ||
using ContractAddress for address; | ||
|
||
/** | ||
* @notice Deploys a new contract using the `CREATE3` method. | ||
* @dev This function first deploys the CreateDeploy contract using | ||
* the `CREATE2` opcode and then utilizes the CreateDeploy to deploy the | ||
* new contract with the `CREATE` opcode. | ||
* @param bytecode The bytecode of the contract to be deployed | ||
* @param deploySalt A salt to influence the contract address | ||
* @return deployed The address of the deployed contract | ||
*/ | ||
function _create3(bytes memory bytecode, bytes32 deploySalt) internal returns (address deployed) { | ||
deployed = _create3Address(deploySalt); | ||
|
||
if (bytecode.length == 0) revert EmptyBytecode(); | ||
if (deployed.isContract()) revert AlreadyDeployed(); | ||
|
||
// Deploy using create2 | ||
CreateDeploy createDeploy; | ||
bytes memory createDeployBytecode_ = CREATE_DEPLOY_BYTECODE; | ||
uint256 length = createDeployBytecode_.length; | ||
assembly { | ||
createDeploy := create2(0, add(createDeployBytecode_, 0x20), length, deploySalt) | ||
} | ||
|
||
if (address(createDeploy) == address(0)) revert DeployFailed(); | ||
// Deploy using create | ||
createDeploy.deploy(bytecode); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.