mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Remove the Sandbox contract
If instead of intaking calls, we intake code, we can deploy a fresh contract which makes arbitrary calls *without* attempting to build our abstraction layer over the concept. This should have the same gas costs, as we still have one contract deployment. The new contract only has a constructor, so it should have no actual code and beat the Sandbox in that regard? We do have to call into ourselves to meter the gas, yet we already had to call into the deployed Sandbox to achieve that. Also re-defines the OutInstruction to include tokens, implements OutInstruction-specified gas amounts, bumps the Solidity version, and other such misc changes.
This commit is contained in:
@@ -6,8 +6,12 @@ use std::{path::PathBuf, fs, process::Command};
|
||||
|
||||
/// Build contracts from the specified path, outputting the artifacts to the specified path.
|
||||
///
|
||||
/// Requires solc 0.8.25.
|
||||
pub fn build(contracts_path: &str, artifacts_path: &str) -> Result<(), String> {
|
||||
/// Requires solc 0.8.26.
|
||||
pub fn build(
|
||||
include_paths: &[&str],
|
||||
contracts_path: &str,
|
||||
artifacts_path: &str,
|
||||
) -> Result<(), String> {
|
||||
println!("cargo:rerun-if-changed={contracts_path}/*");
|
||||
println!("cargo:rerun-if-changed={artifacts_path}/*");
|
||||
|
||||
@@ -24,20 +28,24 @@ pub fn build(contracts_path: &str, artifacts_path: &str) -> Result<(), String> {
|
||||
if let Some(version) = line.strip_prefix("Version: ") {
|
||||
let version =
|
||||
version.split('+').next().ok_or_else(|| "no value present on line".to_string())?;
|
||||
if version != "0.8.25" {
|
||||
Err(format!("version was {version}, 0.8.25 required"))?
|
||||
if version != "0.8.26" {
|
||||
Err(format!("version was {version}, 0.8.26 required"))?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
let args = [
|
||||
let mut args = vec![
|
||||
"--base-path", ".",
|
||||
"-o", artifacts_path, "--overwrite",
|
||||
"--bin", "--bin-runtime", "--abi",
|
||||
"--via-ir", "--optimize",
|
||||
"--no-color",
|
||||
];
|
||||
for include_path in include_paths {
|
||||
args.push("--include-path");
|
||||
args.push(include_path);
|
||||
}
|
||||
let mut args = args.into_iter().map(str::to_string).collect::<Vec<_>>();
|
||||
|
||||
let mut queue = vec![PathBuf::from(contracts_path)];
|
||||
@@ -70,17 +78,17 @@ pub fn build(contracts_path: &str, artifacts_path: &str) -> Result<(), String> {
|
||||
}
|
||||
|
||||
let solc = Command::new("solc")
|
||||
.args(args)
|
||||
.args(args.clone())
|
||||
.output()
|
||||
.map_err(|_| "couldn't fetch solc output".to_string())?;
|
||||
let stderr =
|
||||
String::from_utf8(solc.stderr).map_err(|_| "solc stderr wasn't UTF-8".to_string())?;
|
||||
if !solc.status.success() {
|
||||
Err(format!("solc didn't successfully execute: {stderr}"))?;
|
||||
Err(format!("solc (`{}`) didn't successfully execute: {stderr}", args.join(" ")))?;
|
||||
}
|
||||
for line in stderr.lines() {
|
||||
if line.contains("Error:") {
|
||||
Err(format!("solc output had error: {stderr}"))?;
|
||||
Err(format!("solc (`{}`) output had error: {stderr}", args.join(" ")))?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user