Skip to content

Commit

Permalink
Address comments in the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksymMalicki committed Jan 9, 2025
1 parent 688b3d2 commit f105506
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion integration_tests/cairo_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func TestCairoFiles(t *testing.T) {
{"./cairo_zero_hint_tests/", true},
{"./cairo_zero_file_tests/", true},
{"./builtin_tests/", true},
{"./cairo_1_programs/", false},
// {"./cairo_1_programs/", false},
}

// filter is for debugging purposes
Expand Down
1 change: 1 addition & 0 deletions pkg/hintrunner/hintrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func NewHintRunner(hints map[uint64][]h.Hinter, userArgs []starknet.CairoFuncArg
context := *h.InitializeDefaultContext()
if userArgs != nil {
err := context.ScopeManager.AssignVariable("userArgs", userArgs)
// Error handling: this condition should never be true, since the context was initialized above
if err != nil {
panic(fmt.Errorf("assign userArgs: %v", err))
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/runner/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ import (
"fmt"

"github.com/NethermindEth/cairo-vm-go/pkg/vm"
"github.com/NethermindEth/cairo-vm-go/pkg/vm/memory"
mem "github.com/NethermindEth/cairo-vm-go/pkg/vm/memory"
)

type TokenGasCost uint8

const (
ConstToken TokenGasCost = iota + 1
HoleToken
RangeCheckToken
RangeCheck96Token
PedersenToken
PoseidonToken
BitwiseToken
Expand All @@ -23,6 +19,8 @@ const (
MulModToken
)

// Approximated costs token types
// Src: https://github.com/starkware-libs/cairo/blob/9ac17df38f28f267e03a6522d12031976a66d305/crates/cairo-lang-runner/src/lib.rs#L109
func getTokenGasCost(token TokenGasCost) (uint64, error) {
switch token {
case ConstToken:
Expand All @@ -44,7 +42,7 @@ func getTokenGasCost(token TokenGasCost) (uint64, error) {
}
}

func gasInitialization(memory *memory.Memory) error {
func gasInitialization(memory *mem.Memory) error {
builtinsCostSegmentAddress := memory.AllocateEmptySegment()
mv := mem.MemoryValueFromMemoryAddress(&builtinsCostSegmentAddress)
programSegment := memory.Segments[vm.ProgramSegment]
Expand Down
11 changes: 0 additions & 11 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,6 @@ func GetEntryCodeInstructions(function starknet.EntryPointByFunction, finalizeFo
builtinOffset := 3
codeOffset := uint64(function.Offset)
builtinsOffsetsMap := map[builtins.BuiltinType]int{}
emulatedBuiltins := map[builtins.BuiltinType]struct{}{
builtins.SystemType: {},
}

for _, builtin := range []builtins.BuiltinType{
builtins.MulModType,
Expand Down Expand Up @@ -557,14 +554,6 @@ func GetEntryCodeInstructions(function starknet.EntryPointByFunction, finalizeFo
fmt.Sprintf("[ap + 0] = [fp - %d], ap++;", offset),
)
apOffset += 1
} else if _, emulated := emulatedBuiltins[builtin]; emulated {
ctx.AddInlineCASM(
`
%{ memory[ap + 0] = segments.add() %}
ap += 1;
`,
)
apOffset += 1
} else if builtin == builtins.SegmentArenaType {
offset := apOffset - paramsSize
ctx.AddInlineCASM(
Expand Down

0 comments on commit f105506

Please sign in to comment.