Skip to content

Commit a0a129d

Browse files
committed
script to buidl custom besu image with gasless sequencer
1 parent 3942cb0 commit a0a129d

File tree

3 files changed

+88
-68
lines changed

3 files changed

+88
-68
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,6 @@ __pycache__/
143143
!prover/**/testdata/**/*.csv
144144
!prover/**/utils/profiling
145145
!prover/**/verifying_key.bin
146-
!/sdk/src/lib/compressor/bin
146+
!/sdk/src/lib/compressor/bin
147+
148+
custom-besu-package

build-rln-enabled-sequencer.sh

Lines changed: 81 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -e
33

4-
echo "🚀 Building Simple RLN-Enabled Linea Sequencer"
4+
echo "🚀 Building RLN-Enabled Sequencer"
55

66
# Colors for output
77
RED='\033[0;31m'
@@ -10,36 +10,29 @@ YELLOW='\033[1;33m'
1010
BLUE='\033[0;34m'
1111
NC='\033[0m' # No Color
1212

13-
# Build paths - Updated for correct directory structure
13+
# Build paths
1414
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1515
LINEA_SEQUENCER_DIR="${SCRIPT_DIR}/besu-plugins/linea-sequencer"
1616
STATUS_RLN_PROVER_DIR="/Users/nadeem/dev/status/linea/status-rln-prover"
17-
CUSTOM_BESU_DIR="${SCRIPT_DIR}/custom-besu-package"
18-
LINEA_BESU_DIR="/Users/nadeem/dev/status/linea/linea-besu"
17+
CUSTOM_BESU_DIR="${SCRIPT_DIR}/custom-besu-minimal"
1918

2019
echo -e "${BLUE}📁 Working directories:${NC}"
21-
echo -e " Linea Sequencer: ${LINEA_SEQUENCER_DIR}"
22-
echo -e " Status RLN Prover: ${STATUS_RLN_PROVER_DIR}"
23-
echo -e " Custom Besu Package: ${CUSTOM_BESU_DIR}"
24-
echo -e " Linea Besu Repository: ${LINEA_BESU_DIR}"
25-
26-
# Check if directories exist
27-
for dir in "$LINEA_SEQUENCER_DIR" "$STATUS_RLN_PROVER_DIR" "$LINEA_BESU_DIR"; do
28-
if [[ ! -d "$dir" ]]; then
29-
echo -e "${RED}❌ Error: Directory not found: $dir${NC}"
30-
exit 1
31-
fi
32-
done
20+
echo -e " Script: ${SCRIPT_DIR}"
21+
echo -e " Sequencer: ${LINEA_SEQUENCER_DIR}"
22+
echo -e " RLN Prover: ${STATUS_RLN_PROVER_DIR}"
23+
echo -e " Custom Besu: ${CUSTOM_BESU_DIR}"
24+
25+
# Use the exact same image version as the official Linea setup
26+
BESU_PACKAGE_TAG="beta-v2.1-rc16.2-20250521134911-f6cb0f2"
27+
BESU_BASE_IMAGE="consensys/linea-besu-package:${BESU_PACKAGE_TAG}"
3328

3429
echo -e "${BLUE}🦀 Building RLN Bridge Rust Library for Linux...${NC}"
3530
cd "${LINEA_SEQUENCER_DIR}/sequencer/src/main/rust/rln_bridge"
3631

37-
# Check if Linux library already exists
3832
RLN_LIB_FILE="${LINEA_SEQUENCER_DIR}/sequencer/src/main/rust/rln_bridge/target/x86_64-unknown-linux-gnu/release/librln_bridge.so"
3933

4034
if [[ ! -f "$RLN_LIB_FILE" ]]; then
4135
echo -e "${YELLOW}🐳 Cross-compiling Rust library for Linux x86-64...${NC}"
42-
# Use Docker to cross-compile for Linux
4336
docker run --rm --platform linux/amd64 \
4437
-v "$(pwd)":/workspace \
4538
-w /workspace \
@@ -51,26 +44,25 @@ if [[ ! -f "$RLN_LIB_FILE" ]]; then
5144
cargo build --release --target x86_64-unknown-linux-gnu
5245
"
5346
fi
47+
5448
if [[ ! -f "$RLN_LIB_FILE" ]]; then
55-
echo -e "${RED}❌ Error: Linux RLN library not found at: $RLN_LIB_FILE${NC}"
49+
echo -e "${RED}❌ Error: Linux RLN library not found: $RLN_LIB_FILE${NC}"
5650
exit 1
5751
fi
5852

