Skip to content

Commit 58533e4

Browse files
authored
Merge pull request #100 from defi-wonderland/fix/merge-develop-to-beacon
fix: merge develop to beacon
2 parents 62f07eb + 6a989aa commit 58533e4

File tree

125 files changed

+4768
-4433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+4768
-4433
lines changed

.circleci/config.yml

Lines changed: 37 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -828,55 +828,47 @@ jobs:
828828
when: always
829829

830830
go-test:
831-
parameters:
832-
module:
833-
description: Go Module Name
834-
type: string
835-
uses_artifacts:
836-
description: Uses contract artifacts
837-
type: boolean
838-
default: false
839-
docker:
840-
- image: <<pipeline.parameters.ci_builder_image>>
841-
resource_class: xlarge
842-
circleci_ip_ranges: true
831+
machine: true
832+
resource_class: ethereum-optimism/latitude-1
843833
steps:
844834
- checkout
845-
- restore_cache:
846-
name: Restore Go modules cache
847-
key: gomod-{{ checksum "go.sum" }}
848-
- restore_cache:
849-
name: Restore Go build cache
850-
keys:
851-
- golang-build-cache-test-<<parameters.module>>-{{ checksum "go.sum" }}
852-
- golang-build-cache-test-
853-
- when:
854-
condition: <<parameters.uses_artifacts>>
855-
steps:
856-
- attach_workspace: { at: "." }
857-
- run:
858-
name: Install components
859-
command: |
860-
go version
861-
go install gotest.tools/[email protected]
862-
- run:
863-
name: prep results dir
864-
command: mkdir -p /tmp/test-results && mkdir -p /tmp/testlogs
835+
- attach_workspace:
836+
at: "."
865837
- run:
866838
name: run tests
867839
command: |
868-
ENABLE_ANVIL=true SEPOLIA_RPC_URL="https://ci-sepolia-l1.optimism.io" gotestsum --format=testname --junitfile=/tmp/test-results/<<parameters.module>>.xml --jsonfile=/tmp/testlogs/log.json \
869-
-- -parallel=8 -coverpkg=github.com/ethereum-optimism/optimism/... -coverprofile=coverage.out ./...
870-
working_directory: <<parameters.module>>
871-
- save_cache:
872-
name: Save Go build cache
873-
key: golang-build-cache-test-<<parameters.module>>-{{ checksum "go.sum" }}
874-
paths:
875-
- "/root/.cache/go-build"
840+
mkdir -p ./tmp/test-results && mkdir -p ./tmp/testlogs
841+
842+
packages=(
843+
op-batcher
844+
op-chain-ops
845+
op-node
846+
op-proposer
847+
op-challenger
848+
op-dispute-mon
849+
op-conductor
850+
op-program
851+
op-service
852+
op-supervisor
853+
packages/contracts-bedrock/scripts/checks/semver-natspec
854+
)
855+
formatted_packages=""
856+
for package in "${packages[@]}"; do
857+
formatted_packages="$formatted_packages ./$package/..."
858+
done
859+
860+
export ENABLE_ANVIL=true
861+
export SEPOLIA_RPC_URL="https://ci-sepolia-l1-archive.optimism.io"
862+
863+
gotestsum --format=testname \
864+
--junitfile=./tmp/test-results/results.xml \
865+
--jsonfile=./tmp/testlogs/log.json \
866+
-- -coverpkg=github.com/ethereum-optimism/optimism/... \
867+
-coverprofile=coverage.out $formatted_packages
876868
- store_test_results:
877-
path: /tmp/test-results
869+
path: ./tmp/test-results
878870
- store_artifacts:
879-
path: /tmp/testlogs
871+
path: ./tmp/testlogs
880872
when: always
881873

