Skip to content
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
12 changes: 12 additions & 0 deletions .github/workflows/juno-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,15 @@ jobs:
version: latest
args: --config=./.golangci_diff.yaml
only-new-issues: true
# Both passes again with the compact felt codec built in; only core/felt differs under the tag
- name: golangci-lint (compactfelt)
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: latest
args: --build-tags compactfelt ./core/felt/...
- name: golangci-lint-diffs (compactfelt)
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: latest
args: --config=./.golangci_diff.yaml --build-tags compactfelt
only-new-issues: true
3 changes: 3 additions & 0 deletions .github/workflows/juno-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ jobs:
FULL_TESTS: ${{ github.event_name != 'pull_request' || steps.filter.outputs.consensus == 'true' }}
run: make test

- name: Tests (compact felt codec)
run: make test-compactfelt

# Tests with race condition detector are flaky; we're disabling them for now
# - name: Tests (Race Detection)
# if: matrix.os == 'ubuntu-latest'
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

ifeq ($(VM_DEBUG),true)
GO_TAGS = -tags vm_debug
COMPACTFELT_GO_TAGS = -tags vm_debug,compactfelt
VM_TARGET = debug
else
GO_TAGS =
COMPACTFELT_GO_TAGS = -tags compactfelt
VM_TARGET = all
endif

Expand Down Expand Up @@ -87,6 +89,9 @@ test-new-state: clean-testcache rustdeps ## Run tests with new state
test-cached: rustdeps ## Run cached tests
go test $(GO_TAGS) $(TEST_MODE_FLAGS) ./...

test-compactfelt: rustdeps ## Run tests with the compact felt codec built in
go test $(COMPACTFELT_GO_TAGS) $(TEST_MODE_FLAGS) ./...

test-race: clean-testcache rustdeps ## Run tests with race detection
go test $(GO_TAGS) $(TEST_MODE_FLAGS) ./... -race $(TEST_RACE_LDFLAGS)

Expand All @@ -113,11 +118,13 @@ install-golangci-lint:
install-k6: ## Install the k6 load generator used by the RPC benchmark harness
go install go.k6.io/k6@latest

lint: install-golangci-lint lint-diff
lint: install-golangci-lint lint-diff ## Lint the regular build, then core/felt with the compact felt codec
golangci-lint run
golangci-lint run --build-tags compactfelt ./core/felt/...

lint-diff:
lint-diff: ## Lint changes vs origin/main in both the regular and the compact felt build
golangci-lint run --config=./.golangci_diff.yaml --new-from-rev=origin/main
golangci-lint run --config=./.golangci_diff.yaml --new-from-rev=origin/main --build-tags compactfelt

tidy: ## Add missing and remove unused modules
go mod tidy
Expand Down
16 changes: 7 additions & 9 deletions core/deprecatedstate/accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,28 @@ func GetContractClassHash(r db.KeyValueReader, addr *felt.Felt) (felt.Felt, erro
var classHash felt.Felt
//nolint:staticcheck,nolintlint // old state layout
err := r.Get(db.DeprecatedContractClassHashKey(addr), func(data []byte) error {
classHash.SetBytes(data)
return nil
return classHash.SetMinimalBytes(data)
})
return classHash, err
}

func WriteContractClassHash(w db.KeyValueWriter, addr, classHash *felt.Felt) error {
//nolint:staticcheck,nolintlint // old state layout
return w.Put(db.DeprecatedContractClassHashKey(addr), classHash.Marshal())
return w.Put(db.DeprecatedContractClassHashKey(addr), classHash.StoredBytes())
}

func GetContractNonce(r db.KeyValueReader, addr *felt.Felt) (felt.Felt, error) {
var nonce felt.Felt
//nolint:staticcheck,nolintlint // old state layout
err := r.Get(db.DeprecatedContractNonceKey(addr), func(data []byte) error {
nonce.SetBytes(data)
return nil
return nonce.SetMinimalBytes(data)
})
return nonce, err
}

