Skip to content

Commit

Permalink
Updated Solidity compiler to v0.8.26 and evmVersion to cancun.
Browse files Browse the repository at this point in the history
  • Loading branch information
- committed May 26, 2024
1 parent e1dcd26 commit b9532b1
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 188 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ Axelar's factory was included because they are a trustworthy organization doing

The original solidity files were obtained by firstly adding the npm package `@axelar-network/axelar-gmp-sdk-solidity` and importing `@axelar-network/axelar-gmp-sdk-solidity/contracts/deploy/Create3Deployer.sol` in `contracts/Imports.sol`. Hardhat then compiles it and places the artifacts in `artifacts` directory. `Create3Deployer.json` is then copied to `artifacts-saved/@axelar-network/axelar-gmp-sdk-solidity/contracts/deploy/Create3Deployer.sol/` directory for preservation of the bytecode.

Gas used for the deployment is around 724,337, so gas limit in this deployment transaction has been set to 900,000, giving some room in case some opcode costs increase in future, hence there should be at least 0.09 of native currency at the signer's address before factory deployment.
Gas used for the deployment is around 737,521, so gas limit in this deployment transaction has been set to 900,000, giving some room in case some opcode costs increase in future, hence there should be at least 0.09 of native currency at the signer's address before factory deployment.

Axelar's factory contract will be deployed to this address (if the EVM version is `shanghai` and transaction bytecode is unchanged):
Axelar's factory contract will be deployed to this address (if the EVM version is `cancun` and transaction bytecode is unchanged):
```
0x95A9323CF0443758df5F3becf3B221cB3D42f3A0
0x8cf037a598957EFE440841E256f4CA0056A8219C
```
The derived address of the account that would sign the deployment transaction, and that you'd need to fund in order to pay the gas fee, is:
```
0x152510503b8f5EB95dc34aAF274DFc858d609DF5
0xa800eb61836539b33ad43201b7997ED30bA75f5D
```

#### ZeframLou & transmissions11/solmate
Expand All @@ -99,15 +99,15 @@ The solmate CREATE3 library was obtained by adding the github repository commit

`@SKYBITDev3/ZeframLou-create3-factory/src/CREATE3Factory.sol` is imported in `contracts/Imports.sol`. Hardhat then compiles it and places the artifacts in `artifacts` directory. `CREATE3Factory.json` is then copied to `artifacts-saved/@SKYBITDev3/ZeframLou-create3-factory/src/CREATE3Factory.sol/` directory for preservation of the bytecode.

Gas used for the deployment is around 389,011, so gas limit in this deployment transaction has been set to 500,000, giving some room in case some opcode costs increase in future, hence there should be at least 0.05 of native currency at the signer's address before factory deployment.
Gas used for the deployment is around 392,687, so gas limit in this deployment transaction has been set to 500,000, giving some room in case some opcode costs increase in future, hence there should be at least 0.05 of native currency at the signer's address before factory deployment.

ZeframLou's factory contract will be deployed to this address (if the EVM version is `shanghai` and transaction bytecode is unchanged):
ZeframLou's factory contract will be deployed to this address (if the EVM version is `cancun` and transaction bytecode is unchanged):
```
0x2befaF9234EE4d5b10dDAECF55F73dA87F74Facb
0x03B583D983aAe5a965dfCC3565F58C9153Af1Be3
```
The derived address of the account that would sign the deployment transaction, and that you'd need to fund in order to pay the gas fee, is:
```
0x1C5aEAeb492367E680e2aD965fE2Ac90E5c648cf
0x9dA930687de2ac5a056dbD80BCDb99c7008f1750
```
#### SKYBIT & Vectorized/solady
The Vectorized/solady CREATE3 library has been included because it is more gas-efficient than other options. A factory contract is needed to use the library so a new one was created based on ZeframLou's factory.
Expand All @@ -118,15 +118,15 @@ The original Vectorized/solady CREATE3 solidity file was obtained by firstly add