882874
go-e2e-test:
@@ -1355,30 +1347,8 @@ workflows:
13551347
uses_artifacts: true
13561348
requires: ["go-mod-download", "contracts-bedrock-build"]
13571349
- go-test:
1358-
name: <<matrix.module>>-tests
1350+
name: go-test-all
13591351
requires:
1360-
- go-mod-download
1361-
matrix:
1362-
parameters:
1363-
module:
1364-
- op-batcher
1365-
- op-node
1366-
- op-proposer
1367-
- op-challenger
1368-
- op-dispute-mon
1369-
- op-conductor
1370-
- op-program
1371-
- op-service
1372-
- op-supervisor
1373-
- go-test:
1374-
name: semver-natspec-tests
1375-
module: packages/contracts-bedrock/scripts/checks/semver-natspec
1376-
- go-test:
1377-
name: op-chain-ops-tests
1378-
module: op-chain-ops
1379-
uses_artifacts: true
1380-
requires:
1381-
- go-mod-download
13821352
- contracts-bedrock-build
13831353
- go-test-kurtosis:
13841354
name: op-chain-ops-integration
@@ -1405,9 +1375,7 @@ workflows:
14051375
requires:
14061376
- contracts-bedrock-build
14071377
- cannon-prestate
1408-
- op-program-compat:
1409-
requires:
1410-
- op-program-tests
1378+
- op-program-compat
14111379
- bedrock-go-tests:
14121380
requires:
14131381
- go-mod-download
@@ -1417,18 +1385,8 @@ workflows:
14171385
- check-generated-mocks-op-node
14181386
- check-generated-mocks-op-service
14191387
- go-mod-download
1420-
- op-batcher-tests
1421-
- op-chain-ops-tests
14221388
- op-chain-ops-integration
1423-
- op-node-tests
1424-
- op-proposer-tests
1425-
- op-challenger-tests
1426-
- op-dispute-mon-tests
1427-
- op-conductor-tests
1428-
- op-program-tests
14291389
- op-program-compat
1430-
- op-service-tests
1431-
- op-supervisor-tests
14321390
- op-e2e-HTTP-tests
14331391
- op-e2e-fault-proof-tests
14341392
- op-e2e-action-tests
@@ -1438,6 +1396,7 @@ workflows:
14381396
- op-program-docker-build
14391397
- op-supervisor-docker-build
14401398
- proofs-tools-docker-build
1399+
- go-test-all
14411400
- docker-build:
14421401
name: <<matrix.docker_name>>-docker-build
14431402
docker_tags: <<pipeline.git.revision>>,<<pipeline.git.branch>>

cannon/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ cannon32-impl:
2121
cannon64-impl:
2222
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build --tags=cannon64 -v $(LDFLAGS) -o ./bin/cannon64-impl .
2323

24+
# Note: This target is used by ./scripts/build-legacy-cannons.sh
25+
# It should build the individual versions of cannons and copy them into place in hte multicannon/embeds directory
26+
# Ideally, preserve backwards compatibility with this behaviour but if it needs to change, build-legacy-cannons.sh will
27+
# need to be updated to account for different behaviours in different versions.
2428
cannon-embeds: cannon32-impl cannon64-impl
2529
# singlethreaded-v2
2630
@cp bin/cannon32-impl ./multicannon/embeds/cannon-2
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package exec
2+
3+
// FYI: https://en.wikibooks.org/wiki/MIPS_Assembly/Register_File
4+
//
5+
// https://refspecs.linuxfoundation.org/elf/mipsabi.pdf
6+
const (
7+
// syscall number; 1st return value
8+
RegV0 = 2
9+
// syscall arguments; returned unmodified
10+
RegA0 = 4
11+
RegA1 = 5
12+
RegA2 = 6
13+
// 4th syscall argument; set to 0/1 for success/error
14+
RegA3 = 7
15+
)
16+
17+
// FYI: https://web.archive.org/web/20231223163047/https://www.linux-mips.org/wiki/Syscall
18+
19+
const (
20+
RegSyscallNum = RegV0
21+
RegSyscallErrno = RegA3
22+
RegSyscallRet1 = RegV0
23+
RegSyscallParam1 = RegA0
24+
RegSyscallParam2 = RegA1
25+
RegSyscallParam3 = RegA2
26+
RegSyscallParam4 = RegA3
27+
)

cannon/mipsevm/exec/mips_syscalls.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ const (
9999
)
100100

101101
func GetSyscallArgs(registers *[32]Word) (syscallNum, a0, a1, a2, a3 Word) {
102-
syscallNum = registers[2] // v0
102+
syscallNum = registers[RegSyscallNum] // v0
103103

104-
a0 = registers[4]
105-
a1 = registers[5]
106-
a2 = registers[6]
107-
a3 = registers[7]
104+
a0 = registers[RegSyscallParam1]
105+
a1 = registers[RegSyscallParam2]
106+
a2 = registers[RegSyscallParam3]
107+
a3 = registers[RegSyscallParam4]
108108

109109
return syscallNum, a0, a1, a2, a3
110110
}
@@ -281,8 +281,8 @@ func HandleSysFcntl(a0, a1 Word) (v0, v1 Word) {
281281
}
282282

