Skip to content

Commit

Permalink
Support specific evmVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
helldealer committed Apr 28, 2022
1 parent 521457a commit 31d87fd
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
backend/solc-bin
backend/node_modules
backend/.idea
backend/contract-db/
backend/deploycode
backend/libevmwrap.so
moeing_dev.*
*.swp
.DS_Store
.idea
34 changes: 2 additions & 32 deletions backend/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,6 @@ app.use((err, req, res, next) => {
}
});

// Get Contract Source Code for Verified Contract Source Codes
app.get('/contract/source/:addr', async (req, res) => {
console.log('/contract/source/', req.params.addr);
try {
const info = await getContractContext(req.params.addr);
if (info) {
res.json({ status: "success", data: info.flattenedSource });
} else {
res.json({ status: "error", message: "not verified" });
}
} catch (err) {
res.json({ status: "error", message: err.toString() });
}
});

// Get Contract ABI for Verified Contract Source Codes
app.get('/contract/abi/:addr', async (req, res) => {
console.log('/contract/abi/', req.params.addr);
try {
const info = await getContractContext(req.params.addr);
if (info) {
res.json({ status: "success", data: info.abi });
} else {
res.json({ status: "error", message: "not verified" });
}
} catch (err) {
res.json({ status: "error", message: err.toString() });
}
});

// Check Source Code Verification Status
app.get('/contract/info/:addr', async (req, res) => {
console.log(`/contract/info/${req.params.addr}`);
Expand Down Expand Up @@ -111,8 +81,7 @@ app.post('/contract/verify', async (req, res) => {
errMsg = 'missing constructorArguments';
// } else if (! body.licenseType) {
// errMsg = 'missing licenseType';
}

}
if (errMsg) {
res.json({ status: "error", message: errMsg });
} else {
Expand All @@ -126,6 +95,7 @@ app.post('/contract/verify', async (req, res) => {
compilerVersion : body.compilerVersion,
optimizationUsed : body.optimizationUsed,
runs : body.runs,
evmVersion : body.evmVersion,
});
if (ok) {
res.json({ status: "success" });
Expand Down
5 changes: 5 additions & 0 deletions backend/get_solc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# https://github.com/ethereum/solc-bin/blob/gh-pages/bin/list.json
getSolc() {
wget https://binaries.soliditylang.org/linux-amd64/$1
}
Expand Down Expand Up @@ -69,3 +70,7 @@ getSolc solc-linux-amd64-v0.8.6%2Bcommit.11564f7e
getSolc solc-linux-amd64-v0.8.7%2Bcommit.e28d00a7
getSolc solc-linux-amd64-v0.8.8%2Bcommit.dddeac2f
getSolc solc-linux-amd64-v0.8.9%2Bcommit.e5eed63a
getSolc solc-linux-amd64-v0.8.10%2Bcommit.fc410830
getSolc solc-linux-amd64-v0.8.11%2Bcommit.d7f03943
getSolc solc-linux-amd64-v0.8.12%2Bcommit.f00d7308
getSolc solc-linux-amd64-v0.8.13%2Bcommit.abaa5c0e
11 changes: 9 additions & 2 deletions backend/verifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ const SolVersions = new Set([
"v0.8.9+commit.e5eed63a",
"v0.8.10+commit.fc410830",
"v0.8.11+commit.d7f03943",
"v0.8.12+commit.f00d7308",
"v0.8.13+commit.abaa5c0e",
])

async function runSolc(config) {
Expand All @@ -168,9 +170,13 @@ async function runSolc(config) {
fs.writeFileSync(srcFile, config.flattenedSource);

let outDir = path.join(tmpDir, "out");
// if not specific evm-version, use the default one in each sol which always use the newest version it supports, but not all this.
let args = ["--bin", "--abi", "--input-file", srcFile,
"--output-dir", outDir, "--evm-version", "istanbul"];

"--output-dir", outDir];
if (typeof config.evmVersion === 'string' && config.evmVersion !== "default") {
args = ["--bin", "--abi", "--input-file", srcFile,
"--output-dir", outDir, "--evm-version", config.evmVersion];
}
if(config.optimizationUsed) {
args.push("--optimize");
}
Expand Down Expand Up @@ -364,6 +370,7 @@ async function test() {
contractName: "ExchangeHub",
constructor: "constructor() public",
constructorArguments: [],
evmVersion: "default"
}
await verifyContract(context)
}
Expand Down
25 changes: 22 additions & 3 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
Solidity compiler version:<br>
<p class="select is-small is-link">
<select id="compilerVersion">
<option>v0.8.13+commit.abaa5c0e</option>
<option>v0.8.12+commit.f00d7308</option>
<option>v0.8.11+commit.d7f03943</option>
<option>v0.8.10+commit.fc410830</option>
<option>v0.8.9+commit.e5eed63a</option>
Expand Down Expand Up @@ -106,7 +108,24 @@
<option>v0.4.10+commit.9e8cc01b</option>
</select>
</p>


<br>Evm Version:<br>
<div class="select is-small is-link">
<select id="evmVersionType">
<option>default</option>
<option>london</option>
<option>berlin</option>
<option>istanbul</option>
<option>petersburg</option>
<option>constantinople</option>
<option>byzantium</option>
<option>spuriousDragon</option>
<option>tangerineWhistle</option>
</select>
</div>

<br>
<br>
<p class="control is-link">Compiler Optimization
<label class="radio is-small">
<input type="radio" name="optimizationUsed" id="optimizationUsed" checked>
Expand Down Expand Up @@ -270,7 +289,7 @@
content: e});
return
}

var evmVersion = document.getElementById("evmVersionType").value
const jsonForPost = {
contractAddress,
contractName,
Expand All @@ -281,6 +300,7 @@
constructor,
constructorArguments,
licenseType,
evmVersion,
}

console.log(jsonForPost)
Expand Down Expand Up @@ -312,7 +332,6 @@
return response.json(); // parses JSON response into native JavaScript objects
}


document.onclick = function() {
if(window.AlertDlg) {
window.AlertDlg.destroy();
Expand Down

0 comments on commit 31d87fd

Please sign in to comment.