11#! /bin/bash
22set -e
33
4- echo " 🚀 Building Simple RLN-Enabled Linea Sequencer"
4+ echo " 🚀 Building RLN-Enabled Sequencer"
55
66# Colors for output
77RED=' \033[0;31m'
@@ -10,36 +10,29 @@ YELLOW='\033[1;33m'
1010BLUE=' \033[0;34m'
1111NC=' \033[0m' # No Color
1212
13- # Build paths - Updated for correct directory structure
13+ # Build paths
1414SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
1515LINEA_SEQUENCER_DIR=" ${SCRIPT_DIR} /besu-plugins/linea-sequencer"
1616STATUS_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
2019echo -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
3429echo -e " ${BLUE} 🦀 Building RLN Bridge Rust Library for Linux...${NC} "
3530cd " ${LINEA_SEQUENCER_DIR} /sequencer/src/main/rust/rln_bridge"
3631
37- # Check if Linux library already exists
3832RLN_LIB_FILE=" ${LINEA_SEQUENCER_DIR} /sequencer/src/main/rust/rln_bridge/target/x86_64-unknown-linux-gnu/release/librln_bridge.so"
3933
4034if [[ ! -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 "
5346fi
47+
5448if [[ ! -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
5751fi
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} "
6956cd " $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
7361SEQUENCER_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} "
7466if [[ ! -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
8880fi
8981echo -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} "
9284mkdir -p " $CUSTOM_BESU_DIR "
9385cd " $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)
97109echo -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} "
99112docker cp temp-besu-extract:/opt/besu/ ./besu/
100113docker rm temp-besu-extract
101114
102115# Verify all required Linea plugins are present
103116echo -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-
111117echo -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
123121echo -e " ${YELLOW} 🔄 Installing custom sequencer...${NC} "
124122rm -f ./besu/plugins/linea-sequencer-* .jar
125123cp " $SEQUENCER_JAR " ./besu/plugins/
126124echo -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
129138echo -e " ${YELLOW} 📚 Installing RLN native library...${NC} "
130139mkdir -p ./besu/lib/native
131140cp " $RLN_LIB_FILE " ./besu/lib/native/
132141echo -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!)
135144echo -e " ${YELLOW} ⚙️ Updating Besu startup scripts...${NC} "
136145for 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 "
159168done
160169
161- # Create simple Dockerfile
170+ # Create Dockerfile like your working script
162171cat > Dockerfile << 'EOF '
163172FROM ubuntu:24.04
164173
@@ -188,12 +197,17 @@ ENTRYPOINT ["besu"]
188197HEALTHCHECK --start-period=5s --interval=5s --timeout=1s --retries=10 CMD bash -c "[ -f /tmp/pid ]"
189198EOF
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
192204TIMESTAMP=$( 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} "
194208docker 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
198212echo -e " ${BLUE} 🐳 Building RLN Prover Docker image...${NC} "
199213cd " $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 "
219233fi
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} "
222240echo -e " ${BLUE} 📋 Built Components:${NC} "
223241echo -e " Custom Sequencer JAR: $( basename " $SEQUENCER_JAR " ) "
224242echo -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 "
226244echo -e " RLN Prover Image: $RLN_PROVER_TAG "
227245echo
228246echo -e " ${YELLOW} 🚀 Next Steps:${NC} "
229247echo -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"
231249echo -e " 3. Check logs: ${GREEN} docker logs sequencer${NC} "
232250echo
233251echo -e " ${BLUE} 🔧 Environment Variables:${NC} "
0 commit comments