Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
include:
- os: ubuntu-latest
arch: amd64
- os: macos-15-intel
- os: macos-13
arch: amd64
- os: ubuntu-arm64-4-core
arch: arm64
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/find-smallest-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
branches:
- main
paths:
- docs/docs/running-juno.md
- .github/workflows/find-smallest-rust.yml
- core/rust/*
- vm/rust/*
Expand Down Expand Up @@ -36,7 +35,7 @@ jobs:
with:
script: |
const msrv = '${{ steps.rust-version.outputs.highest-msrv }}'
const previous_msrv = '1.87.0'
const previous_msrv = '1.86.0'

if (msrv != previous_msrv) {
github.rest.issues.createComment({
Expand All @@ -50,7 +49,7 @@ jobs:
- name: "Check README and Makefile"
run: |
set -euxo pipefail
echo "Checking if version is set in docs/docs/running-juno.md"
cat docs/docs/running-juno.md | grep "\[Rust\]" | grep "${{ steps.rust-version.outputs.highest-msrv }}"
echo "Checking if version is set in README"
cat README.md | grep "\[Rust\]" | grep "${{ steps.rust-version.outputs.highest-msrv }}"
echo "Checking makefile"
cat Makefile | grep "MINIMUM_RUST_VERSION = ${{ steps.rust-version.outputs.highest-msrv }}"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# --- Builder stage ---
FROM golang:1.25-bookworm AS builder

ARG RUST_VERSION=1.87.0
ARG RUST_VERSION=1.86.0

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ juno-cached: ## Cached Juno compilation
@go build $(GO_TAGS) -ldflags="-X main.Version=$(shell git describe --tags)" -o build/juno ./cmd/juno/


MINIMUM_RUST_VERSION = 1.87.0
MINIMUM_RUST_VERSION = 1.86.0
CURR_RUST_VERSION = $(shell rustc --version | grep -o '[0-9.]\+' | head -n1)
check-rust: ## Ensure rust version is greater than minimum
@echo "Checking if current rust version >= $(MINIMUM_RUST_VERSION)"
Expand Down
9 changes: 3 additions & 6 deletions adapters/core2sn/class.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ func AdaptCasmClass(coreCasmClass *core.CasmClass) starknet.CasmClass {
feederCompiledClass.CompilerVersion = coreCasmClass.CompilerVersion
feederCompiledClass.Hints = coreCasmClass.Hints
feederCompiledClass.Prime = utils.ToHex(coreCasmClass.Prime)

if coreCasmClass.BytecodeSegmentLengths.Length != 0 ||
len(coreCasmClass.BytecodeSegmentLengths.Children) != 0 {
segmentLengths := AdaptSegmentLengths(coreCasmClass.BytecodeSegmentLengths)
feederCompiledClass.BytecodeSegmentLengths = &segmentLengths
}
feederCompiledClass.BytecodeSegmentLengths = AdaptSegmentLengths(
coreCasmClass.BytecodeSegmentLengths,
)

feederCompiledClass.EntryPoints.External = make(
[]starknet.CompiledEntryPoint,
Expand Down
4 changes: 1 addition & 3 deletions adapters/sn2core/sn2core.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,7 @@ func AdaptCompiledClass(compiledClass *starknet.CasmClass) (*core.CasmClass, err
casm.PythonicHints = compiledClass.PythonicHints
casm.CompilerVersion = compiledClass.CompilerVersion
casm.Hints = compiledClass.Hints
if compiledClass.BytecodeSegmentLengths != nil {
casm.BytecodeSegmentLengths = AdaptSegmentLengths(*compiledClass.BytecodeSegmentLengths)
}
casm.BytecodeSegmentLengths = AdaptSegmentLengths(compiledClass.BytecodeSegmentLengths)

var ok bool
casm.Prime, ok = new(big.Int).SetString(compiledClass.Prime, 0)
Expand Down
78 changes: 3 additions & 75 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/core/state"
"github.com/NethermindEth/juno/core/state/statefactory"

Check failure on line 11 in blockchain/blockchain.go

View workflow job for this annotation

GitHub Actions / lint

File is not properly formatted (gci)
"github.com/NethermindEth/juno/core/trie2/triedb"
"github.com/NethermindEth/juno/db"
"github.com/NethermindEth/juno/feed"
Expand Down Expand Up @@ -251,11 +252,8 @@
}

// Store takes a block and state update and performs sanity checks before putting in the database.
func (b *Blockchain) Store(
block *core.Block,
blockCommitments *core.BlockCommitments,
stateUpdate *core.StateUpdate,
newClasses map[felt.Felt]core.ClassDefinition,
func (b *Blockchain) Store(block *core.Block, blockCommitments *core.BlockCommitments,
stateUpdate *core.StateUpdate, newClasses map[felt.Felt]core.ClassDefinition,
) error {
// old state
// TODO(maksymmalick): remove this once we have a new state implementation
Expand Down Expand Up @@ -304,11 +302,6 @@
return err
}

err := storeCasmClassHashesV2ForBlock(txn, block.ProtocolVersion, newClasses, stateUpdate)
if err != nil {
return err
}

return core.WriteChainHeight(txn, block.Number)
})
if err != nil {
Expand Down Expand Up @@ -371,63 +364,6 @@
return b.runningFilter.Insert(block.EventsBloom, block.Number)
}

// storeCasmClassHashesV2ForBlock stores CASM class hashes V2 based on the block version.
// For versions < 0.14.1, it computes hashes from class definitions.
// For versions >= 0.14.1, it uses pre-computed hashes from the state update.
func storeCasmClassHashesV2ForBlock(
txn db.KeyValueWriter,
protocolVersion string,
newClasses map[felt.Felt]core.ClassDefinition,
stateUpdate *core.StateUpdate,
) error {
ver, err := core.ParseBlockVersion(protocolVersion)
if err != nil {
return err
}
if ver.LessThan(core.Ver0_14_1) {
// Pre-compute blake2s CASM class hashes of declared classes in this block and
// store them in order to avoid computing them during simulation.
return computeAndStoreCasmClassHashesV2(txn, newClasses)
}
return storeCasmClassHashesV2(txn, stateUpdate.StateDiff.DeclaredV1Classes)
}

// computeAndStoreCasmClassHashesV2 computes and stores CASM class hashes V2 from class definitions.
func computeAndStoreCasmClassHashesV2(
txn db.KeyValueWriter,
declaredClasses map[felt.Felt]core.ClassDefinition,
) error {
for classHash, classDefinition := range declaredClasses {
sierraClass, ok := classDefinition.(*core.SierraClass)
if !ok {
// We don't have CASM classes for deprecated Cairo class
continue
}

casmHashV2 := felt.CasmClassHash(sierraClass.Compiled.Hash(core.HashVersionV2))
sierraClassHash := felt.SierraClassHash(classHash)
if err := core.WriteCasmClassHashV2(txn, &sierraClassHash, &casmHashV2); err != nil {
return err
}
}
return nil
}

// storeCasmClassHashesV2 stores pre-computed CASM class hashes V2 from the state update.
func storeCasmClassHashesV2(
txn db.KeyValueWriter,
declaredV1Classes map[felt.Felt]*felt.Felt,
) error {
for classHash, casmClassHashV2 := range declaredV1Classes {
casmHashV2 := felt.CasmClassHash(*casmClassHashV2)
sierraClassHash := felt.SierraClassHash(classHash)
if err := core.WriteCasmClassHashV2(txn, &sierraClassHash, &casmHashV2); err != nil {
return err
}
}
return nil
}

// VerifyBlock assumes the block has already been sanity-checked.
func (b *Blockchain) VerifyBlock(block *core.Block) error {
return verifyBlock(b.database, block)
Expand Down Expand Up @@ -850,10 +786,6 @@
if err := b.storeBlockData(txn, block, stateUpdate, commitments); err != nil {
return err
}
err = storeCasmClassHashesV2ForBlock(txn, block.ProtocolVersion, newClasses, stateUpdate)
if err != nil {
return err
}
return core.WriteChainHeight(txn, block.Number)
})
if err != nil {
Expand All @@ -876,10 +808,6 @@
if err := b.storeBlockData(batch, block, stateUpdate, commitments); err != nil {
return err
}
err = storeCasmClassHashesV2ForBlock(batch, block.ProtocolVersion, newClasses, stateUpdate)
if err != nil {
return err
}
if err := core.WriteChainHeight(batch, block.Number); err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"github.com/NethermindEth/juno/blockchain"
"github.com/NethermindEth/juno/core"
"github.com/NethermindEth/juno/core/felt"

Check failure on line 10 in builder/builder.go

View workflow job for this annotation

GitHub Actions / lint

File is not properly formatted (gci)
"github.com/NethermindEth/juno/mempool"
"github.com/NethermindEth/juno/utils"
"github.com/consensys/gnark-crypto/ecc/stark-curve/ecdsa"
Expand Down
1 change: 1 addition & 0 deletions consensus/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func getBlockchain(
t.Helper()
testDB := memory.New()
network := &utils.Mainnet

bc := blockchain.New(testDB, network, statetestutils.UseNewState())
require.NoError(t, bc.StoreGenesis(&genesisDiff, genesisClasses))
return bc
Expand Down
27 changes: 0 additions & 27 deletions core/accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,30 +557,3 @@ func WriteRunningEventFilter(w db.KeyValueWriter, filter *RunningEventFilter) er

return w.Put(db.RunningEventFilter.Key(), enc)
}

func GetCasmClassHashV2(
r db.KeyValueReader,
classHash *felt.SierraClassHash,
) (felt.CasmClassHash, error) {
var casmClassHash felt.CasmClassHash
err := r.Get(db.ClassHashToCasmHashV2Key(classHash), func(data []byte) error {
casmClassHash.Unmarshal(data)
return nil
})
return casmClassHash, err
}

func WriteCasmClassHashV2(
w db.KeyValueWriter,
classHash *felt.SierraClassHash,
casmClassHash *felt.CasmClassHash,
) error {
return w.Put(db.ClassHashToCasmHashV2Key(classHash), casmClassHash.Marshal())
}

func DeleteCasmClassHashV2(
w db.KeyValueWriter,
classHash *felt.SierraClassHash,
) error {
return w.Delete(db.ClassHashToCasmHashV2Key(classHash))
}
4 changes: 1 addition & 3 deletions core/common_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/NethermindEth/juno/core/felt"
)

//go:generate mockgen -destination=../mocks/mock_common_state.go -package=mocks github.com/NethermindEth/juno/core CommonState
//go:generate mockgen -destination=../../mocks/mock_commonstate_reader.go -package=mocks github.com/NethermindEth/juno/core CommonStateReader
type CommonState interface {
CommonStateReader

Expand Down Expand Up @@ -32,6 +32,4 @@ type CommonStateReader interface {
ClassTrie() (CommonTrie, error)
ContractTrie() (CommonTrie, error)
ContractStorageTrie(addr *felt.Felt) (CommonTrie, error)
CompiledClassHash(classHash *felt.SierraClassHash) (felt.CasmClassHash, error)
CompiledClassHashV2(classHash *felt.SierraClassHash) (felt.CasmClassHash, error)
}
32 changes: 0 additions & 32 deletions core/felt/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ func (h *Hash) MarshalJSON() ([]byte, error) {
return (*Felt)(h).MarshalJSON()
}

func (h *Hash) Marshal() []byte {
return (*Felt)(h).Marshal()
}

func (h *Hash) Unmarshal(e []byte) {
(*Felt)(h).Unmarshal(e)
}

type ClassHash Hash

func (h *ClassHash) String() string {
Expand All @@ -40,14 +32,6 @@ func (h *ClassHash) MarshalJSON() ([]byte, error) {
return (*Hash)(h).MarshalJSON()
}

func (h *ClassHash) Marshal() []byte {
return (*Hash)(h).Marshal()
}

func (h *ClassHash) Unmarshal(e []byte) {
(*Hash)(h).Unmarshal(e)
}

type SierraClassHash ClassHash

func (h *SierraClassHash) String() string {
Expand All @@ -62,14 +46,6 @@ func (h *SierraClassHash) MarshalJSON() ([]byte, error) {
return (*ClassHash)(h).MarshalJSON()
}

func (h *SierraClassHash) Marshal() []byte {
return (*ClassHash)(h).Marshal()
}

func (h *SierraClassHash) Unmarshal(e []byte) {
(*ClassHash)(h).Unmarshal(e)
}

type CasmClassHash ClassHash

func (h *CasmClassHash) String() string {
Expand All @@ -84,14 +60,6 @@ func (h *CasmClassHash) MarshalJSON() ([]byte, error) {
return (*ClassHash)(h).MarshalJSON()
}

func (h *CasmClassHash) Marshal() []byte {
return (*ClassHash)(h).Marshal()
}

func (h *CasmClassHash) Unmarshal(e []byte) {
(*ClassHash)(h).Unmarshal(e)
}

type TransactionHash Hash

func (h *TransactionHash) String() string {
Expand Down
Loading
Loading