Skip to content

Commit

Permalink
merge main - wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Oct 17, 2024
1 parent 8441202 commit 11b3c3b
Show file tree
Hide file tree
Showing 68 changed files with 1,888 additions and 1,043 deletions.
49 changes: 32 additions & 17 deletions .github/workflows/ci-cd-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: CI/CD pipeline
env:
DOCKER_REGISTRY: nethermind.jfrog.io

REPO_DEV: nubia-docker-local-dev
REPO_STAGING: nubia-docker-local-staging
REPO_PROD: nubia-docker-local-prod
REPO_DEV: nubia-oci-local-dev
REPO_STAGING: nubia-oci-local-staging
REPO_PROD: nubia-oci-local-prod


on:
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
# This one is to be able to use the image tag in the next steps in this job
echo "DOCKER_IMAGE_TAG=$DOCKER_IMAGE_TAG" >> $GITHUB_ENV
# This one is to be able to use the image tag in the next jobs
# This one is to be able to use the image tag in the next jobs
echo "DOCKER_IMAGE_TAG=$DOCKER_IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Setup Docker Buildx
Expand Down Expand Up @@ -93,6 +93,12 @@ jobs:
TEST_ACCOUNT_ADDRESS: ${{ secrets.TEST_ACCOUNT_ADDRESS }}
TEST_ACCOUNT_PRIVATE_KEY: ${{ secrets.TEST_ACCOUNT_PRIVATE_KEY }}

dev-starknet-go-tests:
needs: [validate_dev]
uses: ./.github/workflows/starknet-go-tests.yml
secrets:
TEST_RPC_URL: ${{ secrets.DEV_SEPOLIA_URL }}/v0_7

promote_to_staging:
needs: [build_docker_image, validate_dev]
runs-on: ubuntu-latest
Expand All @@ -102,23 +108,19 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup oras cli
uses: oras-project/setup-oras@v1

- name: Login to registry
run: |
docker login ${{ env.DOCKER_REGISTRY }} -u ${{ secrets.ARTIFACTORY_NUBIA_USERNAME }} -p ${{ secrets.ARTIFACTORY_NUBIA_TOKEN_DEVELOPER }}
oras login ${{ env.DOCKER_REGISTRY }} -u ${{ secrets.ARTIFACTORY_NUBIA_USERNAME }} -p ${{ secrets.ARTIFACTORY_NUBIA_TOKEN_DEVELOPER }}
- name: Promote to Staging
run: |
OLD_TAG=${{ env.DOCKER_REGISTRY }}/${{ env.REPO_DEV }}/juno:${{ needs.build_docker_image.outputs.DOCKER_IMAGE_TAG }}
NEW_TAG=${{ env.DOCKER_REGISTRY }}/${{ env.REPO_STAGING }}/juno:${{ needs.build_docker_image.outputs.DOCKER_IMAGE_TAG }}
LATEST_TAG=${{ env.DOCKER_REGISTRY }}/${{ env.REPO_STAGING }}/juno:latest
docker pull $OLD_TAG
docker tag $OLD_TAG $NEW_TAG
docker push $NEW_TAG
docker tag $OLD_TAG $LATEST_TAG
docker push $LATEST_TAG
oras cp -r $OLD_TAG $NEW_TAG,latest
- name: Verify Deployment Version (Staging)
run: |
bash .github/workflow-scripts/verify_deployment.sh ${{ secrets.STAGING_SEPOLIA_URL }} ${{ needs.build_docker_image.outputs.DOCKER_IMAGE_TAG }}
Expand All @@ -137,24 +139,31 @@ jobs:
TEST_ACCOUNT_ADDRESS: ${{ secrets.TEST_ACCOUNT_ADDRESS }}
TEST_ACCOUNT_PRIVATE_KEY: ${{ secrets.TEST_ACCOUNT_PRIVATE_KEY }}

staging-starknet-go-tests:
needs: [promote_to_staging]
uses: ./.github/workflows/starknet-go-tests.yml
secrets:
TEST_RPC_URL: ${{ secrets.STAGING_SEPOLIA_URL }}/v0_7

