Skip to content

Commit

Permalink
comment: feltOne, function signature
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Jan 21, 2025
1 parent c93213c commit 82064bd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
7 changes: 3 additions & 4 deletions adapters/vm2core/vm2core.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ func AdaptOrderedEvents(events []vm.OrderedEvent) []*core.Event {
return utils.Map(events, AdaptOrderedEvent)
}

func AdaptStateDiff(trace *vm.TransactionTrace) *core.StateDiff {
if trace.StateDiff == nil {
return nil
func AdaptStateDiff(stateDiff *vm.StateDiff) *core.StateDiff {
if stateDiff == nil {
return core.EmptyStateDiff()
}

Check warning on line 47 in adapters/vm2core/vm2core.go

View check run for this annotation

Codecov / codecov/patch

adapters/vm2core/vm2core.go#L46-L47

Added lines #L46 - L47 were not covered by tests
stateDiff := trace.StateDiff
newStorageDiffs := make(map[felt.Felt]map[felt.Felt]*felt.Felt, len(stateDiff.StorageDiffs))
for _, sd := range stateDiff.StorageDiffs {
entries := make(map[felt.Felt]*felt.Felt)
Expand Down
2 changes: 1 addition & 1 deletion genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func GenesisStateDiff( //nolint:funlen,gocyclo
return nil, nil, fmt.Errorf("execute function call: %v", err)
}

Check warning on line 210 in genesis/genesis.go

View check run for this annotation

Codecov / codecov/patch

genesis/genesis.go#L209-L210

Added lines #L209 - L210 were not covered by tests

traceSD := vm2core.AdaptStateDiff(&trace[0])
traceSD := vm2core.AdaptStateDiff(trace[0].StateDiff)
genesisSD, _ := genesisState.StateDiffAndClasses()
genesisSD.Merge(traceSD)
genesisState.SetStateDiff(genesisSD)
Expand Down
5 changes: 3 additions & 2 deletions sync/pending.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/NethermindEth/juno/db"
)

var feltOne = new(felt.Felt).SetUint64(1)

type Pending struct {
Block *core.Block
StateUpdate *core.StateUpdate
Expand Down Expand Up @@ -97,8 +99,7 @@ func (p *PendingStateWriter) IncrementNonce(contractAddress *felt.Felt) error {
if err != nil {
return fmt.Errorf("get contract nonce: %v", err)
}
newNonce := new(felt.Felt).SetUint64(1)
p.stateDiff.Nonces[*contractAddress] = newNonce.Add(currentNonce, newNonce)
p.stateDiff.Nonces[*contractAddress] = currentNonce.Add(currentNonce, feltOne)
return nil

Check warning on line 103 in sync/pending.go

View check run for this annotation

Codecov / codecov/patch

sync/pending.go#L97-L103

Added lines #L97 - L103 were not covered by tests
}

Expand Down

0 comments on commit 82064bd

Please sign in to comment.