func WriteContractNonce(w db.KeyValueWriter, addr, nonce *felt.Felt) error {
//nolint:staticcheck,nolintlint // old state layout
return w.Put(db.DeprecatedContractNonceKey(addr), nonce.Marshal())
return w.Put(db.DeprecatedContractNonceKey(addr), nonce.StoredBytes())
Comment thread
EgeCaner marked this conversation as resolved.
Resolved
}

func WriteContractDeploymentHeight(w db.KeyValueWriter, addr *felt.Felt, height uint64) error {
Expand Down Expand Up @@ -72,7 +70,7 @@ func WriteContractStorageHistory(
) error {
//nolint:staticcheck,nolintlint // old state layout
key := db.DeprecatedContractStorageHistoryAtBlockKey(contractAddress, storageLocation, height)
return w.Put(key, oldValue.Marshal())
return w.Put(key, oldValue.StoredBytes())
}

// DeleteContractStorageHistory deletes the history at the given height
Expand All @@ -97,7 +95,7 @@ func WriteContractNonceHistory(
) error {
//nolint:staticcheck,nolintlint // old state layout
key := db.DeprecatedContractNonceHistoryAtBlockKey(contractAddress, height)
return w.Put(key, oldValue.Marshal())
return w.Put(key, oldValue.StoredBytes())
}

// DeleteContractNonceHistory deletes the history at the given height
Expand All @@ -119,7 +117,7 @@ func WriteContractClassHashHistory(
) error {
//nolint:staticcheck,nolintlint // old state layout
key := db.DeprecatedContractClassHashHistoryAtBlockKey(contractAddress, height)
return w.Put(key, oldValue.Marshal())
return w.Put(key, oldValue.StoredBytes())
}

func DeleteContractClassHashHistory(
Expand Down
4 changes: 2 additions & 2 deletions core/deprecatedstate/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (c *ContractUpdater) Purge() error {
func (c *ContractUpdater) UpdateNonce(nonce *felt.Felt) error {
//nolint:staticcheck,nolintlint // old state layout
nonceKey := db.DeprecatedContractNonceKey(c.Address)
return c.txn.Put(nonceKey, nonce.Marshal())
return c.txn.Put(nonceKey, nonce.StoredBytes())
}

// ContractRoot returns the root of the contract storage.
Expand Down Expand Up @@ -157,7 +157,7 @@ func ContractStorage(addr, key *felt.Felt, txn db.IndexedBatch) (felt.Felt, erro
//nolint:staticcheck // Necessary for old state
func setClassHash(txn db.IndexedBatch, addr, classHash *felt.Felt) error {
classHashKey := db.DeprecatedContractClassHashKey(addr)
return txn.Put(classHashKey, classHash.Marshal())
return txn.Put(classHashKey, classHash.StoredBytes())
}

// Replace replaces the class that the contract instantiates
Expand Down
6 changes: 3 additions & 3 deletions core/deprecatedstate/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ func (s *State) ContractStorageAt(
return felt.Felt{}, err
}

return felt.FromBytes[felt.Felt](value), nil
return felt.FromMinimalBytes[felt.Felt](value)
}

// ContractStorageLastUpdatedAt returns the block number at which a given storage
Expand All @@ -923,7 +923,7 @@ func (s *State) ContractNonceAt(
if err != nil {
return felt.Felt{}, err
}
return felt.FromBytes[felt.Felt](value), nil
return felt.FromMinimalBytes[felt.Felt](value)
}

func (s *State) ContractClassHashAt(
Expand All @@ -936,7 +936,7 @@ func (s *State) ContractClassHashAt(
return felt.Felt{}, err
}

return felt.FromBytes[felt.Felt](value), nil
return felt.FromMinimalBytes[felt.Felt](value)
}

func (s *State) CompiledClassHashAt(
Expand Down
Loading
Loading