73 lines
2.6 KiB
Bash
Executable File
73 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Tighten Besu layered tx-pool on VMID 2103 (Thirdweb admin core) only, so a single
|
|
# sender cannot fill the local pool with far-future / gap nonces (e.g. 15 when next is 1).
|
|
#
|
|
# - Sets tx-pool-max-future-by-sender=1 (do NOT use 0: Besu 24+ can log IndexOutOfBounds in
|
|
# SparseTransactions on new blocks when 0 is set; observed 2026-04-22 on 2103).
|
|
# - Restarts besu-rpc. Optional: purge local pool after restart (arg --purge) via clear-rpc-2103-txpool.
|
|
#
|
|
# Usage: ./scripts/maintenance/apply-2103-thirdweb-strict-tx-pool.sh [--purge] [--value N]
|
|
# --value N default 1
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
# shellcheck disable=SC1091
|
|
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
|
|
|
|
VAL="${VAL:-1}"
|
|
PURGE=false
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--purge) PURGE=true; shift ;;
|
|
--value) VAL="$2"; shift 2 ;;
|
|
*) echo "Unknown: $1" >&2; exit 2 ;;
|
|
esac
|
|
done
|
|
|
|
HOST="${PROXMOX_R630_01:-${PROXMOX_HOST_R630_01:-192.168.11.11}}"
|
|
VMID=2103
|
|
CFG_PCT="/etc/besu/config-rpc.toml"
|
|
SSH="root@${HOST}"
|
|
|
|
echo "=== 2103 tx-pool: tx-pool-max-future-by-sender=$VAL (Thirdweb path only) ==="
|
|
echo "Host: $HOST LXC: $VMID config: $CFG_PCT (inside LXC)"
|
|
echo ""
|
|
|
|
if ! ssh -o ConnectTimeout=8 -o StrictHostKeyChecking=no "$SSH" "pct list | grep -q '$VMID'"; then
|
|
echo "VMID $VMID not on $HOST" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$VAL" -le 0 ]]; then
|
|
echo "Refusing: value 0 is unsafe on current Besu (SparseTransactions/IndexOutOfBounds). Use 1 or more." >&2
|
|
exit 1
|
|
fi
|
|
|
|
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no "$SSH" "pct exec $VMID -- bash -c '
|
|
set -e
|
|
cp -a $CFG_PCT ${CFG_PCT}.bak.\$(date +%Y%m%d%H%M%S)
|
|
if ! grep -qE \"^tx-pool-max-future-by-sender=\" $CFG_PCT; then
|
|
echo \"[ERROR] $CFG_PCT has no tx-pool-max-future-by-sender= line; add it manually.\" >&2
|
|
exit 1
|
|
fi
|
|
sed -i \"s/^tx-pool-max-future-by-sender=.*/tx-pool-max-future-by-sender=$VAL/\" $CFG_PCT
|
|
grep -E \"^tx-pool-max-future-by-sender=\" $CFG_PCT
|
|
systemctl restart besu-rpc
|
|
sleep 3
|
|
systemctl is-active besu-rpc
|
|
'"
|
|
|
|
if [[ "$PURGE" == "true" ]]; then
|
|
echo ""
|
|
echo "=== Purging 2103 local pool ==="
|
|
"${PROJECT_ROOT}/scripts/clear-rpc-2103-txpool.sh"
|
|
else
|
|
echo "Done. Optional: --purge to also run clear-rpc-2103-txpool.sh"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Next: from Thirdweb, use the nonce returned by eth_getTransactionCount(deployer, 'pending'|'latest')."
|
|
echo "A send at nonce 15 will be rejected (NONCE_TOO_FAR) until nonces 1,2,… are broadcast with the deployer key outside Thirdweb, if the chain is still behind."
|