283283
func HandleSyscallUpdates(cpu *mipsevm.CpuScalars, registers *[32]Word, v0, v1 Word) {
284-
registers[2] = v0
285-
registers[7] = v1
284+
registers[RegSyscallRet1] = v0
285+
registers[RegSyscallErrno] = v1
286286

287287
cpu.PC = cpu.NextPC
288288
cpu.NextPC = cpu.NextPC + 4

cannon/mipsevm/multithreaded/mips.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ func (m *InstrumentedState) handleSyscall() error {
5959

6060
newThread.Registers[29] = a1
6161
// the child will perceive a 0 value as returned value instead, and no error
62-
newThread.Registers[2] = 0
63-
newThread.Registers[7] = 0
62+
newThread.Registers[exec.RegSyscallRet1] = 0
63+
newThread.Registers[exec.RegSyscallErrno] = 0
6464
m.state.NextThreadId++
6565

6666
// Preempt this thread for the new one. But not before updating PCs
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
SCRIPTS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
4+
5+
# This script builds a version of the cannon executable that includes support for both current and legacy state versions.
6+
# Each cannon release is built
7+
8+
TMP_DIR=$(mktemp -d)
9+
function cleanup() {
10+
rm -rf "${TMP_DIR}"
11+
}
12+
trap cleanup EXIT
13+
echo "Using temp dir: ${TMP_DIR}"
14+
cd "${TMP_DIR}"
15+
16+
# Need to check out a fresh copy of the monorepo so we can switch to specific tags without it also affecting the
17+
# contents of this script (which is checked into the repo).
18+
git clone https://github.com/ethereum-optimism/optimism --recurse-submodules
19+
20+
CANNON_DIR="${SCRIPTS_DIR}/../"
21+
EMBEDS_DIR="${CANNON_DIR}/multicannon/embeds"
22+
LOGS_DIR="${CANNON_DIR}/temp/logs"
23+
REPO_DIR="${TMP_DIR}/optimism"
24+
BIN_DIR="${REPO_DIR}/cannon/multicannon/embeds"
25+
26+
mkdir -p "${LOGS_DIR}"
27+
28+
cd "${REPO_DIR}"
29+
30+
function buildVersion() {
31+
TAG=${1}
32+
LOG_FILE="${LOGS_DIR}/build-$(echo "${TAG}" | cut -c 8-).txt"
33+
echo "Building Version: ${TAG} Logs: ${LOG_FILE}"
34+
git checkout "${TAG}" > "${LOG_FILE}" 2>&1
35+
git submodule update --init --recursive >> "${LOG_FILE}" 2>&1
36+
rm -rf "${BIN_DIR}/cannon-"*
37+
make -C "${REPO_DIR}/cannon" cannon-embeds >> "${LOG_FILE}" 2>&1
38+
cp "${BIN_DIR}/cannon-"* "${EMBEDS_DIR}/"
39+
echo "Built ${TAG} with versions:"
40+
(cd "${BIN_DIR}" && ls cannon-*)
41+
}
42+
43+
# Build each release of cannon from earliest to latest. Releases with qualifiers (e.g. `-rc`, `-alpha` etc are skipped.
44+
# If the same state version is supported by multiple version tags built, the build from the last tag listed will be used
45+
# The currently checked out code is built after this list to include the currently supported state versions and
46+
# build the final cannon executable.
47+
VERSIONS=$(git tag --list 'cannon/v*' --sort taggerdate | grep -v -- '-')
48+
for VERSION in ${VERSIONS}
49+
do
50+
buildVersion "$VERSION"
51+
done
52+
53+
cd "${CANNON_DIR}"
54+
LOG_FILE="${LOGS_DIR}/build-current.txt"
55+
echo "Building current version of cannon Logs: ${LOG_FILE}"
56+
make cannon > "${LOG_FILE}" 2>&1
57+
58+
echo "All cannon versions successfully built and available in ${EMBEDS_DIR}"
59+
"${CANNON_DIR}/bin/cannon" list

0 commit comments

Comments
 (0)