promote_to_production:
needs: [build_docker_image, promote_to_staging]
runs-on: ubuntu-latest
environment:
name: Production
steps:
- name: Setup oras cli
uses: oras-project/setup-oras@v1

- name: Login to registry
run: |
docker login ${{ env.DOCKER_REGISTRY }} -u ${{ secrets.ARTIFACTORY_NUBIA_USERNAME }} -p ${{ secrets.ARTIFACTORY_NUBIA_TOKEN_DEVELOPER }}
oras login ${{ env.DOCKER_REGISTRY }} -u ${{ secrets.ARTIFACTORY_NUBIA_USERNAME }} -p ${{ secrets.ARTIFACTORY_NUBIA_TOKEN_DEVELOPER }}
- name: Promote to Production
run: |
OLD_TAG=${{ env.DOCKER_REGISTRY }}/${{ env.REPO_STAGING }}/juno:${{ needs.build_docker_image.outputs.DOCKER_IMAGE_TAG }}
NEW_TAG=${{ env.DOCKER_REGISTRY }}/${{ env.REPO_PROD }}/juno:${{ needs.build_docker_image.outputs.DOCKER_IMAGE_TAG }}
docker pull $OLD_TAG
docker tag $OLD_TAG $NEW_TAG
docker push $NEW_TAG
oras cp -r $OLD_TAG $NEW_TAG,latest
test_in_production:
needs: [promote_to_production]
Expand All @@ -179,3 +188,9 @@ jobs:
TEST_RPC_URL: ${{ secrets.PROD_SEPOLIA_URL }}/v0_7
TEST_ACCOUNT_ADDRESS: ${{ secrets.TEST_ACCOUNT_ADDRESS }}
TEST_ACCOUNT_PRIVATE_KEY: ${{ secrets.TEST_ACCOUNT_PRIVATE_KEY }}