`contracts/SKYBITCREATE3Factory.sol` imports `{CREATE3} from "@Vectorized/solady/src/utils/CREATE3.sol";`. Hardhat then compiles it and places the artifacts in `artifacts` directory. `SKYBITCREATE3Factory.json` is then copied to `artifacts-saved/contracts/SKYBITCREATE3Factory.sol/` directory for preservation of the bytecode.

Gas used for the deployment is around 230,784, so gas limit in this deployment transaction has been set to 300,000, giving some room in case some opcode costs increase in future, hence there should be at least 0.03 of native currency at the signer's address before factory deployment.
Gas used for the deployment is around 260,068, so gas limit in this deployment transaction has been set to 300,000, giving some room in case some opcode costs increase in future, hence there should be at least 0.03 of native currency at the signer's address before factory deployment.

The SKYBITSolady factory contract will be deployed to this address (if the EVM version is `shanghai` and transaction bytecode is unchanged):
The SKYBITSolady factory contract will be deployed to this address (if the EVM version is `cancun` and transaction bytecode is unchanged):
```
0xF545230eE44735CCDb71325c6D4bC981b444CBb6
0x5391d63aBd39A43360CE360531f5Ba5c19249030
```
The derived address of the account that would sign the deployment transaction, and that you'd need to fund in order to pay the gas fee, is:
```
0x7a2c43Cb49D08a68D8F6Ac708A55716C3cd78557
0x0d253cCC774aa8F6619FC6C094D961a09Ce50865
```

