Skip to content

Commit

Permalink
feat: implement recursive_large_output layout (#652)
Browse files Browse the repository at this point in the history
recursive_large_output layout
  • Loading branch information
TAdev0 authored Sep 5, 2024
1 parent 39fde50 commit afedafd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions integration_tests/cairozero_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ func runPythonVm(testFilename, path string) (time.Duration, string, string, erro
args = append(args, "--layout", "dex")
} else if strings.HasSuffix(testFilename, ".starknet_with_keccak.cairo") {
args = append(args, "--layout", "starknet_with_keccak")
} else if strings.HasSuffix(testFilename, ".recursive_large_output.cairo") {
args = append(args, "--layout", "recursive_large_output")
} else if strings.HasSuffix(testFilename, ".recursive_with_poseidon.cairo") {
args = append(args, "--layout", "recursive_with_poseidon")
}
Expand Down Expand Up @@ -329,6 +331,8 @@ func runVm(path string) (time.Duration, string, string, string, error) {
layout = "dex"
} else if strings.Contains(path, ".starknet_with_keccak") {
layout = "starknet_with_keccak"
} else if strings.Contains(path, ".recursive_large_output") {
layout = "recursive_large_output"
} else if strings.Contains(path, ".recursive_with_poseidon") {
layout = "recursive_with_poseidon"
}
Expand Down
13 changes: 12 additions & 1 deletion pkg/vm/builtins/layouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ func getStarknetWithKeccakLayout() Layout {
}}
}

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

func getRecursiveWithPoseidonLayout() Layout {
return Layout{Name: "recursive_with_poseidon", RcUnits: 4, Builtins: []LayoutBuiltin{
{Runner: &Output{}, Builtin: starknet.Output},
Expand All @@ -69,7 +79,6 @@ func getRecursiveWithPoseidonLayout() Layout {
}}
}

// recursive_with_poseidon
func GetLayout(layout string) (Layout, error) {
switch layout {
case "plain":
Expand All @@ -80,6 +89,8 @@ func GetLayout(layout string) (Layout, error) {
return getDexLayout(), nil
case "starknet_with_keccak":
return getStarknetWithKeccakLayout(), nil
case "recursive_large_output":
return getRecursiveLargeOutputLayout(), nil
case "recursive_with_poseidon":
return getRecursiveWithPoseidonLayout(), nil
case "":
Expand Down

0 comments on commit afedafd

Please sign in to comment.