59-
# Verify it's actually a Linux .so file
60-
LIB_INFO=$(file "$RLN_LIB_FILE")
61-
if echo "$LIB_INFO" | grep -q "ELF.*x86-64"; then
62-
echo -e "${GREEN}✅ RLN Bridge library built for Linux: $RLN_LIB_FILE${NC}"
63-
else
64-
echo -e "${RED}❌ Error: Library is not Linux x86-64 format: $LIB_INFO${NC}"
65-
exit 1
66-
fi
53+
echo -e "${GREEN}✅ RLN Bridge library ready: $RLN_LIB_FILE${NC}"
6754

68-
echo -e "${BLUE}☕ Building Custom Sequencer JAR...${NC}"
55+
echo -e "${BLUE}☕ Building Custom Sequencer JAR with Dependencies...${NC}"
6956
cd "$SCRIPT_DIR"
70-
./gradlew clean :besu-plugins:linea-sequencer:sequencer:build -x test -x checkSpdxHeader -x spotlessJavaCheck -x spotlessGroovyGradleCheck --no-daemon
57+
# Build with distPlugin to include dependencies not provided by Besu
58+
./gradlew clean :besu-plugins:linea-sequencer:sequencer:distPlugin -x test -x checkSpdxHeader -x spotlessJavaCheck -x spotlessGroovyGradleCheck --no-daemon
7159

72-
# Find the built JAR
60+
# Look for both JAR and ZIP files from distPlugin
7361
SEQUENCER_JAR=$(find "${LINEA_SEQUENCER_DIR}/sequencer/build/libs" -name "linea-sequencer-*.jar" | head -1)
62+
SEQUENCER_DIST=$(find "${LINEA_SEQUENCER_DIR}/sequencer/build/distributions" -name "linea-sequencer-*.zip" | head -1)
63+
64+
echo -e "${YELLOW} Found JAR: $SEQUENCER_JAR${NC}"
65+
echo -e "${YELLOW} Found Distribution: $SEQUENCER_DIST${NC}"
7466
if [[ ! -f "$SEQUENCER_JAR" ]]; then
7567
echo -e "${RED}❌ Error: Sequencer JAR not found!${NC}"
7668
exit 1
@@ -88,50 +80,67 @@ if [[ ! -f "$PROVER_BINARY" ]]; then
8880
fi
8981
echo -e "${GREEN}✅ RLN Prover service built: $PROVER_BINARY${NC}"
9082

91-
echo -e "${BLUE}🐳 Building Custom Besu Docker Image...${NC}"
83+
echo -e "${BLUE}🐳 Building Minimal Custom Besu Image...${NC}"
9284
mkdir -p "$CUSTOM_BESU_DIR"
9385
cd "$CUSTOM_BESU_DIR"
9486

95-
# Get the working official image and extract its structure
96-
BESU_PACKAGE_TAG="beta-v2.1-rc16.2-20250521124830-4d89458"
87+
# Copy the files we need to the build directory first
88+
cp "$SEQUENCER_JAR" .
89+
cp "$RLN_LIB_FILE" .
90+
91+
# Extract dependencies to the current build directory (MOVED HERE!)
92+
if [[ -f "$SEQUENCER_DIST" ]]; then
93+
echo -e "${YELLOW} 📦 Extracting dependencies from distribution ZIP...${NC}"
94+
unzip -q "$SEQUENCER_DIST" -d extracted-deps/
95+
# Copy dependency JARs (excluding the main sequencer JAR) to current directory
96+
find extracted-deps/ -name "*.jar" -not -name "linea-sequencer-*" -exec cp {} . \;
97+
DEPS_COUNT=$(find extracted-deps/ -name "*.jar" -not -name "linea-sequencer-*" | wc -l)
98+
echo -e "${YELLOW} ✅ Extracted $DEPS_COUNT dependency JARs to build directory${NC}"
99+
rm -rf extracted-deps/
100+
101+
# List what we extracted for debugging
102+
echo -e "${YELLOW} Dependencies extracted:${NC}"
103+
ls -la *.jar | grep -v "$(basename "$SEQUENCER_JAR")" | head -5
104+
else
105+
echo -e "${YELLOW} ⚠️ No distribution ZIP found - dependencies may be missing${NC}"
106+
fi
107+
108+
# Extract the entire Besu distribution from official image (like your working script)
97109
echo -e "${YELLOW}📥 Extracting base Besu from official image...${NC}"
98-
docker create --name temp-besu-extract "consensys/linea-besu-package:${BESU_PACKAGE_TAG}"
110+
docker rm temp-besu-extract 2>/dev/null || true
111+
docker create --name temp-besu-extract "${BESU_BASE_IMAGE}"
99112
docker cp temp-besu-extract:/opt/besu/ ./besu/
100113
docker rm temp-besu-extract
101114

