Skip to content

Commit

Permalink
feat: implement all_solidity layout (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
TAdev0 authored Sep 6, 2024
1 parent 390afca commit e821f4c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions integration_tests/cairozero_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ func runPythonVm(testFilename, path string) (time.Duration, string, string, erro
args = append(args, "--layout", "recursive_large_output")
} else if strings.HasSuffix(testFilename, ".recursive_with_poseidon.cairo") {
args = append(args, "--layout", "recursive_with_poseidon")
} else if strings.HasSuffix(testFilename, ".all_solidity.cairo") {
args = append(args, "--layout", "all_solidity")
}

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

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 @@ -100,6 +100,17 @@ func getRecursiveWithPoseidonLayout() Layout {
}}
}

func getAllSolidityLayout() Layout {
return Layout{Name: "recursive_with_poseidon", RcUnits: 8, Builtins: []LayoutBuiltin{
{Runner: &Output{}, Builtin: starknet.Output},
{Runner: &Pedersen{ratio: 8}, Builtin: starknet.Pedersen},
{Runner: &RangeCheck{ratio: 8, RangeCheckNParts: 8}, Builtin: starknet.RangeCheck},
{Runner: &ECDSA{ratio: 512}, Builtin: starknet.ECDSA},
{Runner: &Bitwise{ratio: 256}, Builtin: starknet.Bitwise},
{Runner: &EcOp{ratio: 256, cache: make(map[uint64]fp.Element)}, Builtin: starknet.ECOP},
}}
}

func GetLayout(layout string) (Layout, error) {
switch layout {
case "plain":
Expand All @@ -118,6 +129,8 @@ func GetLayout(layout string) (Layout, error) {
return getRecursiveLargeOutputLayout(), nil
case "recursive_with_poseidon":
return getRecursiveWithPoseidonLayout(), nil
case "all_solidity":
return getAllSolidityLayout(), nil
case "":
return getPlainLayout(), nil
default:
Expand Down

0 comments on commit e821f4c

Please sign in to comment.