forked from foundry-rs/foundry
-
Notifications
You must be signed in to change notification settings - Fork 1
# Sequence diagram for AST-based keccak256 gas lint #292
Copy link
Copy link
Closed
Labels
P-highT-bugdependenciesPull requests that update a dependency filePull requests that update a dependency filedocumentationImprovements or additions to documentationImprovements or additions to documentationduplicateThis issue or pull request already existsThis issue or pull request already existsgithub_actionsPull requests that update GitHub Actions codePull requests that update GitHub Actions codegood first issueGood for newcomersGood for newcomersinvalidThis doesn't seem rightThis doesn't seem rightquestionFurther information is requestedFurther information is requestedrustPull requests that update rust codePull requests that update rust code
Description
Reviewer's Guide
Introduces a new AST-based linting infrastructure and simplifies the keccak gas lint to an early AST pass, adds multiple CI and security workflows plus a sample counter project, tightens path handling for corpus, benchmarks and test utilities, and makes assorted UX, documentation, and minor correctness tweaks across the codebase.
Sequence diagram for AST-based keccak256 gas lint
sequenceDiagram
participant CompilerSession as CompilerSession
participant LintContext as LintContext
participant EarlyLintVisitor as EarlyLintVisitor
participant AsmKeccak256 as AsmKeccak256
participant ExprNode as Expr
CompilerSession->>LintContext: new(sess, with_description)
CompilerSession->>EarlyLintVisitor: construct(ctx, passes=[AsmKeccak256])
loop walk_ast
CompilerSession->>EarlyLintVisitor: visit_expr(expr)
activate EarlyLintVisitor
EarlyLintVisitor->>AsmKeccak256: check_expr(ctx, expr)
activate AsmKeccak256
AsmKeccak256->>ExprNode: inspect kind
alt expr is Call to Ident Keccak256
AsmKeccak256->>LintContext: emit(ASM_KECCAK256, expr.span)
LintContext->>CompilerSession: create_diagnostic
else other expressions
AsmKeccak256-->>EarlyLintVisitor: no_op
end
deactivate AsmKeccak256
EarlyLintVisitor-->>CompilerSession: walk_expr_children
deactivate EarlyLintVisitor
end
Class diagram for new linting infrastructure and keccak256 gas lint
classDiagram
direction LR
class Linter {
<<trait>>
+type Language
+type Lint
+lint(input_pathbufs)
}
class Lint {
<<trait>>
+id() str
+severity() Severity
+description() str
+help() str
}
class LintContext {
-sess Session
-desc bool
+new(sess, with_description) LintContext
+emit(lint, span)
}
class EarlyLintPass {
<<trait>>
+check_expr(ctx, expr)
+check_item_struct(ctx, strukt)
+check_item_function(ctx, func)
+check_variable_definition(ctx, var)
}
class EarlyLintVisitor {
+ctx LintContext
+passes EarlyLintPass[]
+visit_expr(expr)
+visit_variable_definition(var)
+visit_item_struct(strukt)
+visit_item_function(func)
}
class AsmKeccak256 {
+new()
+check_expr(ctx, expr)
}
class Session
class Severity
class Expr {
+kind ExprKind
+span Span
}
class ExprKind {
<<enum>>
Call
Ident
Other
}
class Span
Linter --> Lint : uses
Linter --> LintContext : uses
LintContext --> Session : holds
LintContext --> Lint : emit
EarlyLintVisitor --> LintContext : holds
EarlyLintVisitor --> EarlyLintPass : "*" passes
AsmKeccak256 ..|> EarlyLintPass : implements
EarlyLintVisitor --> Expr : visits
Expr --> ExprKind : has
Expr --> Span : has
AsmKeccak256 --> Expr : analyzes
class ASM_KECCAK256 {
<<static_lint>>
+id : str
+severity : Severity
+description : str
+help : str
}
ASM_KECCAK256 ..|> Lint
AsmKeccak256 --> ASM_KECCAK256 : emits
Class diagram for sample Counter Solidity contract
classDiagram
direction LR
class Counter {
-uint256 number
+setNumber(newNumber_uint256)
+increment()
+number() uint256
}
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Refactor linting infrastructure and update ASM keccak gas lint to operate on the AST as an early pass. |
|
crates/lint/src/linter.rscrates/lint/src/sol/gas/keccak.rs |
| Harden filesystem handling for fuzzing corpus replay, benchmark project cleanup, and script testing utilities. |
|
crates/evm/evm/src/executors/corpus.rsbenches/src/lib.rscrates/test-utils/src/script.rs |
Tighten UX and correctness of the cast mktx command and simplify gas simulation output token handling. |
|
crates/cast/src/cmd/mktx.rscrates/script/src/simulate.rs |
| Adjust documentation generation behavior for dev comments, function headings, and enum variant docs. |
|
crates/doc/src/writer/as_doc.rscrates/doc/src/writer/buf_writer.rscrates/doc/src/parser/comment.rs |
| Extend CI and security tooling with dependency update automation, container/image scanning, CodeQL, deploy, and Docker workflows, plus CircleCI configs. |
|
.github/workflows/dependencies.yml.github/workflows/docker.yml.github/workflows/google.yml.github/workflows/snyk-container.yml.github/workflows/codeql.yml.github/workflows/deploy.yml.github/workflows/apisec-scan.yml.circleci/ci_cargo.yml.circleci/cargo.yml.circleci/config.yml.circleci/ci-web3-gamefi.yml.circleci/web3_defi_gamefi.yml |
Add a sample counter Foundry Solidity project with its own config, scripts, tests, and CI. |
|
counter/src/Counter.solcounter/script/Counter.s.solcounter/test/Counter.t.solcounter/foundry.tomlcounter/.gitignorecounter/lib/forge-stdcounter/lib/openzeppelin-contractscounter/README.mdcounter/.github/workflows/test.yml |
| Introduce Remix-style Solidity test support artifacts and issue templates. |
|
.deps/remix-tests/remix_tests.sol.deps/remix-tests/remix_accounts.sol.github/ISSUE_TEMPLATE/bug_report.md.github/ISSUE_TEMPLATE/feature_request.md.github/ISSUE_TEMPLATE/custom.md |
| Tweak test configuration, CLI suggestion sorting, artifact matching, and verification input wiring. |
|
.config/nextest.tomlcrates/cli/src/utils/suggestions.rscrates/common/src/contracts.rscrates/verify/src/etherscan/standard_json.rscrates/forge/tests/cli/test_optimizer.rs |
| Miscellaneous configuration and cosmetic tweaks. |
|
crates/forge/Cargo.tomlflake.nixcrates/script-sequence/src/sequence.rs.codesandbox/tasks.json.gitmodules |
Possibly linked issues
- Dargon789 patch 2 #245: The PR delivers the unified cheatcodes/lint refactors, Anvil/CLI updates, and CI changes outlined in the issue.
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with@sourcery-ai issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull
request title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment@sourcery-ai summaryon the pull request to
(re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull
request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore. - Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request
summary, the reviewer's guide, and others. - Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
Originally posted by @sourcery-ai[bot] in #291 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P-highT-bugdependenciesPull requests that update a dependency filePull requests that update a dependency filedocumentationImprovements or additions to documentationImprovements or additions to documentationduplicateThis issue or pull request already existsThis issue or pull request already existsgithub_actionsPull requests that update GitHub Actions codePull requests that update GitHub Actions codegood first issueGood for newcomersGood for newcomersinvalidThis doesn't seem rightThis doesn't seem rightquestionFurther information is requestedFurther information is requestedrustPull requests that update rust codePull requests that update rust code
Projects
Status
Done
Status
Done