Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
chore: fix up stage (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 authored Apr 21, 2024
1 parent f13f7de commit 50ee602
Show file tree
Hide file tree
Showing 27 changed files with 138 additions and 144 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ jobs:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: stable
profile: minimal
components: rustfmt, clippy
override: true
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
- name: cargo doc
run: cargo +nightly doc --all-features --no-deps
run: cargo doc --all-features --no-deps

cargo-clippy:
runs-on: ubuntu-latest
Expand All @@ -49,15 +49,15 @@ jobs:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
toolchain: stable
profile: minimal
components: rustfmt, clippy
override: true
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: false
- name: cargo clippy
run: cargo +nightly clippy --all --all-features -- -D warnings
run: cargo clippy --all --all-features -- -D warnings

tests:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions huff_cli/src/huffc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn main() {
if cli.path.is_none() {
// Print help and exit
app.print_help().unwrap();
return
return;
}

// Create compiler from the Huff Args
Expand Down Expand Up @@ -303,7 +303,7 @@ fn main() {
std::process::exit(1);
}
}
return
return;
}

if let Some(TestCommands::Test { format, match_ }) = cli.test {
Expand Down Expand Up @@ -332,7 +332,7 @@ fn main() {
std::process::exit(1);
}
}
return
return;
}

// Create compiling spinner
Expand Down
4 changes: 2 additions & 2 deletions huff_codegen/src/irgen/arg_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn bubble_arg_call(
mis,
jump_table,
)
}
};
}
MacroArg::Ident(iden) => {
tracing::debug!(target: "codegen", "Found MacroArg::Ident IN \"{}\" Macro Invocation: \"{}\"!", macro_invoc.1.macro_name, iden);
Expand Down Expand Up @@ -124,7 +124,7 @@ pub fn bubble_arg_call(
kind: CodegenErrorKind::StoragePointersNotDerived,
span: AstSpan(vec![]),
token: None,
})
});
}
};
*offset += push_bytes.len() / 2;
Expand Down
4 changes: 2 additions & 2 deletions huff_codegen/src/irgen/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn constant_gen(
kind: CodegenErrorKind::MissingConstantDefinition(name.to_string()),
span: ir_byte_span.clone(),
token: None,
})
});
};

// Generate bytecode for the constant
Expand All @@ -40,7 +40,7 @@ pub fn constant_gen(
kind: CodegenErrorKind::StoragePointersNotDerived,
span: constant.span.clone(),
token: None,
})
});
}
};

Expand Down
30 changes: 15 additions & 15 deletions huff_codegen/src/irgen/statements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn statement_gen<'a>(
kind: CodegenErrorKind::InvalidMacroInvocation(mi.macro_name.clone()),
span: mi.span.clone(),
token: None,
})
});
};

tracing::info!(target: "codegen", "FOUND INNER MACRO: {}", ir_macro.name);
Expand All @@ -50,7 +50,7 @@ pub fn statement_gen<'a>(
kind: CodegenErrorKind::TestInvocation(ir_macro.name.clone()),
span: ir_macro.span.clone(),
token: None,
})
});
}

// If invoked macro is a function (outlined), insert a jump to the function's code and a
Expand Down Expand Up @@ -114,7 +114,7 @@ pub fn statement_gen<'a>(
"FAILED TO RECURSE INTO MACRO \"{}\"",
ir_macro.name
);
return Err(e)
return Err(e);
}
};

Expand Down Expand Up @@ -181,7 +181,7 @@ pub fn statement_gen<'a>(
),
span: bf.span.clone(),
token: None,
})
});
};

// Get the name of the macro being passed to __codesize
Expand Down Expand Up @@ -223,7 +223,7 @@ pub fn statement_gen<'a>(
"FAILED TO RECURSE INTO MACRO \"{}\"",
ir_macro.name
);
return Err(e)
return Err(e);
}
};

Expand Down Expand Up @@ -254,7 +254,7 @@ pub fn statement_gen<'a>(
),
span: bf.span.clone(),
token: None,
})
});
};

let size = bytes32_to_string(&ir_table.size, false);
Expand Down Expand Up @@ -294,7 +294,7 @@ pub fn statement_gen<'a>(
),
span: bf.span.clone(),
token: None,
})
});
}
}
BuiltinFunctionKind::FunctionSignature => {
Expand Down Expand Up @@ -353,7 +353,7 @@ pub fn statement_gen<'a>(
),
span: bf.span.clone(),
token: None,
})
});
}
}
BuiltinFunctionKind::EventHash => {
Expand Down Expand Up @@ -403,7 +403,7 @@ pub fn statement_gen<'a>(
),
span: bf.span.clone(),
token: None,
})
});
}
}
BuiltinFunctionKind::Error => {
Expand All @@ -420,7 +420,7 @@ pub fn statement_gen<'a>(
)),
span: bf.span.clone(),
token: None,
})
});
}

if let Some(error) = contract
Expand Down Expand Up @@ -453,7 +453,7 @@ pub fn statement_gen<'a>(
),
span: bf.span.clone(),
token: None,
})
});
}
}
BuiltinFunctionKind::RightPad => {
Expand Down Expand Up @@ -545,7 +545,7 @@ pub fn statement_gen<'a>(
)),
span: bf.span.clone(),
token: None,
})
});
}

let verbatim_str = bf.args[0].name.as_ref().unwrap();
Expand All @@ -554,7 +554,7 @@ pub fn statement_gen<'a>(
for c in verbatim_str.chars() {
if !c.is_ascii_hexdigit() {
is_hex = false;
break
break;
}
}
if !is_hex {
Expand All @@ -567,7 +567,7 @@ pub fn statement_gen<'a>(
kind: CodegenErrorKind::InvalidHex(verbatim_str.to_string()),
span: bf.span.clone(),
token: None,
})
});
}

