Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement recursive_with_poseidon layout #653

Merged
merged 1 commit into from
Sep 5, 2024
Merged
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
4 changes: 4 additions & 0 deletions integration_tests/cairozero_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ func runPythonVm(testFilename, path string) (time.Duration, string, string, erro
args = append(args, "--layout", "small")
} else if strings.HasSuffix(testFilename, ".starknet_with_keccak.cairo") {
args = append(args, "--layout", "starknet_with_keccak")
} else if strings.HasSuffix(testFilename, ".recursive_with_poseidon.cairo") {
args = append(args, "--layout", "recursive_with_poseidon")
}

cmd := exec.Command("cairo-run", args...)
Expand Down Expand Up @@ -323,6 +325,8 @@ func runVm(path string) (time.Duration, string, string, string, error) {
layout = "small"
} else if strings.Contains(path, ".starknet_with_keccak") {
layout = "starknet_with_keccak"
} else if strings.Contains(path, ".recursive_with_poseidon") {
layout = "recursive_with_poseidon"
}

cmd := exec.Command(
Expand Down
13 changes: 13 additions & 0 deletions pkg/vm/builtins/layouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ func getStarknetWithKeccakLayout() Layout {
}}
}

func getRecursiveWithPoseidonLayout() Layout {
return Layout{Name: "recursive_with_poseidon", RcUnits: 4, Builtins: []LayoutBuiltin{
{Runner: &Output{}, Builtin: starknet.Output},
{Runner: &Pedersen{ratio: 256}, Builtin: starknet.Pedersen},
{Runner: &RangeCheck{ratio: 16, RangeCheckNParts: 8}, Builtin: starknet.RangeCheck},
{Runner: &Bitwise{ratio: 16}, Builtin: starknet.Bitwise},
{Runner: &Poseidon{ratio: 64, cache: make(map[uint64]fp.Element)}, Builtin: starknet.Poseidon},
}}
}

// recursive_with_poseidon
func GetLayout(layout string) (Layout, error) {
switch layout {
case "small":
Expand All @@ -58,6 +69,8 @@ func GetLayout(layout string) (Layout, error) {
return getPlainLayout(), nil
case "starknet_with_keccak":
return getStarknetWithKeccakLayout(), nil
case "recursive_with_poseidon":
return getRecursiveWithPoseidonLayout(), nil
case "":
return getPlainLayout(), nil
default:
Expand Down
Loading