diff --git a/script/dev/gas-estimator.sh b/script/dev/gas-estimator.sh new file mode 100755 index 0000000..fa49d23 --- /dev/null +++ b/script/dev/gas-estimator.sh @@ -0,0 +1,117 @@ +#!/bin/bash +# +# Script to estimate gas usage of an (op)Poke using an RPC connected client. +# +# Run via: +# ```bash +# $ script/dev/gas-estimator \ +# --scribe
\ +# --op-poke \ # Set to use opPoke, omit for normal poke +# --poke-val \ +# --poke-age \ +# --schnorr-signature \ +# --schnorr-commitment
\ +# --schnorr-feed-ids \ +# --ecdsa-v \ # ECDSA args only necessary if opPoke +# --ecdsa-r \ # ECDSA args only necessary if opPoke +# --ecdsa-s \ # ECDSA args only necessary if opPoke +# --rpc-url +# ``` + +# Scribe argument +scribe="" + +# (op)Poke arguments +op_poke=false +## Poke data +poke_val="" +poke_age="" +## Schnorr data +schnorr_signature="" +schnorr_commitment="" +schnorr_feed_ids="" +## ECDSA data +ecdsa_v="" +ecdsa_r="" +ecdsa_s="" + +# Other arguments +rpc_url="" + +# Parse arguments: +while [[ $# -gt 0 ]]; do + case "$1" in + --scribe) + scribe="$2" + shift 2 + ;; + --op-poke) + op_poke=true + shift + ;; + --poke-val) + poke_val="$2" + shift 2 + ;; + --poke-age) + poke_age="$2" + shift 2 + ;; + --schnorr-signature) + schnorr_signature="$2" + shift 2 + ;; + --schnorr-commitment) + schnorr_commitment="$2" + shift 2 + ;; + --schnorr-feed-ids) + schnorr_feed_ids="$2" + shift 2 + ;; + --ecdsa-v) + ecdsa_v="$2" + shift 2 + ;; + --ecdsa-r) + ecdsa_r="$2" + shift 2 + ;; + --ecdsa-s) + ecdsa_s="$2" + shift 2 + ;; + --rpc-url) + rpc_url="$2" + shift 2 + ;; + *) + echo "Unknown option: $1" + exit 1 + ;; + esac +done + +# Create calldata. +calldata="" +if [[ -n $op_poke ]]; then + calldata=$(cast calldata "opPoke((uint128,uint32),(bytes32,address,bytes),(uint8,bytes32,bytes32))" \ + "($poke_val,$poke_age)" \ + "($schnorr_signature,$schnorr_commitment,$schnorr_feed_ids)" \ + "($ecdsa_v,$ecdsa_r,$ecdsa_s)" \ + ) +else + calldata=$(cast calldata "poke((uint128,uint32),(bytes32,address,bytes))" \ + "($poke_val,$poke_age)" \ + "($schnorr_signature,$schnorr_commitment,$schnorr_feed_ids)" + ) +fi + +if [[ $calldata == "" ]]; then + echo -e "Error creating calldata" + exit 1 +fi + +# Use `cast estimate` on given RPC to estimate gas usage. +result=$(cast estimate $scribe $calldata --rpc-url $rpc_url) +echo -e "$result" diff --git a/script/dev/print-errors.sh b/script/dev/print-errors.sh new file mode 100755 index 0000000..1869f3c --- /dev/null +++ b/script/dev/print-errors.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# +# Script to print all error identifiers. +# +# Run via: +# ```bash +# $ script/dev/print-errors.sh +# ``` + +echo "Scribe(Optimistic) Errors" +forge inspect src/ScribeOptimistic.sol:ScribeOptimistic errors