tracing::debug!(target: "codegen", "INJECTING as verbatim: {}", verbatim_str);
Expand All @@ -586,7 +586,7 @@ pub fn statement_gen<'a>(
kind: CodegenErrorKind::InvalidMacroStatement,
span: s.span.clone(),
token: None,
})
});
}
}

Expand Down
14 changes: 7 additions & 7 deletions huff_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl Codegen {
.collect::<Vec<Span>>(),
),
token: None,
})
});
}

tracing::info!(target: "codegen", "GENERATING JUMPTABLE BYTECODE");
Expand Down Expand Up @@ -300,7 +300,7 @@ impl Codegen {
let circular_codesize_invocations = circular_codesize_invocations.unwrap_or(&mut ccsi);

// Loop through all intermediate bytecode representations generated from the AST
for (_ir_bytes_index, ir_byte) in ir_bytes.iter().enumerate() {
for ir_byte in ir_bytes.iter() {
let starting_offset = offset;
match &ir_byte.ty {
IRByteType::Bytes(b) => {
Expand All @@ -317,7 +317,7 @@ impl Codegen {
// if we have a codesize call for the constructor here, from within the
// constructor, we skip
if recursing_constructor {
continue
continue;
}
let mut push_bytes = statement_gen(
evm_version,
Expand Down Expand Up @@ -481,7 +481,7 @@ impl Codegen {
// Get the length of the macro
let num_invocations = circular_codesize_invocations.len();
if num_invocations == 0 {
return Ok(bytes)
return Ok(bytes);
}

tracing::debug!(target: "codegen", "Circular Codesize Invocation: Bytes before expansion: {:#?}", bytes);
Expand Down Expand Up @@ -706,7 +706,7 @@ impl Codegen {
kind: CodegenErrorKind::InvalidDynArgIndex,
span: AstSpan(vec![Span { start: 0, end: 0, file: None }]),
token: None,
})
});
}

// Constructor size optimizations
Expand Down Expand Up @@ -781,7 +781,7 @@ impl Codegen {
})),
}]),
token: None,
})
});
}
}
if let Err(e) = fs::write(file_path, serialized_artifact) {
Expand All @@ -799,7 +799,7 @@ impl Codegen {
})),
}]),
token: None,
})
});
}
Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions huff_core/benches/huff_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn lex_erc20_from_source_benchmark(c: &mut Criterion) {
.collect();

// Recurse file deps + generate flattened source
let file_source = file_sources.get(0).unwrap();
let file_source = file_sources.first().unwrap();
let recursed_file_source =
Compiler::recurse_deps(Arc::clone(file_source), &files::Remapper::new("./"), file_provider)
.unwrap();
Expand Down Expand Up @@ -48,7 +48,7 @@ fn parse_erc20_benchmark(c: &mut Criterion) {
.collect();

// Recurse file deps + generate flattened source
let file_source = file_sources.get(0).unwrap();
let file_source = file_sources.first().unwrap();
let recursed_file_source =
Compiler::recurse_deps(Arc::clone(file_source), &files::Remapper::new("./"), file_provider)
.unwrap();
Expand Down Expand Up @@ -84,7 +84,7 @@ fn codegen_erc20_benchmark(c: &mut Criterion) {
.collect();

// Recurse file deps + generate flattened source
let file_source = file_sources.get(0).unwrap();
let file_source = file_sources.first().unwrap();
let recursed_file_source =
Compiler::recurse_deps(Arc::clone(file_source), &files::Remapper::new("./"), file_provider)
.unwrap();
Expand Down Expand Up @@ -133,7 +133,7 @@ fn erc20_compilation_benchmark(c: &mut Criterion) {
.collect();

// Recurse file deps + generate flattened source
let file_source = file_sources.get(0).unwrap();
let file_source = file_sources.first().unwrap();
let recursed_file_source = Compiler::recurse_deps(
Arc::clone(file_source),
&files::Remapper::new("./"),
Expand Down Expand Up @@ -180,7 +180,7 @@ fn erc721_compilation_benchmark(c: &mut Criterion) {
.collect();

// Recurse file deps + generate flattened source
let file_source = file_sources.get(0).unwrap();
let file_source = file_sources.first().unwrap();
let recursed_file_source = Compiler::recurse_deps(
Arc::clone(file_source),
&files::Remapper::new("./"),
Expand Down
6 changes: 3 additions & 3 deletions huff_core/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ pub fn resolve_existing_artifacts(
Some(expected_fs) => {
if !artifact.bytecode.ends_with(&constructor_args) {
tracing::warn!(target: "core", "Mismatched Constructor Args for Cached Artifact \"{}\"", artifact.file.path);
return None
return None;
}
if artifact.file.source != expected_fs.source {
tracing::warn!(target: "core", "Cache Resolution Failed: \"{}\" Artifact Outdated", artifact.file.path);
return None
return None;
} else {
artifacts.push((expected_fs, artifact));
}
Expand All @@ -77,7 +77,7 @@ pub fn resolve_existing_artifacts(
tracing::error!(target: "core", "Invalid artifact file: {}", e);
if expected.is_some() {
tracing::error!(target: "core", "Expected artifact file to be compiled: {}", entry.path().display());
return None
return None;
}
}
}
Expand Down
Loading

0 comments on commit 50ee602

Please sign in to comment.