mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
Update EVM
This commit is contained in:
@@ -3,3 +3,22 @@
|
||||
set -euo pipefail
|
||||
|
||||
go run github.com/rhysd/actionlint/cmd/[email protected] "${@}"
|
||||
|
||||
echo "Checking use of scripts/* in GitHub Actions workflows..."
|
||||
SCRIPT_USAGE=
|
||||
for file in .github/workflows/*.{yml,yaml}; do
|
||||
# Skip if no matches found (in case one of the extensions doesn't exist)
|
||||
[[ -f "$file" ]] || continue
|
||||
|
||||
# Search for scripts/* except for scripts/run_task.sh
|
||||
MATCHES=$(grep -H -n -P "scripts/(?!run_task\.sh)" "$file" || true)
|
||||
if [[ -n "${MATCHES}" ]]; then
|
||||
echo "${MATCHES}"
|
||||
SCRIPT_USAGE=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -n "${SCRIPT_USAGE}" ]]; then
|
||||
echo "Error: the lines listed above must be converted to use scripts/run_task.sh to ensure local reproducibility."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
+7
-7
@@ -5,23 +5,23 @@ set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
# Root directory
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
|
||||
# Load the constants
|
||||
source "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
BINARY_PATH=$1
|
||||
elif [[ $# -eq 0 ]]; then
|
||||
BINARY_PATH="$GOPATH/src/github.com/luxfi/node/build/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy"
|
||||
BINARY_PATH="$DEFAULT_PLUGIN_DIR/$DEFAULT_VM_ID"
|
||||
else
|
||||
echo "Invalid arguments to build evm. Requires zero (default location) or one argument to specify binary location."
|
||||
echo "Invalid arguments to build evm. Requires zero (default binary path) or one argument to specify the binary path."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build Lux EVM, which is run as a subprocess
|
||||
echo "Building Lux EVM @ GitCommit: $SUBNET_EVM_COMMIT at $BINARY_PATH"
|
||||
go build -ldflags "-X github.com/luxfi/evm/plugin/evm.GitCommit=$SUBNET_EVM_COMMIT $STATIC_LD_FLAGS" -o "$BINARY_PATH" "plugin/"*.go
|
||||
# Build Subnet EVM, which is run as a subprocess
|
||||
echo "Building Subnet EVM @ GitCommit: $EVM_COMMIT at $BINARY_PATH"
|
||||
go build -ldflags "-X github.com/luxfi/evm/plugin/evm.GitCommit=$EVM_COMMIT $STATIC_LD_FLAGS" -o "$BINARY_PATH" "plugin/"*.go
|
||||
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Builds docker images for antithesis testing.
|
||||
|
||||
# e.g.,
|
||||
# ./scripts/build_antithesis_images.sh # Build local images
|
||||
# IMAGE_PREFIX=<registry>/<repo> IMAGE_TAG=latest ./scripts/build_antithesis_images.sh # Specify a prefix to enable image push and use a specific tag
|
||||
|
||||
# Directory above this script
|
||||
EVM_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
|
||||
|
||||
# Assume it's necessary to build the luxd node image from source
|
||||
# TODO(marun) Support use of a released node image if using a release version of luxd
|
||||
|
||||
source "${EVM_PATH}"/scripts/constants.sh
|
||||
source "${EVM_PATH}"/scripts/lib_luxd_clone.sh
|
||||
|
||||
clone_luxd "${LUX_VERSION}"
|
||||
LUXD_IMAGE_TAG="$(luxd_image_tag_from_clone)"
|
||||
|
||||
# Build luxd node image in the clone path
|
||||
pushd "${LUXD_CLONE_PATH}" > /dev/null
|
||||
NODE_ONLY=1 TEST_SETUP=luxd IMAGE_TAG="${LUXD_IMAGE_TAG}" bash -x "${LUXD_CLONE_PATH}"/scripts/build_antithesis_images.sh
|
||||
popd > /dev/null
|
||||
|
||||
# Specifying an image prefix will ensure the image is pushed after build
|
||||
IMAGE_PREFIX="${IMAGE_PREFIX:-}"
|
||||
|
||||
IMAGE_TAG="${IMAGE_TAG:-}"
|
||||
if [[ -z "${IMAGE_TAG}" ]]; then
|
||||
# Default to tagging with the commit hash
|
||||
source "${EVM_PATH}"/scripts/constants.sh
|
||||
IMAGE_TAG="${EVM_COMMIT::8}"
|
||||
fi
|
||||
|
||||
# The dockerfiles don't specify the golang version to minimize the changes required to bump
|
||||
# the version. Instead, the golang version is provided as an argument.
|
||||
GO_VERSION="$(go list -m -f '{{.GoVersion}}')"
|
||||
|
||||
# Import common functions used to build images for antithesis test setups
|
||||
# shellcheck source=/dev/null
|
||||
source "${LUXD_CLONE_PATH}"/scripts/lib_build_antithesis_images.sh
|
||||
|
||||
build_antithesis_builder_image "${GO_VERSION}" "antithesis-evm-builder:${IMAGE_TAG}" "${LUXD_CLONE_PATH}" "${EVM_PATH}"
|
||||
|
||||
# Ensure luxd and evm binaries are available to create an initial db state that includes subnets.
|
||||
pushd "${LUXD_CLONE_PATH}" && ./scripts/build.sh && popd
|
||||
"${EVM_PATH}"/scripts/build.sh
|
||||
|
||||
echo "Generating compose configuration"
|
||||
gen_antithesis_compose_config "${IMAGE_TAG}" "${EVM_PATH}/tests/antithesis/gencomposeconfig" \
|
||||
"${EVM_PATH}/build/antithesis" \
|
||||
"LUXD_PATH=${LUXD_CLONE_PATH}/build/luxd \
|
||||
LUXD_PLUGIN_DIR=${DEFAULT_PLUGIN_DIR}"
|
||||
|
||||
build_antithesis_images "${GO_VERSION}" "${IMAGE_PREFIX}" "antithesis-evm" "${IMAGE_TAG}" \
|
||||
"${LUXD_IMAGE_TAG}" "${EVM_PATH}/tests/antithesis/Dockerfile" \
|
||||
"${EVM_PATH}/Dockerfile" "${EVM_PATH}"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Directory above this script
|
||||
EVM_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
|
||||
# Load the constants
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
echo "Building Workload..."
|
||||
go build -o "$EVM_PATH/build/workload" "$EVM_PATH/tests/antithesis/"*.go
|
||||
@@ -5,12 +5,12 @@ set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
# Root directory
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
|
||||
# Load the constants
|
||||
source "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
go test ./precompile/contracts/... -bench=./... -timeout="10m" "$@"
|
||||
|
||||
@@ -17,13 +17,13 @@ PLATFORMS="${PLATFORMS:-}"
|
||||
PUBLISH="${PUBLISH:-}"
|
||||
|
||||
# Directory above this script
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
|
||||
# Load the constants
|
||||
source "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
# ALLOW_TAG_LATEST is used to tag the image as 'latest' if set to true.
|
||||
# It only works if the image is built from the master branch. This is to avoid
|
||||
@@ -92,7 +92,7 @@ if ! docker pull "${LUXD_NODE_IMAGE}"; then
|
||||
LUXD_NODE_IMAGE="${LUXD_LOCAL_IMAGE_NAME}:${LUX_VERSION}"
|
||||
echo "Building ${LUXD_NODE_IMAGE} locally"
|
||||
|
||||
source "${SUBNET_EVM_PATH}"/scripts/lib_luxd_clone.sh
|
||||
source "${EVM_PATH}"/scripts/lib_luxd_clone.sh
|
||||
clone_luxd "${LUX_VERSION}"
|
||||
SKIP_BUILD_RACE=1 \
|
||||
DOCKER_IMAGE="${LUXD_LOCAL_IMAGE_NAME}" \
|
||||
@@ -100,11 +100,11 @@ if ! docker pull "${LUXD_NODE_IMAGE}"; then
|
||||
"${LUXD_CLONE_PATH}"/scripts/build_image.sh
|
||||
fi
|
||||
|
||||
echo "Building Docker Image: $IMAGE_NAME:$BUILD_IMAGE_ID based of Lux@$LUX_VERSION"
|
||||
echo "Building Docker Image: $IMAGE_NAME:$BUILD_IMAGE_ID based of Luxd@$LUX_VERSION"
|
||||
${DOCKER_CMD} -t "$IMAGE_NAME:$BUILD_IMAGE_ID" -t "$IMAGE_NAME:${DOCKERHUB_TAG}" \
|
||||
"$SUBNET_EVM_PATH" -f "$SUBNET_EVM_PATH/Dockerfile" \
|
||||
"$EVM_PATH" -f "$EVM_PATH/Dockerfile" \
|
||||
--build-arg LUXD_NODE_IMAGE="$LUXD_NODE_IMAGE" \
|
||||
--build-arg SUBNET_EVM_COMMIT="$SUBNET_EVM_COMMIT" \
|
||||
--build-arg EVM_COMMIT="$EVM_COMMIT" \
|
||||
--build-arg CURRENT_BRANCH="$CURRENT_BRANCH" \
|
||||
--build-arg VM_ID="$VM_ID"
|
||||
|
||||
|
||||
+42
-3
@@ -6,15 +6,54 @@ set -o pipefail
|
||||
# TODO(marun) Ensure the working directory is the repository root or a non-canonical set of tests may be executed
|
||||
|
||||
# Root directory
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
|
||||
# Load the constants
|
||||
source "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
# We pass in the arguments to this script directly to enable easily passing parameters such as enabling race detection,
|
||||
# parallelism, and test coverage.
|
||||
# DO NOT RUN tests from the top level "tests" directory since they are run by ginkgo
|
||||
go test -coverprofile=coverage.out -covermode=atomic -timeout="30m" $@ $(go list ./... | grep -v github.com/luxfi/evm/tests)
|
||||
race="-race"
|
||||
if [[ -n "${NO_RACE:-}" ]]; then
|
||||
race=""
|
||||
fi
|
||||
|
||||
# MAX_RUNS bounds the attempts to retry the tests before giving up
|
||||
# This is useful for flaky tests
|
||||
MAX_RUNS=4
|
||||
for ((i = 1; i <= MAX_RUNS; i++));
|
||||
do
|
||||
# shellcheck disable=SC2046
|
||||
go test -shuffle=on ${race:-} -timeout="${TIMEOUT:-600s}" -coverprofile=coverage.out -covermode=atomic "$@" $(go list ./... | grep -v github.com/luxfi/evm/tests) | tee test.out || command_status=$?
|
||||
|
||||
# If the test passed, exit
|
||||
if [[ ${command_status:-0} == 0 ]]; then
|
||||
rm test.out
|
||||
exit 0
|
||||
else
|
||||
unset command_status # Clear the error code for the next run
|
||||
fi
|
||||
|
||||
# If the test failed, print the output
|
||||
unexpected_failures=$(
|
||||
# First grep pattern corresponds to test failures, second pattern corresponds to test panics due to timeouts
|
||||
(grep "^--- FAIL" test.out | awk '{print $3}' || grep -E '^\s+Test.+ \(' test.out | awk '{print $1}') |
|
||||
sort -u | comm -23 - <(sed 's/\r$//' ./scripts/known_flakes.txt)
|
||||
)
|
||||
if [ -n "${unexpected_failures}" ]; then
|
||||
echo "Unexpected test failures: ${unexpected_failures}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Note the absence of unexpected failures cannot be indicative that we only need to run the tests that failed,
|
||||
# for example a test may panic and cause subsequent tests in that package to not run.
|
||||
# So we loop here.
|
||||
echo "Test run $i failed with known flakes, retrying..."
|
||||
done
|
||||
|
||||
# If we reach here, we have failed all retries
|
||||
exit 1
|
||||
+10
-5
@@ -12,12 +12,17 @@ DEFAULT_VM_NAME="evm"
|
||||
DEFAULT_VM_ID="srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy"
|
||||
|
||||
# Lux docker hub
|
||||
DOCKERHUB_REPO="luxdefi/node"
|
||||
# avaplatform/luxd - defaults to local as to avoid unintentional pushes
|
||||
# You should probably set it - export IMAGE_NAME='avaplatform/evm_luxd'
|
||||
IMAGE_NAME=${IMAGE_NAME:-"evm_luxd"}
|
||||
|
||||
# Shared between ./scripts/build_docker_image.sh and ./scripts/tests.build_docker_image.sh
|
||||
LUXD_IMAGE_NAME="${LUXD_IMAGE_NAME:-avaplatform/luxd}"
|
||||
|
||||
# if this isn't a git repository (say building from a release), don't set our git constants.
|
||||
if [ ! -d .git ]; then
|
||||
CURRENT_BRANCH=""
|
||||
SUBNET_EVM_COMMIT=""
|
||||
EVM_COMMIT=""
|
||||
else
|
||||
# Current branch
|
||||
CURRENT_BRANCH=${CURRENT_BRANCH:-$(git describe --tags --exact-match 2>/dev/null || git symbolic-ref -q --short HEAD || git rev-parse --short HEAD || :)}
|
||||
@@ -26,13 +31,13 @@ else
|
||||
#
|
||||
# Use an abbreviated version of the full commit to tag the image.
|
||||
# WARNING: this will use the most recent commit even if there are un-committed changes present
|
||||
SUBNET_EVM_COMMIT="$(git --git-dir="$SUBNET_EVM_PATH/.git" rev-parse HEAD || :)"
|
||||
EVM_COMMIT="$(git --git-dir="$EVM_PATH/.git" rev-parse HEAD || :)"
|
||||
fi
|
||||
|
||||
# Don't export them as they're used in the context of other calls
|
||||
if [[ -z ${LUX_VERSION:-} ]]; then
|
||||
# Get module details from go.mod
|
||||
MODULE_DETAILS="$(go list -m "github.com/luxfi/node" 2>/dev/null)"
|
||||
MODULE_DETAILS="$(go list -m "github.com/luxfi/luxd" 2>/dev/null)"
|
||||
|
||||
LUX_VERSION="$(echo "${MODULE_DETAILS}" | awk '{print $2}')"
|
||||
|
||||
@@ -49,7 +54,7 @@ if [[ -z ${LUX_VERSION:-} ]]; then
|
||||
fi
|
||||
|
||||
# Shared between ./scripts/build_docker_image.sh and ./scripts/tests.build_docker_image.sh
|
||||
DOCKERHUB_TAG="${SUBNET_EVM_COMMIT::8}_${LUX_VERSION}"
|
||||
DOCKERHUB_TAG="${EVM_COMMIT::8}_${LUX_VERSION}"
|
||||
# WARNING: this will use the most recent commit even if there are un-committed changes present
|
||||
BUILD_IMAGE_ID=${BUILD_IMAGE_ID:-"${CURRENT_BRANCH}_${LUX_VERSION}"}
|
||||
|
||||
|
||||
@@ -13,6 +13,6 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
source "$SCRIPT_DIR"/constants.sh
|
||||
|
||||
# Start a dev shell with the luxd flake
|
||||
FLAKE="github:luxfi/node?ref=${LUX_VERSION}"
|
||||
FLAKE="github:luxfi/luxd?ref=${LUX_VERSION}"
|
||||
echo "Starting nix shell for ${FLAKE}"
|
||||
nix develop "${FLAKE}" "${@}"
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
"github.com/luxfi/libevm/accounts"
|
||||
"github.com/luxfi/libevm/accounts/external"
|
||||
"github.com/luxfi/libevm/accounts/keystore"
|
||||
"github.com/luxfi/libevm/accounts/scwallet"
|
||||
"github.com/luxfi/libevm/common"
|
||||
"github.com/luxfi/libevm/common/bitutil"
|
||||
"github.com/luxfi/libevm/common/compiler"
|
||||
"github.com/luxfi/libevm/common/hexutil"
|
||||
"github.com/luxfi/libevm/common/lru"
|
||||
"github.com/luxfi/libevm/common/math"
|
||||
"github.com/luxfi/libevm/common/prque"
|
||||
"github.com/luxfi/libevm/core/asm"
|
||||
"github.com/luxfi/libevm/core/rawdb"
|
||||
"github.com/luxfi/libevm/core/types"
|
||||
"github.com/luxfi/libevm/core/vm"
|
||||
"github.com/luxfi/libevm/crypto"
|
||||
"github.com/luxfi/libevm/crypto/blake2b"
|
||||
"github.com/luxfi/libevm/crypto/bls12381"
|
||||
"github.com/luxfi/libevm/crypto/bn256"
|
||||
"github.com/luxfi/libevm/crypto/kzg4844"
|
||||
"github.com/luxfi/libevm/eth/tracers/js"
|
||||
"github.com/luxfi/libevm/eth/tracers/logger"
|
||||
"github.com/luxfi/libevm/eth/tracers/native"
|
||||
"github.com/luxfi/libevm/ethdb"
|
||||
"github.com/luxfi/libevm/ethdb/leveldb"
|
||||
"github.com/luxfi/libevm/ethdb/memorydb"
|
||||
"github.com/luxfi/libevm/ethdb/pebble"
|
||||
"github.com/luxfi/libevm/event"
|
||||
"github.com/luxfi/libevm/libevm"
|
||||
"github.com/luxfi/libevm/libevm/legacy"
|
||||
"github.com/luxfi/libevm/libevm/stateconf"
|
||||
"github.com/luxfi/libevm/log"
|
||||
"github.com/luxfi/libevm/metrics"
|
||||
"github.com/luxfi/libevm/rlp"
|
||||
"github.com/luxfi/libevm/trie"
|
||||
"github.com/luxfi/libevm/trie/testutil"
|
||||
"github.com/luxfi/libevm/trie/trienode"
|
||||
"github.com/luxfi/libevm/trie/triestate"
|
||||
"github.com/luxfi/libevm/trie/utils"
|
||||
"github.com/luxfi/libevm/triedb"
|
||||
"github.com/luxfi/libevm/triedb/database"
|
||||
"github.com/luxfi/geth/accounts"
|
||||
"github.com/luxfi/geth/accounts/external"
|
||||
"github.com/luxfi/geth/accounts/keystore"
|
||||
"github.com/luxfi/geth/accounts/scwallet"
|
||||
"github.com/luxfi/geth/common"
|
||||
"github.com/luxfi/geth/common/bitutil"
|
||||
"github.com/luxfi/geth/common/compiler"
|
||||
"github.com/luxfi/geth/common/hexutil"
|
||||
"github.com/luxfi/geth/common/lru"
|
||||
"github.com/luxfi/geth/common/math"
|
||||
"github.com/luxfi/geth/common/prque"
|
||||
"github.com/luxfi/geth/core/asm"
|
||||
"github.com/luxfi/geth/core/rawdb"
|
||||
"github.com/luxfi/geth/core/types"
|
||||
"github.com/luxfi/geth/core/vm"
|
||||
"github.com/luxfi/geth/crypto"
|
||||
"github.com/luxfi/geth/crypto/blake2b"
|
||||
"github.com/luxfi/geth/crypto/bls12381"
|
||||
"github.com/luxfi/geth/crypto/bn256"
|
||||
"github.com/luxfi/geth/crypto/kzg4844"
|
||||
"github.com/luxfi/geth/eth/tracers/js"
|
||||
"github.com/luxfi/geth/eth/tracers/logger"
|
||||
"github.com/luxfi/geth/eth/tracers/native"
|
||||
"github.com/luxfi/geth/ethdb"
|
||||
"github.com/luxfi/geth/ethdb/leveldb"
|
||||
"github.com/luxfi/geth/ethdb/memorydb"
|
||||
"github.com/luxfi/geth/ethdb/pebble"
|
||||
"github.com/luxfi/geth/event"
|
||||
"github.com/luxfi/geth/geth"
|
||||
"github.com/luxfi/geth/geth/legacy"
|
||||
"github.com/luxfi/geth/geth/stateconf"
|
||||
"github.com/luxfi/geth/log"
|
||||
"github.com/luxfi/geth/metrics"
|
||||
"github.com/luxfi/geth/rlp"
|
||||
"github.com/luxfi/geth/trie"
|
||||
"github.com/luxfi/geth/trie/testutil"
|
||||
"github.com/luxfi/geth/trie/trienode"
|
||||
"github.com/luxfi/geth/trie/triestate"
|
||||
"github.com/luxfi/geth/trie/utils"
|
||||
"github.com/luxfi/geth/triedb"
|
||||
"github.com/luxfi/geth/triedb/database"
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to fix internal imports in the EVM package
|
||||
# These should remain as github.com/luxfi/evm/* not github.com/luxfi/geth/*
|
||||
|
||||
echo "Fixing internal imports in EVM package..."
|
||||
|
||||
# Find all Go files and fix imports that should be internal
|
||||
find . -name "*.go" -type f -not -path "./vendor/*" -not -path "./.git/*" | while read -r file; do
|
||||
# Skip if file doesn't contain our imports
|
||||
if ! grep -q "github.com/luxfi/evm" "$file"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# List of packages that are INTERNAL to EVM and should NOT use geth
|
||||
# These are implemented within the EVM package itself
|
||||
sed -i.bak \
|
||||
-e 's|"github.com/luxfi/geth/common"|"github.com/luxfi/evm/common"|g' \
|
||||
-e 's|"github.com/luxfi/geth/common/hexutil"|"github.com/luxfi/evm/common/hexutil"|g' \
|
||||
-e 's|"github.com/luxfi/geth/common/math"|"github.com/luxfi/evm/common/math"|g' \
|
||||
-e 's|"github.com/luxfi/geth/core/types"|"github.com/luxfi/evm/core/types"|g' \
|
||||
-e 's|"github.com/luxfi/geth/core/rawdb"|"github.com/luxfi/evm/core/rawdb"|g' \
|
||||
-e 's|"github.com/luxfi/geth/core/state"|"github.com/luxfi/evm/core/state"|g' \
|
||||
-e 's|"github.com/luxfi/geth/core/vm"|"github.com/luxfi/evm/core/vm"|g' \
|
||||
-e 's|"github.com/luxfi/geth/crypto"|"github.com/luxfi/evm/crypto"|g' \
|
||||
-e 's|"github.com/luxfi/geth/ethdb"|"github.com/luxfi/evm/ethdb"|g' \
|
||||
-e 's|"github.com/luxfi/geth/event"|"github.com/luxfi/evm/event"|g' \
|
||||
-e 's|"github.com/luxfi/geth/log"|"github.com/luxfi/evm/log"|g' \
|
||||
-e 's|"github.com/luxfi/geth/params"|"github.com/luxfi/evm/params"|g' \
|
||||
-e 's|"github.com/luxfi/geth/accounts"|"github.com/luxfi/evm/accounts"|g' \
|
||||
-e 's|"github.com/luxfi/geth/rlp"|"github.com/luxfi/evm/rlp"|g' \
|
||||
-e 's|"github.com/luxfi/geth/trie"|"github.com/luxfi/evm/trie"|g' \
|
||||
-e 's|"github.com/luxfi/geth/metrics"|"github.com/luxfi/evm/metrics"|g' \
|
||||
"$file"
|
||||
|
||||
# Remove backup file if successful
|
||||
if [ $? -eq 0 ]; then
|
||||
rm -f "${file}.bak"
|
||||
else
|
||||
echo "Error updating $file"
|
||||
mv "${file}.bak" "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Internal import fix complete!"
|
||||
echo ""
|
||||
echo "Note: The EVM package should use its own internal packages."
|
||||
echo "Only use luxfi/geth for things that come from go-ethereum."
|
||||
@@ -2,19 +2,19 @@
|
||||
set -e
|
||||
|
||||
# This script generates a Stateful Precompile stub based off of a Solidity ABI file.
|
||||
# It first sets the necessary CGO_FLAGs for the BLST library used in Lux and
|
||||
# It first sets the necessary CGO_FLAGs for the BLST library used in Luxd and
|
||||
# then runs PrecompileGen.
|
||||
if ! [[ "$0" =~ scripts/generate_precompile.sh ]]; then
|
||||
echo "must be run from repository root, but got $0"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
|
||||
# Load the constants
|
||||
source "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
go run ./cmd/precompilegen/main.go "$@"
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
|
||||
# Load the constants
|
||||
source "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
############################
|
||||
# download node
|
||||
# https://github.com/luxfi/node/releases
|
||||
# download luxd
|
||||
# https://github.com/luxfi/luxd/releases
|
||||
GOARCH=$(go env GOARCH)
|
||||
GOOS=$(go env GOOS)
|
||||
BASEDIR=${BASEDIR:-"/tmp/node-release"}
|
||||
LUXD_BUILD_PATH=${LUXD_BUILD_PATH:-${BASEDIR}/node}
|
||||
BASEDIR=${BASEDIR:-"/tmp/luxd-release"}
|
||||
LUXD_BUILD_PATH=${LUXD_BUILD_PATH:-${BASEDIR}/luxd}
|
||||
|
||||
mkdir -p "${BASEDIR}"
|
||||
|
||||
LUXD_DOWNLOAD_URL=https://github.com/luxfi/node/releases/download/${LUX_VERSION}/node-linux-${GOARCH}-${LUX_VERSION}.tar.gz
|
||||
LUXD_DOWNLOAD_PATH=${BASEDIR}/node-linux-${GOARCH}-${LUX_VERSION}.tar.gz
|
||||
LUXD_DOWNLOAD_URL=https://github.com/luxfi/luxd/releases/download/${LUX_VERSION}/luxd-linux-${GOARCH}-${LUX_VERSION}.tar.gz
|
||||
LUXD_DOWNLOAD_PATH=${BASEDIR}/luxd-linux-${GOARCH}-${LUX_VERSION}.tar.gz
|
||||
|
||||
if [[ ${GOOS} == "darwin" ]]; then
|
||||
LUXD_DOWNLOAD_URL=https://github.com/luxfi/node/releases/download/${LUX_VERSION}/node-macos-${LUX_VERSION}.zip
|
||||
LUXD_DOWNLOAD_PATH=${BASEDIR}/node-macos-${LUX_VERSION}.zip
|
||||
LUXD_DOWNLOAD_URL=https://github.com/luxfi/luxd/releases/download/${LUX_VERSION}/luxd-macos-${LUX_VERSION}.zip
|
||||
LUXD_DOWNLOAD_PATH=${BASEDIR}/luxd-macos-${LUX_VERSION}.zip
|
||||
fi
|
||||
|
||||
BUILD_DIR=${LUXD_BUILD_PATH}-${LUX_VERSION}
|
||||
@@ -33,32 +33,32 @@ extract_archive() {
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
|
||||
if [[ ${LUXD_DOWNLOAD_PATH} == *.tar.gz ]]; then
|
||||
tar xzvf ${LUXD_DOWNLOAD_PATH} --directory ${BUILD_DIR} --strip-components 1
|
||||
tar xzvf "${LUXD_DOWNLOAD_PATH}" --directory "${BUILD_DIR}" --strip-components 1
|
||||
elif [[ ${LUXD_DOWNLOAD_PATH} == *.zip ]]; then
|
||||
unzip ${LUXD_DOWNLOAD_PATH} -d ${BUILD_DIR}
|
||||
mv ${BUILD_DIR}/build/* ${BUILD_DIR}
|
||||
rm -rf ${BUILD_DIR}/build/
|
||||
unzip "${LUXD_DOWNLOAD_PATH}" -d "${BUILD_DIR}"
|
||||
mv "${BUILD_DIR}"/build/* "${BUILD_DIR}"
|
||||
rm -rf "${BUILD_DIR}"/build/
|
||||
fi
|
||||
}
|
||||
|
||||
# first check if we already have the archive
|
||||
if [[ -f ${LUXD_DOWNLOAD_PATH} ]]; then
|
||||
# if the download path already exists, extract and exit
|
||||
echo "found node ${LUX_VERSION} at ${LUXD_DOWNLOAD_PATH}"
|
||||
echo "found luxd ${LUX_VERSION} at ${LUXD_DOWNLOAD_PATH}"
|
||||
|
||||
extract_archive
|
||||
else
|
||||
# try to download the archive if it exists
|
||||
if curl -s --head --request GET ${LUXD_DOWNLOAD_URL} | grep "302" > /dev/null; then
|
||||
if curl -s --head --request GET "${LUXD_DOWNLOAD_URL}" | grep "302" >/dev/null; then
|
||||
echo "${LUXD_DOWNLOAD_URL} found"
|
||||
echo "downloading to ${LUXD_DOWNLOAD_PATH}"
|
||||
curl -L ${LUXD_DOWNLOAD_URL} -o ${LUXD_DOWNLOAD_PATH}
|
||||
curl -L "${LUXD_DOWNLOAD_URL}" -o "${LUXD_DOWNLOAD_PATH}"
|
||||
|
||||
extract_archive
|
||||
else
|
||||
# else the version is a git commitish (or it's invalid)
|
||||
GIT_CLONE_URL=https://github.com/luxfi/node.git
|
||||
GIT_CLONE_PATH=${BASEDIR}/node-repo/
|
||||
GIT_CLONE_URL=https://github.com/luxfi/luxd.git
|
||||
GIT_CLONE_PATH=${BASEDIR}/luxd-repo/
|
||||
|
||||
# check to see if the repo already exists, if not clone it
|
||||
if [[ ! -d ${GIT_CLONE_PATH} ]]; then
|
||||
@@ -77,14 +77,14 @@ else
|
||||
|
||||
set +e
|
||||
# try to checkout the branch
|
||||
git checkout origin/${LUX_VERSION} > /dev/null 2>&1
|
||||
git checkout origin/"${LUX_VERSION}" >/dev/null 2>&1
|
||||
CHECKOUT_STATUS=$?
|
||||
set -e
|
||||
|
||||
# if it's not a branch, try to checkout the commit
|
||||
if [[ $CHECKOUT_STATUS -ne 0 ]]; then
|
||||
set +e
|
||||
git checkout ${LUX_VERSION} > /dev/null 2>&1
|
||||
git checkout "${LUX_VERSION}" >/dev/null 2>&1
|
||||
CHECKOUT_STATUS=$?
|
||||
set -e
|
||||
|
||||
@@ -100,9 +100,9 @@ else
|
||||
# use the commit hash instead of the branch name or tag
|
||||
BUILD_DIR=${LUXD_BUILD_PATH}-${COMMIT}
|
||||
|
||||
# if the build-directory doesn't exist, build node
|
||||
# if the build-directory doesn't exist, build luxd
|
||||
if [[ ! -d ${BUILD_DIR} ]]; then
|
||||
echo "building node ${COMMIT} to ${BUILD_DIR}"
|
||||
echo "building luxd ${COMMIT} to ${BUILD_DIR}"
|
||||
./scripts/build.sh
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
|
||||
@@ -113,15 +113,12 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
LUXD_PATH=${LUXD_BUILD_PATH}/node
|
||||
LUXD_PLUGIN_DIR=${LUXD_BUILD_PATH}/plugins
|
||||
LUXD_PATH=${LUXD_BUILD_PATH}/luxd
|
||||
|
||||
mkdir -p ${LUXD_BUILD_PATH}
|
||||
|
||||
cp ${BUILD_DIR}/node ${LUXD_PATH}
|
||||
mkdir -p "${LUXD_BUILD_PATH}"
|
||||
|
||||
cp "${BUILD_DIR}"/luxd "${LUXD_PATH}"
|
||||
|
||||
echo "Installed Lux release ${LUX_VERSION}"
|
||||
echo "Lux Path: ${LUXD_PATH}"
|
||||
echo "Plugin Dir: ${LUXD_PLUGIN_DIR}"
|
||||
echo "Installed Luxd release ${LUX_VERSION}"
|
||||
echo "Luxd Path: ${LUXD_PATH}"
|
||||
echo "Plugin Dir: ${DEFAULT_PLUGIN_DIR}"
|
||||
@@ -4,12 +4,12 @@ set -euo pipefail
|
||||
|
||||
# Defines functions for interacting with git clones of the luxd repo.
|
||||
|
||||
if [[ -z "${SUBNET_EVM_PATH}" ]]; then
|
||||
echo "SUBNET_EVM_PATH must be set"
|
||||
if [[ -z "${EVM_PATH}" ]]; then
|
||||
echo "EVM_PATH must be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export LUXD_CLONE_PATH=${LUXD_CLONE_PATH:-${SUBNET_EVM_PATH}/luxd}
|
||||
export LUXD_CLONE_PATH=${LUXD_CLONE_PATH:-${EVM_PATH}/luxd}
|
||||
|
||||
# Clones the luxd repo to the configured path and checks out the specified version.
|
||||
function clone_luxd {
|
||||
@@ -22,12 +22,12 @@ function clone_luxd {
|
||||
git fetch
|
||||
else
|
||||
echo "creating new clone"
|
||||
git clone https://github.com/luxfi/node.git "${LUXD_CLONE_PATH}"
|
||||
git clone https://github.com/luxfi/luxd.git "${LUXD_CLONE_PATH}"
|
||||
cd "${LUXD_CLONE_PATH}"
|
||||
fi
|
||||
# Branch will be reset to $lux_version if it already exists
|
||||
git checkout -B "test-${lux_version}" "${lux_version}"
|
||||
cd "${SUBNET_EVM_PATH}"
|
||||
cd "${EVM_PATH}"
|
||||
}
|
||||
|
||||
# Derives an image tag from the current state of the luxd clone
|
||||
Executable
+214
@@ -0,0 +1,214 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if ! [[ "$0" =~ scripts/lint.sh ]]; then
|
||||
echo "must be run from repository root"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# The -P option is not supported by the grep version installed by
|
||||
# default on macos. Since `-o errexit` is ignored in an if
|
||||
# conditional, triggering the problem here ensures script failure when
|
||||
# using an unsupported version of grep.
|
||||
grep -P 'lint.sh' scripts/lint.sh &>/dev/null || (
|
||||
echo >&2 "error: This script requires a recent version of gnu grep."
|
||||
echo >&2 " On macos, gnu grep can be installed with 'brew install grep'."
|
||||
echo >&2 " It will also be necessary to ensure that gnu grep is available in the path."
|
||||
exit 255
|
||||
)
|
||||
|
||||
# Read excluded directories into arrays
|
||||
DEFAULT_FILES=()
|
||||
UPSTREAM_FILES=()
|
||||
function read_dirs {
|
||||
local upstream_folders_file="./scripts/upstream_files.txt"
|
||||
# Read the upstream_folders file into an array
|
||||
mapfile -t upstream_folders <"$upstream_folders_file"
|
||||
|
||||
# Shared find filters
|
||||
local -a find_filters=(
|
||||
-type f
|
||||
-name '*.go'
|
||||
! -name '*.pb.go'
|
||||
! -name 'mock_*.go'
|
||||
! -name 'mocks_*.go'
|
||||
! -name 'mocks.go'
|
||||
! -name 'mock.go'
|
||||
! -name 'gen_*.go'
|
||||
! -path './**/*mock/*.go'
|
||||
)
|
||||
|
||||
# Combined loop: build both upstream licensed find and exclude args
|
||||
local -a upstream_find_args=()
|
||||
local -a upstream_exclude_args=()
|
||||
for line in "${upstream_folders[@]}"; do
|
||||
if [[ "$line" == !* ]]; then
|
||||
# Excluding files with !
|
||||
upstream_exclude_args+=(! -path "./${line:1}")
|
||||
else
|
||||
upstream_find_args+=(-path "./${line}" -o)
|
||||
fi
|
||||
done
|
||||
# Remove the last '-o' from the arrays
|
||||
unset 'upstream_find_args[${#upstream_find_args[@]}-1]'
|
||||
|
||||
# Find upstream files
|
||||
mapfile -t UPSTREAM_FILES < <(
|
||||
find . \
|
||||
\( "${upstream_find_args[@]}" \) \
|
||||
-a \( "${find_filters[@]}" \) \
|
||||
"${upstream_exclude_args[@]}"
|
||||
)
|
||||
|
||||
# Build exclusion args from upstream files
|
||||
default_exclude_args=()
|
||||
for f in "${UPSTREAM_FILES[@]}"; do
|
||||
default_exclude_args+=(! -path "$f")
|
||||
done
|
||||
|
||||
# Now find default files (exclude already licensed ones)
|
||||
mapfile -t DEFAULT_FILES < <(find . "${find_filters[@]}" "${default_exclude_args[@]}")
|
||||
}
|
||||
|
||||
# by default, "./scripts/lint.sh" runs all linft tests
|
||||
# to run only "license_header" test
|
||||
# TESTS='license_header' ./scripts/lint.sh
|
||||
TESTS=${TESTS:-"golangci_lint license_header require_error_is_no_funcs_as_params single_import interface_compliance_nil require_no_error_inline_func import_testing_only_in_tests"}
|
||||
|
||||
function test_golangci_lint {
|
||||
go run github.com/golangci/golangci-lint/cmd/[email protected] run --config .golangci.yml
|
||||
}
|
||||
|
||||
# automatically checks license headers
|
||||
# to modify the file headers (if missing), remove "--verify" flag
|
||||
# TESTS='license_header' ADDLICENSE_FLAGS="--debug" ./scripts/lint.sh
|
||||
_addlicense_flags=${ADDLICENSE_FLAGS:-"--verify --debug"}
|
||||
function test_license_header {
|
||||
# Run license tool
|
||||
if [[ ${#UPSTREAM_FILES[@]} -gt 0 ]]; then
|
||||
echo "Running license tool on upstream files with header for upstream..."
|
||||
# shellcheck disable=SC2086
|
||||
go run github.com/palantir/[email protected] \
|
||||
--config=./license_header_for_upstream.yml \
|
||||
${_addlicense_flags} \
|
||||
"${UPSTREAM_FILES[@]}" \
|
||||
|| return 1
|
||||
fi
|
||||
|
||||
if [[ ${#DEFAULT_FILES[@]} -gt 0 ]]; then
|
||||
echo "Running license tool on remaining files with default header..."
|
||||
# shellcheck disable=SC2086
|
||||
go run github.com/palantir/[email protected] \
|
||||
--config=./license_header.yml \
|
||||
${_addlicense_flags} \
|
||||
"${DEFAULT_FILES[@]}" \
|
||||
|| return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function test_single_import {
|
||||
local files=("$@")
|
||||
if grep -R -zo -P 'import \(\n\t".*"\n\)' "${files[@]}"; then
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function test_require_error_is_no_funcs_as_params {
|
||||
local files=("$@")
|
||||
if grep -R -zo -P 'require.ErrorIs\(.+?\)[^\n]*\)\n' "${files[@]}"; then
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function test_require_no_error_inline_func {
|
||||
local files=("$@")
|
||||
if grep -R -zo -P '\t+err :?= ((?!require|if).|\n)*require\.NoError\((t, )?err\)' "${files[@]}"; then
|
||||
echo ""
|
||||
echo "Checking that a function with a single error return doesn't error should be done in-line."
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Ref: https://go.dev/doc/effective_go#blank_implements
|
||||
function test_interface_compliance_nil {
|
||||
local files=("$@")
|
||||
if grep -R -o -P '_ .+? = &.+?\{\}' "${files[@]}"; then
|
||||
echo ""
|
||||
echo "Interface compliance checks need to be of the form:"
|
||||
echo " var _ json.Marshaler = (*RawMessage)(nil)"
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function test_import_testing_only_in_tests {
|
||||
local files=("$@")
|
||||
NON_TEST_GO_FILES=$(
|
||||
echo "${files[@]}" | tr ' ' '\n' |
|
||||
grep -i '\.go$' |
|
||||
grep -vi '_test\.go$' |
|
||||
grep -v '^./tests/'
|
||||
)
|
||||
|
||||
IMPORT_TESTING=$(echo "${NON_TEST_GO_FILES}" | xargs grep -lP '^\s*(import\s+)?"testing"')
|
||||
IMPORT_TESTIFY=$(echo "${NON_TEST_GO_FILES}" | xargs grep -l '"github.com/stretchr/testify')
|
||||
IMPORT_FROM_TESTS=$(echo "${NON_TEST_GO_FILES}" | xargs grep -l '"github.com/luxfi/coreth/tests/')
|
||||
IMPORT_TEST_PKG=$(echo "${NON_TEST_GO_FILES}" | xargs grep -lP '"github.com/luxfi/coreth/.*?test"')
|
||||
|
||||
# TODO(arr4n): send a PR to add support for build tags in `mockgen` and then enable this.
|
||||
# IMPORT_GOMOCK=$( echo "${NON_TEST_GO_FILES}" | xargs grep -l '"go.uber.org/mock');
|
||||
HAVE_TEST_LOGIC=$(printf "%s\n%s\n%s\n%s" "${IMPORT_TESTING}" "${IMPORT_TESTIFY}" "${IMPORT_FROM_TESTS}" "${IMPORT_TEST_PKG}")
|
||||
|
||||
IN_TEST_PKG=$(echo "${NON_TEST_GO_FILES}" | grep -P '.*test/[^/]+\.go$') # directory (hence package name) ends in "test"
|
||||
# Files in /tests/ are already excluded by the `find ... ! -path`
|
||||
INTENDED_FOR_TESTING="${IN_TEST_PKG}"
|
||||
|
||||
# -3 suppresses files that have test logic and have the "test" build tag
|
||||
# -2 suppresses files that are tagged despite not having detectable test logic
|
||||
UNTAGGED=$(comm -23 <(echo "${HAVE_TEST_LOGIC}" | sort -u) <(echo "${INTENDED_FOR_TESTING}" | sort -u))
|
||||
if [ -z "${UNTAGGED}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo 'Non-test Go files importing test-only packages MUST (a) be in *test package; or (b) be in /tests/ directory:'
|
||||
echo "${UNTAGGED}"
|
||||
return 1
|
||||
}
|
||||
|
||||
function run {
|
||||
local test="${1}"
|
||||
shift 1
|
||||
echo "START: '${test}' at $(date)"
|
||||
|
||||
# Filter out files that have skiplint comments for this specific test
|
||||
local filtered_files=()
|
||||
for file in "${DEFAULT_FILES[@]}"; do
|
||||
# Check if file has skiplint comment for this test
|
||||
if ! grep -q "// #skiplint: ${test}" "$file" 2>/dev/null; then
|
||||
filtered_files+=("$file")
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${#filtered_files[@]} -eq 0 ]; then
|
||||
echo "SKIPPED: '${test}' - No files remain after filtering at $(date)"
|
||||
return 0
|
||||
fi
|
||||
if "test_${test}" "${filtered_files[@]}"; then
|
||||
echo "SUCCESS: '${test}' completed at $(date)"
|
||||
else
|
||||
echo "FAIL: '${test}' failed at $(date)"
|
||||
exit 255
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Running '$TESTS' at: $(date)"
|
||||
read_dirs
|
||||
for test in $TESTS; do
|
||||
run "${test}" "${DEFAULT_FILES[@]}"
|
||||
done
|
||||
|
||||
echo "ALL SUCCESS!"
|
||||
@@ -5,16 +5,16 @@ set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
# Ensure that there are no eth imports that are not marked as explicitly allowed via ./scripts/eth-allowed-packages.txt
|
||||
# 1. Recursively search through all go files for any lines that include a direct import from libevm
|
||||
# 2. Ignore lines that import libevm with a named import starting with "eth" or by _ import.
|
||||
# 1. Recursively search through all go files for any lines that include a direct import from geth
|
||||
# 2. Ignore lines that import geth with a named import starting with "eth" or by _ import.
|
||||
# 3. Sort the unique results
|
||||
# 4. Print out the difference between the search results and the list of specified allowed package imports from libevm.
|
||||
libevm_regexp='"github.com/luxfi/libevm/.*"'
|
||||
# 4. Print out the difference between the search results and the list of specified allowed package imports from geth.
|
||||
geth_regexp='"github.com/luxfi/geth/.*"'
|
||||
extra_imports=$(find . -type f \( -name "*.go" \) ! -name "mocks.go" ! -path "simulator" ! -path "./core/main_test.go" ! -name "gen_*.go" -print0 |
|
||||
xargs -0 grep "${libevm_regexp}" |
|
||||
xargs -0 grep "${geth_regexp}" |
|
||||
grep -v 'eth\w\+ "' |
|
||||
grep -v '_ "' |
|
||||
grep -o "${libevm_regexp}" |
|
||||
grep -o "${geth_regexp}" |
|
||||
sort -u | comm -23 - ./scripts/eth-allowed-packages.txt)
|
||||
if [ -n "${extra_imports}" ]; then
|
||||
echo "new ethereum imports should be added to ./scripts/eth-allowed-packages.txt to prevent accidental imports:"
|
||||
@@ -22,9 +22,9 @@ if [ -n "${extra_imports}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extra_imports=$(grep -r --include='*.go' '"github.com/luxfi/geth/.*"' -o -h || true | sort -u)
|
||||
extra_imports=$(grep -r --include='*.go' '"github.com/luxfi/coreth/.*"' -o -h || true | sort -u)
|
||||
if [ -n "${extra_imports}" ]; then
|
||||
echo "evm should not import packages from geth:"
|
||||
echo "evm should not import packages from coreth:"
|
||||
echo "${extra_imports}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// (c) 2024, Lux Industries, Inc.
|
||||
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
//
|
||||
// This file is a derived work, based on the go-ethereum library whose original
|
||||
// notices appear below.
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to migrate from ethereum/go-ethereum to luxfi/geth imports
|
||||
|
||||
echo "Starting migration from ethereum/go-ethereum to luxfi/geth..."
|
||||
|
||||
# Find all Go files and update imports
|
||||
find . -name "*.go" -type f -not -path "./vendor/*" -not -path "./.git/*" | while read -r file; do
|
||||
# Skip if file doesn't contain ethereum/go-ethereum imports
|
||||
if ! grep -q "github.com/ethereum/go-ethereum" "$file"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Updating imports in: $file"
|
||||
|
||||
# Replace the imports
|
||||
sed -i.bak \
|
||||
-e 's|"github.com/ethereum/go-ethereum/common"|"github.com/luxfi/geth/common"|g' \
|
||||
-e 's|"github.com/ethereum/go-ethereum/common/hexutil"|"github.com/luxfi/geth/common/hexutil"|g' \
|
||||
-e 's|"github.com/ethereum/go-ethereum/core/types"|"github.com/luxfi/geth/core/types"|g' \
|
||||
-e 's|"github.com/ethereum/go-ethereum/crypto"|"github.com/luxfi/geth/crypto"|g' \
|
||||
-e 's|"github.com/ethereum/go-ethereum/ethdb"|"github.com/luxfi/geth/ethdb"|g' \
|
||||
-e 's|"github.com/ethereum/go-ethereum/event"|"github.com/luxfi/geth/event"|g' \
|
||||
-e 's|"github.com/ethereum/go-ethereum/log"|"github.com/luxfi/geth/log"|g' \
|
||||
-e 's|eparams "github.com/ethereum/go-ethereum/params"|eparams "github.com/luxfi/geth/params"|g' \
|
||||
-e 's|ethparams "github.com/ethereum/go-ethereum/params"|ethparams "github.com/luxfi/geth/params"|g' \
|
||||
-e 's|ethtypes "github.com/ethereum/go-ethereum/core/types"|ethtypes "github.com/luxfi/geth/core/types"|g' \
|
||||
-e 's|gethevent "github.com/ethereum/go-ethereum/event"|gethevent "github.com/luxfi/geth/event"|g' \
|
||||
"$file"
|
||||
|
||||
# Remove backup file if successful
|
||||
if [ $? -eq 0 ]; then
|
||||
rm -f "${file}.bak"
|
||||
else
|
||||
echo "Error updating $file"
|
||||
mv "${file}.bak" "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Migration complete!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "1. Run 'go mod tidy' to update dependencies"
|
||||
echo "2. Run tests to ensure everything works correctly"
|
||||
echo "3. Review any remaining references to ethereum/go-ethereum"
|
||||
+8
-10
@@ -1,24 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# This script starts N nodes (TODO N instead of 5) and waits for ctrl-c to shutdown the process group of Lux processes
|
||||
# Uses data directory to store all Lux data neatly in one location with minimal config overhead
|
||||
# This script starts N nodes (TODO N instead of 5) and waits for ctrl-c to shutdown the process group of Luxd processes
|
||||
# Uses data directory to store all Luxd data neatly in one location with minimal config overhead
|
||||
if ! [[ "$0" =~ scripts/run.sh ]]; then
|
||||
echo "must be run from repository root, but got $0"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
# Load the constants
|
||||
source "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
# Set up lux binary path and assume build directory is set
|
||||
LUXD_BUILD_PATH=${LUXD_BUILD_PATH:-"$GOPATH/src/github.com/luxfi/node/build"}
|
||||
LUXD_PATH=${LUXD_PATH:-"$LUXD_BUILD_PATH/node"}
|
||||
LUXD_PLUGIN_DIR=${LUXD_PLUGIN_DIR:-"$LUXD_BUILD_PATH/plugins"}
|
||||
LUXD_BUILD_PATH=${LUXD_BUILD_PATH:-"$GOPATH/src/github.com/luxfi/luxd/build"}
|
||||
LUXD_PATH=${LUXD_PATH:-"$LUXD_BUILD_PATH/luxd"}
|
||||
LUXD_PLUGIN_DIR=${LUXD_PLUGIN_DIR:-"$DEFAULT_PLUGIN_DIR"}
|
||||
DATA_DIR=${DATA_DIR:-/tmp/evm-start-node/$(date "+%Y-%m-%d%:%H:%M:%S")}
|
||||
|
||||
mkdir -p "$DATA_DIR"
|
||||
@@ -42,6 +42,4 @@ mkdir -p "$NODE_DATA_DIR"
|
||||
NODE_CONFIG_FILE_PATH="$NODE_DATA_DIR/config.json"
|
||||
_set_config "$NODE_CONFIG_FILE_PATH"
|
||||
|
||||
CMD="$LUXD_PATH --data-dir=$NODE_DATA_DIR --config-file=$NODE_CONFIG_FILE_PATH"
|
||||
|
||||
execute_cmd $CMD
|
||||
(set -x; $LUXD_PATH --data-dir="$NODE_DATA_DIR" --config-file="$NODE_CONFIG_FILE_PATH")
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# This script assumes that an Lux and EVM binaries are available in the standard location
|
||||
# This script assumes that an Luxd and Subnet-EVM binaries are available in the standard location
|
||||
# within the $GOPATH
|
||||
# The Lux and PluginDir paths can be specified via the environment variables used in ./scripts/run.sh.
|
||||
# The Luxd and PluginDir paths can be specified via the environment variables used in ./scripts/run.sh.
|
||||
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
|
||||
source "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
EXTRA_ARGS=()
|
||||
LUXD_BUILD_PATH="${LUXD_BUILD_PATH:-}"
|
||||
@@ -19,4 +19,4 @@ if [[ -n "${LUXD_BUILD_PATH}" ]]; then
|
||||
echo "Running with extra args:" "${EXTRA_ARGS[@]}"
|
||||
fi
|
||||
|
||||
"${SUBNET_EVM_PATH}"/bin/ginkgo -vv --label-filter="${GINKGO_LABEL_FILTER:-}" ./tests/load -- "${EXTRA_ARGS[@]}"
|
||||
"${EVM_PATH}"/bin/ginkgo -vv --label-filter="${GINKGO_LABEL_FILTER:-}" ./tests/load -- "${EXTRA_ARGS[@]}"
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# This script assumes that a Lux and EVM binaries are available in the standard location
|
||||
# This script assumes that an Luxd and Subnet-EVM binaries are available in the standard location
|
||||
# within the $GOPATH
|
||||
# The Lux and PluginDir paths can be specified via the environment variables used in ./scripts/run.sh.
|
||||
# The Luxd and PluginDir paths can be specified via the environment variables used in ./scripts/run.sh.
|
||||
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
|
||||
source "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
TEST_SOURCE_ROOT=$(pwd)
|
||||
|
||||
# By default, it runs all e2e test cases!
|
||||
# Use "--ginkgo.skip" to skip tests.
|
||||
# Use "--ginkgo.focus" to select tests.
|
||||
TEST_SOURCE_ROOT="$TEST_SOURCE_ROOT" "${SUBNET_EVM_PATH}"/bin/ginkgo run -procs=5 tests/precompile \
|
||||
TEST_SOURCE_ROOT="$TEST_SOURCE_ROOT" "${EVM_PATH}"/bin/ginkgo run -procs=5 tests/precompile \
|
||||
--ginkgo.vv \
|
||||
--ginkgo.label-filter="${GINKGO_LABEL_FILTER:-""}"
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# This script assumes that a Lux and EVM binaries are available in the standard location
|
||||
# This script assumes that an Luxd and Subnet-EVM binaries are available in the standard location
|
||||
# within the $GOPATH
|
||||
# The Lux and PluginDir paths can be specified via the environment variables used in ./scripts/run.sh.
|
||||
# The Luxd and PluginDir paths can be specified via the environment variables used in ./scripts/run.sh.
|
||||
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
|
||||
source "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
EXTRA_ARGS=()
|
||||
LUXD_BUILD_PATH="${LUXD_BUILD_PATH:-}"
|
||||
@@ -20,4 +20,4 @@ if [[ -n "${LUXD_BUILD_PATH}" ]]; then
|
||||
echo "Running with extra args:" "${EXTRA_ARGS[@]}"
|
||||
fi
|
||||
|
||||
"${SUBNET_EVM_PATH}"/bin/ginkgo -vv --label-filter="${GINKGO_LABEL_FILTER:-}" ./tests/warp -- "${EXTRA_ARGS[@]}"
|
||||
"${EVM_PATH}"/bin/ginkgo -vv --label-filter="${GINKGO_LABEL_FILTER:-}" ./tests/warp -- "${EXTRA_ARGS[@]}"
|
||||
|
||||
@@ -11,12 +11,12 @@ if ! [[ "$0" =~ scripts/run_simulator.sh ]]; then
|
||||
exit 255
|
||||
fi
|
||||
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
# Load the constants
|
||||
source "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
run_simulator() {
|
||||
#################################
|
||||
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Assume the system-installed task is compatible with the taskfile version
|
||||
if command -v task > /dev/null 2>&1; then
|
||||
exec task "${@}"
|
||||
else
|
||||
go run github.com/go-task/task/v3/cmd/[email protected] "${@}"
|
||||
fi
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Validates the construction of the antithesis images by:
|
||||
#
|
||||
# 1. Building the antithesis test images
|
||||
# 2. Extracting the docker compose configuration from the config image
|
||||
# 3. Running the workload and its target network without error for a minute
|
||||
# 4. Stopping the workload and its target network
|
||||
#
|
||||
|
||||
# e.g.,
|
||||
# ./scripts/tests.build_antithesis_images.sh # Test build of antithesis images
|
||||
# DEBUG=1 ./scripts/tests.build_antithesis_images.sh # Retain the temporary compose path for troubleshooting
|
||||
|
||||
EVM_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
|
||||
|
||||
# Discover the default tag that will be used for the image
|
||||
source "${EVM_PATH}"/scripts/constants.sh
|
||||
export IMAGE_TAG="${DOCKERHUB_TAG}"
|
||||
|
||||
# Build the images
|
||||
bash -x "${EVM_PATH}"/scripts/build_antithesis_images.sh
|
||||
|
||||
# Test the images
|
||||
LUXD_CLONE_PATH="${LUXD_CLONE_PATH:-${EVM_PATH}/luxd}"
|
||||
export IMAGE_NAME="antithesis-evm-config"
|
||||
export DEBUG="${DEBUG:-}"
|
||||
set -x
|
||||
# shellcheck source=/dev/null
|
||||
. "${LUXD_CLONE_PATH}"/scripts/lib_test_antithesis_images.sh
|
||||
@@ -5,12 +5,12 @@ set -euo pipefail
|
||||
# Sanity check the image build by attempting to build and run the image without error.
|
||||
|
||||
# Directory above this script
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
# Load the constants
|
||||
source "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
source "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
build_and_test() {
|
||||
local imagename="${1}"
|
||||
|
||||
@@ -7,7 +7,7 @@ if ! [[ "$0" =~ scripts/update_luxd_version.sh ]]; then
|
||||
exit 255
|
||||
fi
|
||||
|
||||
SUBNET_EVM_PATH=$(
|
||||
EVM_PATH=$(
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
cd .. && pwd
|
||||
)
|
||||
@@ -16,25 +16,28 @@ SUBNET_EVM_PATH=$(
|
||||
VERSION="${1:-}"
|
||||
|
||||
if [[ -n "${VERSION}" ]]; then
|
||||
echo "Ensuring Lux version $VERSION in go.mod"
|
||||
go get "github.com/luxfi/node@${VERSION}"
|
||||
echo "Ensuring Luxd version $VERSION in go.mod"
|
||||
go get "github.com/luxfi/luxd@${VERSION}"
|
||||
go mod tidy
|
||||
fi
|
||||
|
||||
# Discover LUX_VERSION
|
||||
. "$SUBNET_EVM_PATH"/scripts/constants.sh
|
||||
. "$EVM_PATH"/scripts/constants.sh
|
||||
|
||||
# The full SHA is required for versioning custom actions.
|
||||
CURL_ARGS=(curl -s)
|
||||
if [[ -n "${GITHUB_TOKEN:-}" ]]; then
|
||||
# Using an auth token avoids being rate limited when run in CI
|
||||
CURL_ARGS+=(-H "Authorization: token ${GITHUB_TOKEN}")
|
||||
else
|
||||
echo "No GITHUB_TOKEN found, using unauthenticated requests"
|
||||
fi
|
||||
CURL_URL="https://api.github.com/repos/luxfi/node/commits/${LUX_VERSION}"
|
||||
FULL_LUX_VERSION="$("${CURL_ARGS[@]}" "${CURL_URL}" | grep '"sha":' | head -n1 | cut -d'"' -f4)"
|
||||
|
||||
GIT_COMMIT=$("${CURL_ARGS[@]}" "https://api.github.com/repos/luxfi/luxd/commits/${LUX_VERSION}")
|
||||
FULL_LUX_VERSION="$(grep -m1 '"sha":' <<< "${GIT_COMMIT}" | cut -d'"' -f4)"
|
||||
|
||||
# Ensure the custom action version matches the lux version
|
||||
WORKFLOW_PATH=".github/workflows/tests.yml"
|
||||
CUSTOM_ACTION="luxfi/node/.github/actions/run-monitored-tmpnet-cmd"
|
||||
echo "Ensuring Lux version ${FULL_LUX_VERSION} for ${CUSTOM_ACTION} custom action in ${WORKFLOW_PATH} "
|
||||
CUSTOM_ACTION="luxfi/luxd/.github/actions/run-monitored-tmpnet-cmd"
|
||||
echo "Ensuring Luxd version ${FULL_LUX_VERSION} for ${CUSTOM_ACTION} custom action in ${WORKFLOW_PATH} "
|
||||
sed -i.bak "s|\(uses: ${CUSTOM_ACTION}\)@.*|\1@${FULL_LUX_VERSION}|g" "${WORKFLOW_PATH}" && rm -f "${WORKFLOW_PATH}.bak"
|
||||
@@ -0,0 +1,59 @@
|
||||
!accounts/abi/abi_extra_test.go
|
||||
!accounts/abi/bind/bind_extra.go
|
||||
!accounts/abi/bind/precompilebind/*
|
||||
!cmd/simulator/*
|
||||
!consensus/dummy/*
|
||||
!core/blockchain_ext.go
|
||||
!core/blockchain_ext_test.go
|
||||
!core/blockchain_log_test.go
|
||||
!core/blockchain_test.go
|
||||
!core/bounded_buffer.go
|
||||
!core/coretest/test_indices.go
|
||||
!core/extstate/extstatetest/test_statedb.go
|
||||
!core/extstate/statedb.go
|
||||
!core/extstate/test_statedb.go
|
||||
!core/fifo_cache.go
|
||||
!core/genesis_extra_test.go
|
||||
!core/main_test.go
|
||||
!core/predicate_check.go
|
||||
!core/predicate_check_test.go
|
||||
!core/state/database_test.go
|
||||
!core/state/firewood_database.go
|
||||
!core/state/database_test.go
|
||||
!core/state/snapshot/snapshot_ext.go
|
||||
!core/state/trie_prefetcher_extra_test.go
|
||||
!core/state_manager_test.go
|
||||
!core/state_processor_ext.go
|
||||
!core/state_processor_ext_test.go
|
||||
!core/test_blockchain.go
|
||||
!eth/chain_with_final_block.go
|
||||
!eth/gasprice/fee_info_provider_test.go
|
||||
!eth/tracers/api_extra_test.go
|
||||
!ethclient/client_interface_test.go
|
||||
!internal/ethapi/api_extra.go
|
||||
!internal/ethapi/api_extra_test.go
|
||||
!internal/testutils/*
|
||||
!plugin/evm/customtypes/*
|
||||
!triedb/firewood/*
|
||||
|
||||
accounts/*
|
||||
cmd/*
|
||||
consensus/*
|
||||
core/*
|
||||
eth/*
|
||||
ethclient/*
|
||||
internal/*
|
||||
miner/*
|
||||
node/*
|
||||
params/config.go
|
||||
params/config_test.go
|
||||
params/denomination.go
|
||||
params/network_params.go
|
||||
params/version.go
|
||||
plugin/evm/customtypes/rlp_fuzzer_test.go
|
||||
rpc/*
|
||||
signer/*
|
||||
tests/init.go
|
||||
tests/rlp_test_util.go
|
||||
tests/state_test_util.go
|
||||
triedb/*
|
||||
Reference in New Issue
Block a user