102115
# Verify all required Linea plugins are present
103116
echo -e "${YELLOW}🔍 Verifying Linea plugins...${NC}"
104-
REQUIRED_PLUGINS=(
105-
"linea-staterecovery-besu-plugin"
106-
"linea-tracer"
107-
"linea-finalized-tag-updater"
108-
"besu-shomei-plugin"
109-
)
110-
111117
echo -e " Current plugins in extracted image:"
112-
ls -la ./besu/plugins/ || echo " No plugins directory found!"
113-
114-
for plugin in "${REQUIRED_PLUGINS[@]}"; do
115-
if ls ./besu/plugins/*${plugin}*.jar 1> /dev/null 2>&1; then
116-
echo -e " ✅ Found: $plugin"
117-
else
118-
echo -e " ⚠️ Missing: $plugin (will be included from base image)"
119-
fi
120-
done
118+
ls -la ./besu/plugins/
121119

122120
# Replace the sequencer plugin with our custom one
123121
echo -e "${YELLOW}🔄 Installing custom sequencer...${NC}"
124122
rm -f ./besu/plugins/linea-sequencer-*.jar
125123
cp "$SEQUENCER_JAR" ./besu/plugins/
126124
echo -e " ✅ Installed: $(basename "$SEQUENCER_JAR")"
127125

128-
# Copy RLN native library
126+
# Install missing dependency JARs in lib directory
127+
if ls *.jar 1> /dev/null 2>&1; then
128+
echo -e "${YELLOW}📚 Installing dependency JARs...${NC}"
129+
for jar in *.jar; do
130+
if [[ "$jar" != "$(basename "$SEQUENCER_JAR")" ]]; then
131+
cp "$jar" ./besu/lib/
132+
echo -e " ✅ Installed dependency: $jar"
133+
fi
134+
done
135+
fi
136+
137+
# Copy RLN native library
129138
echo -e "${YELLOW}📚 Installing RLN native library...${NC}"
130139
mkdir -p ./besu/lib/native
131140
cp "$RLN_LIB_FILE" ./besu/lib/native/
132141
echo -e " ✅ Installed: librln_bridge.so"
133142

134-
# Update Besu startup scripts to include plugins in classpath
143+
# Update Besu startup scripts to include plugins in classpath (critical!)
135144
echo -e "${YELLOW}⚙️ Updating Besu startup scripts...${NC}"
136145
for script in besu besu.bat besu-untuned besu-untuned.bat; do
137146
if [[ -f "./besu/bin/$script" ]]; then
@@ -142,7 +151,7 @@ for script in besu besu.bat besu-untuned besu-untuned.bat; do
142151
# Windows batch files
143152
sed -i.tmp 's|CLASSPATH=%APP_HOME%\\lib\\*|CLASSPATH=%APP_HOME%\\lib\\*;%APP_HOME%\\plugins\\*|g' "./besu/bin/$script"
144153
else
145-
# Unix shell scripts
154+
# Unix shell scripts
146155
sed -i.tmp 's|CLASSPATH=\$APP_HOME/lib/\*|CLASSPATH=\$APP_HOME/lib/\*:\$APP_HOME/plugins/\*|g' "./besu/bin/$script"
147156
fi
148157
rm -f "./besu/bin/$script.tmp"
@@ -158,7 +167,7 @@ ls -la ./besu/plugins/ | grep -E "\.(jar|JAR)$" | while read -r line; do
158167
echo -e " 📦 $line"
159168
done
160169

161-
# Create simple Dockerfile
170+
# Create Dockerfile like your working script
162171
cat > Dockerfile << 'EOF'
163172
FROM ubuntu:24.04
164173
@@ -188,12 +197,17 @@ ENTRYPOINT ["besu"]
188197
HEALTHCHECK --start-period=5s --interval=5s --timeout=1s --retries=10 CMD bash -c "[ -f /tmp/pid ]"
189198
EOF
190199

191-
# Build custom Docker images
200+
# Remove old extract script - not needed with this approach
201+
rm -f extract-deps.sh
202+
203+
# Build the minimal custom image
192204
TIMESTAMP=$(date +%Y%m%d%H%M%S)
193-
BESU_IMAGE_TAG="linea-besu-custom-sequencer:${TIMESTAMP}"
205+
BESU_IMAGE_TAG="linea-besu-minimal-rln:${TIMESTAMP}"
206+
207+
echo -e "${YELLOW}🔨 Building Docker image...${NC}"
194208
docker build -t "$BESU_IMAGE_TAG" .
195209

196-
echo -e "${GREEN}Custom Besu image built: $BESU_IMAGE_TAG${NC}"
210+
echo -e "${GREEN}Minimal custom Besu image built: $BESU_IMAGE_TAG${NC}"
197211

198212
echo -e "${BLUE}🐳 Building RLN Prover Docker image...${NC}"
199213
cd "$STATUS_RLN_PROVER_DIR"
@@ -208,26 +222,30 @@ if [[ -f "$COMPOSE_FILE" ]]; then
208222
# Create backup
209223
cp "$COMPOSE_FILE" "${COMPOSE_FILE}.backup.$(date +%Y%m%d%H%M%S)"
210224

211-
# Update image tags
212-
sed -i.tmp "s|image: linea-besu-custom-sequencer:.*|image: ${BESU_IMAGE_TAG}|g" "$COMPOSE_FILE"
225+
# Update only the sequencer and l2-node-besu images
226+
sed -i.tmp "s|image: linea-besu.*:.*|image: ${BESU_IMAGE_TAG}|g" "$COMPOSE_FILE"
213227
sed -i.tmp "s|image: status-rln-prover:.*|image: ${RLN_PROVER_TAG}|g" "$COMPOSE_FILE"
214228
rm -f "${COMPOSE_FILE}.tmp"
215229

216-
echo -e "${GREEN}✅ Updated Docker Compose with new images:${NC}"
230+
echo -e "${GREEN}✅ Updated Docker Compose with minimal images:${NC}"
217231
echo -e " Besu: $BESU_IMAGE_TAG"
218232
echo -e " RLN Prover: $RLN_PROVER_TAG"
219233
fi
220234

221-
echo -e "${GREEN}🎉 Build Complete!${NC}"
235+
# Clean up build directory
236+
cd "$SCRIPT_DIR"
237+
rm -rf "$CUSTOM_BESU_DIR"
238+
239+
echo -e "${GREEN}🎉 Minimal Build Complete!${NC}"
222240
echo -e "${BLUE}📋 Built Components:${NC}"
223241
echo -e " Custom Sequencer JAR: $(basename "$SEQUENCER_JAR")"
224242
echo -e " RLN Library: librln_bridge.so (Linux x86-64)"
225-
echo -e " Besu Image: $BESU_IMAGE_TAG"
243+
echo -e " Minimal Besu Image: $BESU_IMAGE_TAG"
226244
echo -e " RLN Prover Image: $RLN_PROVER_TAG"
227245
echo
228246
echo -e "${YELLOW}🚀 Next Steps:${NC}"
229247
echo -e " 1. Run: ${GREEN}make start-env-with-rln${NC}"
230-
echo -e " 2. Test gasless transactions with your custom sequencer"
248+
echo -e " 2. Test gasless transactions"
231249
echo -e " 3. Check logs: ${GREEN}docker logs sequencer${NC}"
232250
echo
233251
echo -e "${BLUE}🔧 Environment Variables:${NC}"

docker/compose-spec-l2-services-rln.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
rln-prover:
88
hostname: rln-prover
99
container_name: rln-prover
10-
image: status-rln-prover:20250624221538
10+
image: status-rln-prover:20250828133212
1111
profiles: [ "l2", "l2-bc", "debug", "external-to-monorepo", "rln" ]
1212
ports:
1313
- "50051:50051" # RLN proof service
@@ -41,7 +41,7 @@ services:
4141
karma-service:
4242
hostname: karma-service
4343
container_name: karma-service
44-
image: status-rln-prover:20250624221538
44+
image: status-rln-prover:20250828133212
4545
profiles: [ "l2", "l2-bc", "debug", "external-to-monorepo", "rln" ]
4646
ports:
4747
- "50053:50052"
@@ -68,7 +68,7 @@ services:
6868
sequencer:
6969
hostname: sequencer
7070
container_name: sequencer
71-
image: linea-besu-custom-sequencer:20250624221538
71+
image: linea-besu-minimal-rln:20250828133212
7272
profiles: [ "l2", "l2-bc", "debug", "external-to-monorepo" ]
7373
ports:
7474
- "8545:8545"
@@ -169,7 +169,7 @@ services:
169169
l2-node-besu:
170170
hostname: l2-node-besu
171171
container_name: l2-node-besu
172-
image: linea-besu-custom-sequencer:20250624221538
172+
image: linea-besu-minimal-rln:20250828133212
173173
profiles: [ "l2", "l2-bc", "debug", "external-to-monorepo" ]
174174
depends_on:
175175
sequencer:

0 commit comments

Comments
 (0)