prod-starknet-go-tests:
needs: [test_in_production]
uses: ./.github/workflows/starknet-go-tests.yml
secrets:
TEST_RPC_URL: ${{ secrets.PROD_SEPOLIA_URL }}/v0_7
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 #v4.2.0

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@5618c9fc1e675841ca52c1c6b1304f5255a905a0 #v2.19.0
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -53,7 +53,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@5618c9fc1e675841ca52c1c6b1304f5255a905a0 #v2.19.0

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -67,4 +67,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@5618c9fc1e675841ca52c1c6b1304f5255a905a0 #v2.19.0
19 changes: 16 additions & 3 deletions .github/workflows/find-smallest-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ on:
- .github/workflows/find-smallest-rust.yml
- core/rust/*
- vm/rust/*
- starknet/rust/*
- starknet/compiler/rust/*
workflow_dispatch:


permissions:
issues: write # Required for sending comments
pull-requests: write # Required for sending comments

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -24,7 +29,7 @@ jobs:
id: rust-version
uses: derrix060/detect-rust-minimum-version@v1
with:
paths: core/rust/,vm/rust/,starknet/rust/
paths: core/rust/,vm/rust/,starknet/compiler/rust/
- name: Send notification on PR
uses: actions/github-script@v7
with:
Expand All @@ -37,6 +42,14 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Minimum supported Rust version is `' + msrv + '`, previous `' + previous_msrv + '`. Please update the README file and this workflow.'
body: 'Minimum supported Rust version is `' + msrv + '`, previous `' + previous_msrv + '`. Please update the README file, the Makefile, and this workflow.'
})
}
- name: "Check README and Makefile"
run: |
set -euxo pipefail
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 .github/workflows/juno-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
workspaces: |
vm/rust
core/rust
starknet/rust
starknet/compiler/rust
- name: Install deps
run: make install-deps
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/starknet-go-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: starknet-go tests

on:
workflow_call:
inputs:
ref:
description: 'The branch, tag or SHA to checkout'
required: false
default: 'v0.7.2'
type: string
secrets:
TEST_RPC_URL:
required: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
with:
repository: NethermindEth/starknet.go
ref: ${{ inputs.ref }}

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

- name: Install dependencies
run: go mod download

- name: Test RPC on testnet
run: cd rpc && go test -timeout 1200s -v -env testnet .
env:
INTEGRATION_BASE: ${{ secrets.TEST_RPC_URL }}
39 changes: 24 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ endif
ifeq ($(shell uname -s),Darwin)
export CGO_LDFLAGS=-framework Foundation -framework SystemConfiguration

# Set macOS deployment target in order to avoid linker warnings linke
# "ld: warning: object file XX was built for newer macOS version (14.4) than being linked (14.0)"
# Set macOS deployment target in order to avoid linker warnings linke
# "ld: warning: object file XX was built for newer macOS version (14.4) than being linked (14.0)"
export MACOSX_DEPLOYMENT_TARGET=$(shell sw_vers --productVersion)

# for test-race we need to pass -ldflags to fix linker warnings on macOS
Expand All @@ -31,7 +31,7 @@ endif

MAKEFLAGS += -j$(NPROCS)

rustdeps: vm core-rust compiler
rustdeps: check-rust vm core-rust compiler

juno: rustdeps ## compile
@mkdir -p build
Expand All @@ -41,14 +41,21 @@ juno-cached:
@mkdir -p build
@go build $(GO_TAGS) -ldflags="-X main.Version=$(shell git describe --tags)" -o build/juno ./cmd/juno/


MINIMUM_RUST_VERSION = 1.80.1
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)"
@bash -c '[[ $(CURR_RUST_VERSION) < $(MINIMUM_RUST_VERSION) ]] && (echo "Rust version must be >= $(MINIMUM_RUST_VERSION). Found version $(CURR_RUST_VERSION)" && exit 1) || echo "Current rust version is $(CURR_RUST_VERSION)"'

vm:
$(MAKE) -C vm/rust $(VM_TARGET)

core-rust:
$(MAKE) -C core/rust $(VM_TARGET)

compiler:
$(MAKE) -C starknet/rust $(VM_TARGET)
$(MAKE) -C starknet/compiler/rust $(VM_TARGET)

generate: ## generate
mkdir -p mocks
Expand All @@ -74,7 +81,7 @@ test-cover: clean-testcache rustdeps ## tests with coverage
go test $(GO_TAGS) -coverpkg=./... -coverprofile=coverage/coverage.out -covermode=atomic ./...
go tool cover -html=coverage/coverage.out -o coverage/coverage.html

install-deps: | install-gofumpt install-mockgen install-golangci-lint## install some project dependencies
install-deps: | install-gofumpt install-mockgen install-golangci-lint check-rust ## install some project dependencies

install-gofumpt:
go install mvdan.cc/gofumpt@latest
Expand All @@ -94,13 +101,13 @@ tidy: ## add missing and remove unused modules
format: ## run go & rust formatters
$(MAKE) -C vm/rust format
$(MAKE) -C core/rust format
$(MAKE) -C starknet/rust format
$(MAKE) -C starknet/compiler/rust format
gofumpt -l -w .

clean: ## clean project builds
$(MAKE) -C vm/rust clean
$(MAKE) -C core/rust clean
$(MAKE) -C starknet/rust clean
$(MAKE) -C starknet/compiler/rust clean
@rm -rf ./build

help: ## show this help
Expand All @@ -115,7 +122,6 @@ feedernode: juno-cached
--p2p-feeder-node \
--p2p-addr=/ip4/0.0.0.0/tcp/7777 \
--p2p-private-key="5f6cdc3aebcc74af494df054876100368ef6126e3a33fa65b90c765b381ffc37a0a63bbeeefab0740f24a6a38dabb513b9233254ad0020c721c23e69bc820089" \
--metrics-port=9090

node1: juno-cached
./build/juno \
Expand Down Expand Up @@ -194,10 +200,13 @@ sequencer-shadow-sepolia:

pathfinder: juno-cached
./build/juno \
--network=sepolia \
--log-level=debug \
--db-path=./p2p-dbs/node-pathfinder \
--p2p \
--p2p-peers=/ip4/127.0.0.1/tcp/8888/p2p/12D3KooWF1JrZWQoBiBSjsFSuLbDiDvqcmJQRLaFQLmpVkHA9duk \
--p2p-private-key="54a695e2a5d5717d5ba8730efcafe6f17251a1955733cffc55a4085fbf7f5d2c1b4009314092069ef7ca9b364ce3eb3072531c64dfb2799c6bad76720a5bdff0" \
--metrics-port=9094
--network=sepolia \
--log-level=debug \
--db-path=./p2p-dbs/node-pathfinder \
--p2p \
--p2p-peers=/ip4/127.0.0.1/tcp/8888/p2p/12D3KooWF1JrZWQoBiBSjsFSuLbDiDvqcmJQRLaFQLmpVkHA9duk \
--p2p-private-key="54a695e2a5d5717d5ba8730efcafe6f17251a1955733cffc55a4085fbf7f5d2c1b4009314092069ef7ca9b364ce3eb3072531c64dfb2799c6bad76720a5bdff0" \
--metrics-port=9094

test-fuzz: ## run fuzzing script
./scripts/fuzz_all.sh
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Use the provided snapshots to quickly sync your Juno node with the current state
| ------- | ------------- |
| **>=v0.9.2** | [**juno_sepolia.tar**](https://juno-snapshots.nethermind.dev/files/sepolia/latest) |
## Sepolia-Integration
#### Sepolia-Integration
| Version | Download Link |
| ------- | ------------- |
Expand Down Expand Up @@ -228,6 +228,7 @@ After following these steps, Juno should be up and running on your machine, util
- Starknet state construction and storage using a path-based Merkle Patricia trie.
- Feeder gateway synchronisation of Blocks, Transactions, Receipts, State Updates and Classes.
- Block and Transaction hash verification.
- Plugins

## 🛣 Roadmap

Expand Down
3 changes: 2 additions & 1 deletion adapters/p2p2core/class.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/p2p/starknet/spec"
"github.com/NethermindEth/juno/starknet"
"github.com/NethermindEth/juno/starknet/compiler"
"github.com/NethermindEth/juno/utils"
)

Expand Down Expand Up @@ -110,7 +111,7 @@ func createCompiledClass(cairo1 *spec.Cairo1Class) (*core.CompiledClass, error)
Version: cairo1.ContractClassVersion,
}

compiledClass, err := starknet.Compile(def)
compiledClass, err := compiler.Compile(def)
if err != nil {
return nil, err
}
Expand Down
20 changes: 18 additions & 2 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,23 @@ func (b *Blockchain) RevertHead() error {
return b.database.Update(b.revertHead)
}

func (b *Blockchain) GetReverseStateDiff() (*core.StateDiff, error) {
var reverseStateDiff *core.StateDiff
return reverseStateDiff, b.database.View(func(txn db.Transaction) error {
blockNumber, err := chainHeight(txn)
if err != nil {
return err
}
stateUpdate, err := stateUpdateByNumber(txn, blockNumber)
if err != nil {
return err
}
state := core.NewState(txn)
reverseStateDiff, err = state.GetReverseStateDiff(blockNumber, stateUpdate.StateDiff)
return err
})
}

func (b *Blockchain) revertHead(txn db.Transaction) error {
blockNumber, err := chainHeight(txn)
if err != nil {
Expand All @@ -847,7 +864,7 @@ func (b *Blockchain) revertHead(txn db.Transaction) error {

state := core.NewState(txn)
// revert state
if err = state.Revert(blockNumber, stateUpdate.StateDiff); err != nil {
if err = state.Revert(blockNumber, stateUpdate); err != nil {
return err
}

Expand Down Expand Up @@ -883,7 +900,6 @@ func (b *Blockchain) revertHead(txn db.Transaction) error {
}

// Revert chain height and pending.

if genesisBlock {
if err = txn.Delete(db.Pending.Key()); err != nil {
return err
Expand Down
Loading

0 comments on commit 11b3c3b

Please sign in to comment.