#### SKYBITLite
Expand All @@ -136,7 +136,7 @@ The node package [@skybit/hardhat-yul](https://www.npmjs.com/package/@skybit/har

Gas used for the deployment is 78,914, so gas limit in this deployment transaction has been set to 100,000, giving some room in case some opcode costs increase in future, hence there should be at least 0.01 of native currency at the signer's address before factory deployment.

The SKYBITLite factory contract will be deployed to this address (if the EVM version is `shanghai` and transaction bytecode is unchanged):
The SKYBITLite factory contract will be deployed to this address (if the EVM version is `cancun` and transaction bytecode is unchanged):
```
0x739201bA340A675624D9ADb1cc27e68F76a29765
```
Expand Down Expand Up @@ -463,18 +463,18 @@ See also `contracts/TESTERC20.sol` in which the constructor accepts an array of
An alternative is to replace `msg.sender` with `tx.origin`, but Vitalik said that we shouldn't rely on `tx.origin`. Feel free to do some research if you're curious.

### Invalid opcode
It's generally best practice to use the latest released versions of technology. However Hardhat v2.17.3 downgraded the default EVM version from `shanghai` to `paris`. So if you want to use the latest EVM then you need to set the EVM version explicity in `hardhat.config.js` like this:
It's generally best practice to use the latest released versions of technology. However Hardhat v2.17.3 downgraded the default EVM version to `paris`. So if you want to use the latest EVM then you need to set the EVM version explicity in `hardhat.config.js` like this:
```js
solidity: { // changing these values affects deployment address
compilers: [
{
version: `0.8.24`,
version: `0.8.26`,
settings: {
optimizer: {
enabled: true,
runs: 15000
},
evmVersion: `shanghai` // downgrade to `paris` if you encounter 'invalid opcode' error
evmVersion: `cancun` // downgrade to `paris` if you encounter 'invalid opcode' error
}
},
],
Expand Down

This file was deleted.

7 changes: 2 additions & 5 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ networks = { ...networks, ...additionalNetworks }
// RPC URL overrides in case you dont want to use the one in viem/chains:
// networks.mainnet.url = `https://eth-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`

networks.polygonMumbai.url = `https://polygon-mumbai.blockpi.network/v1/rpc/public`

networks.bscTestnet.url = `https://data-seed-prebsc-2-s2.bnbchain.org:8545`

networks.sepolia.url = `https://eth-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`
Expand All @@ -139,14 +137,13 @@ module.exports = {
solidity: { // changing these values changes bytecode, so can affect deployment address if not using CREATE3
compilers: [
{
version: `0.8.24`,
version: `0.8.26`,
settings: {
optimizer: {
enabled: true,
runs: 15000
},
evmVersion: `shanghai`, // downgrade to `paris` if you encounter 'invalid opcode' error
// evmVersion: `paris`,
evmVersion: `cancun`,
}
},
],
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SKYBIT-Keyless-Deployment",
"version": "5.0.2",
"version": "6.0.0",
"packageManager": "[email protected]",
"devDependencies": {
"@SKYBITDev3/ZeframLou-create3-factory": "https://github.com/SKYBITDev3/ZeframLou-create3-factory#3a8db987b8a6e1b63845a0ee1d0206cb4b5748f9",
Expand Down Expand Up @@ -30,7 +30,7 @@
"ethers": "^6.12.1",
"hardhat": "^2.22.4",
"hardhat-gas-reporter": "^2.2.0",
"solc": "0.8.24",
"solc": "0.8.26",
"solidity-coverage": "^0.8.12",
"ts-node": "^10.9.2",
"typechain": "^8.3.2",
Expand Down
4 changes: 2 additions & 2 deletions scripts/deployKeylessly-TESTERC20UG.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function main() {
const cfToken = await ethers.getContractFactory(artifactOfContractToDeploy.abi, artifactOfContractToDeploy.bytecode)
const bytecodeWithArgs = (await cfToken.getDeployTransaction()).data // no constructor args

const implAddress = await deployKeylessly(contractName, bytecodeWithArgs, gasLimitForImpl, wallet, isDeployEnabled) // gas cost: 3012861
const implAddress = await deployKeylessly(contractName, bytecodeWithArgs, gasLimitForImpl, wallet, isDeployEnabled)
if (implAddress === undefined) return

const proxyContractName = `ERC1967Proxy`
Expand All @@ -41,7 +41,7 @@ async function main() {

const proxyBytecodeWithArgs = (await cfProxy.getDeployTransaction(...proxyConstructorArgs)).data

const proxyAddress = await deployKeylessly(proxyContractName, proxyBytecodeWithArgs, gasLimitForProxy, wallet, isDeployEnabled) // gas cost: 378214
const proxyAddress = await deployKeylessly(proxyContractName, proxyBytecodeWithArgs, gasLimitForProxy, wallet, isDeployEnabled)

if (isDeployEnabled) {
await upgrades.forceImport(proxyAddress, cfToken)
Expand Down
8 changes: 4 additions & 4 deletions scripts/deployViaCREATE3-TESTERC20.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { ethers, network } = require(`hardhat`)

// CHOOSE WHICH FACTORY YOU WANT TO USE:
// const factoryToUse = { name: `axelarnetwork`, address: `0x95A9323CF0443758df5F3becf3B221cB3D42f3A0` } // gas cost: 1846094
// const factoryToUse = { name: `ZeframLou`, address: `0x2befaF9234EE4d5b10dDAECF55F73dA87F74Facb` } // gas cost: 1767973
// const factoryToUse = { name: `SKYBITSolady`, address: `0xF545230eE44735CCDb71325c6D4bC981b444CBb6` } // gas cost: 1743119
const factoryToUse = { name: `SKYBITLite`, address: `0x739201bA340A675624D9ADb1cc27e68F76a29765` } // gas cost: 1743602
// const factoryToUse = { name: `axelarnetwork`, address: `0x8cf037a598957EFE440841E256f4CA0056A8219C` }
// const factoryToUse = { name: `ZeframLou`, address: `0x03B583D983aAe5a965dfCC3565F58C9153Af1Be3` }
// const factoryToUse = { name: `SKYBITSolady`, address: `0x5391d63aBd39A43360CE360531f5Ba5c19249030` }
const factoryToUse = { name: `SKYBITLite`, address: `0x739201bA340A675624D9ADb1cc27e68F76a29765` }


const isDeployEnabled = true // toggle in case you do deployment and verification separately.
Expand Down
10 changes: 5 additions & 5 deletions scripts/deployViaCREATE3-TESTERC20UG.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
const { ethers, network, upgrades } = require(`hardhat`)

// CHOOSE WHICH FACTORY YOU WANT TO USE:
// const factoryToUse = { name: `axelarnetwork`, address: `0x95A9323CF0443758df5F3becf3B221cB3D42f3A0` } // gas cost: 2413077 + 498930
// const factoryToUse = { name: `ZeframLou`, address: `0x2befaF9234EE4d5b10dDAECF55F73dA87F74Facb` } // gas cost: 2413077 + 422294
// const factoryToUse = { name: `SKYBITSolady`, address: `0xF545230eE44735CCDb71325c6D4bC981b444CBb6` } // gas cost: 2413077 + 418479
const factoryToUse = { name: `SKYBITLite`, address: `0x739201bA340A675624D9ADb1cc27e68F76a29765` } // gas cost: 2413077 + 419071
// const factoryToUse = { name: `axelarnetwork`, address: `0x8cf037a598957EFE440841E256f4CA0056A8219C` }
// const factoryToUse = { name: `ZeframLou`, address: `0x03B583D983aAe5a965dfCC3565F58C9153Af1Be3` }
// const factoryToUse = { name: `SKYBITSolady`, address: `0x5391d63aBd39A43360CE360531f5Ba5c19249030` }
const factoryToUse = { name: `SKYBITLite`, address: `0x739201bA340A675624D9ADb1cc27e68F76a29765` }

const isDeployEnabled = true // toggle in case you do deployment and verification separately.

Expand Down Expand Up @@ -67,7 +67,7 @@ async function main() {
const { getArtifactOfFactory, getDeployedAddress, CREATE3Deploy } = rootRequire(`scripts/CREATE3-deploy-functions.js`)

if (isDeployEnabled) {
proxy = await CREATE3Deploy(factoryToUse.name, factoryToUse.address, cfProxy, proxyContractName, proxyConstructorArgs, salt, wallet, isDeployEnabled) // Gas cost: 425068
proxy = await CREATE3Deploy(factoryToUse.name, factoryToUse.address, cfProxy, proxyContractName, proxyConstructorArgs, salt, wallet, isDeployEnabled)
if (proxy === undefined) return

proxyAddress = proxy.target
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ __metadata:
ethers: "npm:^6.12.1"
hardhat: "npm:^2.22.4"
hardhat-gas-reporter: "npm:^2.2.0"
solc: "npm:0.8.24"
solc: "npm:0.8.26"
solidity-coverage: "npm:^0.8.12"
ts-node: "npm:^10.9.2"
typechain: "npm:^8.3.2"
Expand Down Expand Up @@ -6576,9 +6576,9 @@ __metadata:
languageName: node
linkType: hard

"solc@npm:0.8.24":
version: 0.8.24
resolution: "solc@npm:0.8.24"
"solc@npm:0.8.26":
version: 0.8.26
resolution: "solc@npm:0.8.26"
dependencies:
command-exists: "npm:^1.2.8"
commander: "npm:^8.1.0"
Expand All @@ -6589,7 +6589,7 @@ __metadata:
tmp: "npm:0.0.33"
bin:
solcjs: solc.js
checksum: 10/e85644370a26a92fbdfb783ce14184fb6291ddd77ff93cc5d70019add63c32ecea9988453d02b27b99cb37f46cc99b88f33321305b3f9a5cacb9b1a6f803b607
checksum: 10/30ef9c2687f727eb5bdd685c77b1a0b354e7d6ba7a080cfcdce5a89f25a1399ff7949fecef47768088d825588da230da0044b46f056fc36f3959c0e3d3c9a82b
languageName: node
linkType: hard

Expand Down

0 comments on commit b9532b1

Please sign in to comment.