Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/with-docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
&& rustup target add wasm32-unknown-unknown \
&& rustup target add wasm32v1-none

RUN cargo install --locked stellar-cli
RUN cargo install --locked stellar-cli@23.1.4
10 changes: 10 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@
(finalPython: prevPython: {
kframework = k-framework.packages.${system}.pyk-python310;
pykwasm = wasm-semantics.packages.${system}.kwasm-pyk;
# override numpy on Darwin to avoid the missing dynamic library issue
numpy = if pkgs.stdenv.isDarwin
then
prevPython.numpy.overrideAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [ pkgs.Accelerate ];
NPY_BLAS_ORDER = "accelerate";
NPY_LAPACK_ORDER = "accelerate";
})
else
prevPython.numpy;
});
groups = [ ];
checkGroups = [ ];
Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.72
0.1.73
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "komet"
version = "0.1.72"
version = "0.1.73"
description = "K tooling for the Soroban platform"
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
3 changes: 2 additions & 1 deletion src/komet/kasmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
)
from .proof import is_functional, run_claim, run_functional_claim
from .scval import SCType
from .utils import KSorobanError, concrete_definition
from .utils import KSorobanError, concrete_definition, subst_on_program_cell

if TYPE_CHECKING:
from collections.abc import Iterable, Mapping
Expand Down Expand Up @@ -248,6 +248,7 @@ def scval_to_kore(val: SCValue) -> Pattern:
check_exit_code=True,
max_examples=max_examples,
handler=KometFuzzHandler(self.definition, task),
subst_func=subst_on_program_cell,
)

def run_prove(
Expand Down
31 changes: 31 additions & 0 deletions src/komet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@
from pyk.kast.outer import KRule, read_kast_definition
from pyk.kdist import kdist
from pyk.konvert import kast_to_kore
from pyk.kore.manip import substitute_vars
from pyk.kore.prelude import generated_top
from pyk.kore.syntax import App
from pyk.ktool.kompile import DefinitionInfo
from pyk.ktool.kprove import KProve
from pyk.ktool.krun import KRun
from pyk.utils import single

if TYPE_CHECKING:
from collections.abc import Mapping
from pathlib import Path
from subprocess import CompletedProcess
from typing import Any, Final

from pyk.kast.inner import KInner, KSort
from pyk.kast.outer import KDefinition, KFlatModule
from pyk.kore.syntax import EVar, Pattern
from pyk.ktool.kompile import KompileBackend

_LOGGER: Final = logging.getLogger(__name__)
Expand Down Expand Up @@ -92,3 +97,29 @@ def parse_lemmas_module(self, module_path: Path, module_name: str) -> KFlatModul
concrete_definition = SorobanDefinition(kdist.get('soroban-semantics.llvm'))
library_definition = SorobanDefinition(kdist.get('soroban-semantics.llvm-library'))
symbolic_definition = SorobanDefinition(kdist.get('soroban-semantics.haskell'))


def subst_on_program_cell(template: Pattern, subst_case: Mapping[EVar, Pattern]) -> Pattern:
"""A substitution function that only applies substitutions within the K cell.
Optimizing the fuzzer by restricting changes to relevant parts of the configuration.

Args:
template: The template configuration containing variables in the K cell.
subst_case: A mapping from variables to their replacement patterns.
"""

def kasmer_cell(program_cell: Pattern, soroban_cell: Pattern, exit_code_cell: Pattern) -> Pattern:
return App("Lbl'-LT-'kasmer'-GT-'", args=(program_cell, soroban_cell, exit_code_cell))

match template:
case App(
"Lbl'-LT-'generatedTop'-GT-'",
args=(
App("Lbl'-LT-'kasmer'-GT-'", args=(program_cell, soroban_cell, exit_code_cell)),
generated_counter_cell,
),
):
program_cell_ = substitute_vars(program_cell, subst_case)
return generated_top((kasmer_cell(program_cell_, soroban_cell, exit_code_cell), generated_counter_cell))

raise ValueError(template)
Loading