Skip to content

Commit

Permalink
wrappers / abi
Browse files Browse the repository at this point in the history
  • Loading branch information
Fletch153 committed Dec 2, 2024
1 parent 6e45c51 commit 1db7f34
Show file tree
Hide file tree
Showing 11 changed files with 6,199 additions and 1,559 deletions.
21 changes: 12 additions & 9 deletions contracts/scripts/native_solc_compile_all_llo-feeds
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ echo " └───────────────────────
SOLC_VERSION="0.8.19"
OPTIMIZE_RUNS=1000000


SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
python3 -m pip install --require-hashes -r "$SCRIPTPATH"/requirements.txt
solc-select install $SOLC_VERSION
Expand All @@ -19,15 +18,15 @@ export SOLC_VERSION=$SOLC_VERSION
ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; cd ../../ && pwd -P )"

compileContract () {
local contract
contract=$(basename "$1" ".sol")

solc --overwrite --optimize --optimize-runs $OPTIMIZE_RUNS --metadata-hash none \
-o "$ROOT"/contracts/solc/v$SOLC_VERSION/"$contract" \
--abi --bin --allow-paths "$ROOT"/contracts/src/v0.8\
"$ROOT"/contracts/src/v0.8/"$1"
local contract dir
contract=$(basename "$1" ".sol")
dir=$(dirname "$1")

solc --overwrite --optimize --optimize-runs $OPTIMIZE_RUNS --metadata-hash none \
-o "$ROOT"/contracts/solc/v$SOLC_VERSION/"$dir"/"$contract" \
--abi --bin --allow-paths "$ROOT"/contracts/src/v0.8\
"$ROOT"/contracts/src/v0.8/"$1"
}

compileContract llo-feeds/v0.3.0/Verifier.sol
compileContract llo-feeds/v0.3.0/VerifierProxy.sol
compileContract llo-feeds/v0.3.0/FeeManager.sol
Expand All @@ -38,6 +37,10 @@ compileContract llo-feeds/v0.4.0/DestinationFeeManager.sol
compileContract llo-feeds/v0.4.0/DestinationRewardManager.sol
compileContract llo-feeds/v0.5.0/configuration/ChannelConfigStore.sol
compileContract llo-feeds/v0.5.0/configuration/Configurator.sol
compileContract llo-feeds/v0.5.0/Verifier.sol
compileContract llo-feeds/v0.5.0/VerifierProxy.sol
compileContract llo-feeds/v0.5.0/FeeManager.sol
compileContract llo-feeds/v0.5.0/RewardManager.sol

# Test | Mocks
compileContract llo-feeds/v0.3.0/test/mocks/ErroredVerifier.sol
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/v0.8/llo-feeds/v0.5.0/Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface {
address[] calldata signers,
uint8 f,
Common.AddressAndWeight[] memory recipientAddressesAndWeights,
bool updateConfig
bool _updateConfig
) internal {
VerifierState storage verifierState = s_verifierStates[configDigest];

if(verifierState.f > 0 && !updateConfig) {
if(verifierState.f > 0 && !_updateConfig) {
revert ConfigDigestAlreadySet();
}

Expand All @@ -325,7 +325,7 @@ contract Verifier is IVerifier, ConfirmedOwner, TypeAndVersionInterface {
});
}

if(!updateConfig) {
if(!_updateConfig) {
IVerifierProxy(i_verifierProxyAddr).setVerifier(
bytes32(0),
configDigest,
Expand Down
165 changes: 165 additions & 0 deletions contracts/verify_v0_4_0_contracts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#!/bin/bash

# Default values
ETHERSCAN_API_KEY="xxx"
VERIFIER_URL="https://api-sepolia.blastscan.io/api"
COMPILER_VERSION="0.8.19+commit.7dd6d404"
NUM_OF_OPTIMIZATIONS=1000000
DEPLOYMENT_INFO_FILE="deployment-info.json"

# Function to parse command line arguments
parse_args() {
while [[ $# -gt 0 ]]; do
case $1 in
--etherscan-api-key)
ETHERSCAN_API_KEY="$2"
shift 2
;;
--verifier-url)
VERIFIER_URL="$2"
shift 2
;;
--compiler-version)
COMPILER_VERSION="$2"
shift 2
;;
--num-of-optimizations)
NUM_OF_OPTIMIZATIONS="$2"
shift 2
;;
--deployment-info)
DEPLOYMENT_INFO_FILE="$2"
shift 2
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
}

# Function to verify a contract
verify_contract() {
local contract_name="$1"
local address="$2"
local constructor_args="$3"
local file_path="$4"

if [ -z "$address" ] || [ "$address" == "null" ]; then
echo "Error: Invalid address for $contract_name"
exit 1
fi

local cmd="forge verify-contract"
cmd+=" --etherscan-api-key $ETHERSCAN_API_KEY"
cmd+=" --verifier-url $VERIFIER_URL"
cmd+=" $address"
cmd+=" $file_path:$contract_name"
cmd+=" --compiler-version $COMPILER_VERSION"

if [ -n "$constructor_args" ]; then
cmd+=" --constructor-args $constructor_args"
fi

cmd+=" --num-of-optimizations $NUM_OF_OPTIMIZATIONS"

echo "Verifying $contract_name..."

# Execute the command
if ! eval "$cmd"; then
echo "Verification failed for $contract_name"
exit 1
fi

echo "Verification successful for $contract_name"
}

# Function to safely get JSON value
get_json_value() {
local value=$(echo "$DEPLOYMENT_INFO" | jq -r "$1")
if [ "$value" == "null" ] || [ -z "$value" ]; then
echo ""
else
echo "$value"
fi
}

# Main execution
parse_args "$@"

# Check if the deployment info file exists
if [ ! -f "$DEPLOYMENT_INFO_FILE" ]; then
echo "Error: Deployment info file '$DEPLOYMENT_INFO_FILE' not found."
exit 1
fi

# Read deployment info
DEPLOYMENT_INFO=$(cat "$DEPLOYMENT_INFO_FILE")

# Verify DestinationFeeManager if present
if [ "$(get_json_value '.contracts.DestinationFeeManager')" != "" ]; then
address=$(get_json_value '.contracts.DestinationFeeManager.address')
linkToken=$(get_json_value '.contracts.DestinationFeeManager.params.linkToken')
nativeToken=$(get_json_value '.contracts.DestinationFeeManager.params.nativeToken')
verifier=$(get_json_value '.contracts.DestinationFeeManager.params.verifier')
rewardManager=$(get_json_value '.contracts.DestinationFeeManager.params.rewardManager')

if [ -n "$address" ] && [ -n "$linkToken" ] && [ -n "$nativeToken" ] && [ -n "$verifier" ] && [ -n "$rewardManager" ]; then
constructor_args=$(cast abi-encode "constructor(address,address,address,address)" "$linkToken" "$nativeToken" "$verifier" "$rewardManager")
verify_contract "DestinationFeeManager" "$address" "$constructor_args" "src/v0.8/llo-feeds/v0.4.0/DestinationFeeManager.sol"
else
echo "Error: Missing parameters for DestinationFeeManager"
exit 1
fi
else
echo "DestinationFeeManager not found in deployment info. Skipping."
fi

# Verify DestinationRewardManager if present
if [ "$(get_json_value '.contracts.DestinationRewardManager')" != "" ]; then
address=$(get_json_value '.contracts.DestinationRewardManager.address')
linkToken=$(get_json_value '.contracts.DestinationRewardManager.params.linkToken')

if [ -n "$address" ] && [ -n "$linkToken" ]; then
constructor_args=$(cast abi-encode "constructor(address)" "$linkToken")
verify_contract "DestinationRewardManager" "$address" "$constructor_args" "src/v0.8/llo-feeds/v0.4.0/DestinationRewardManager.sol"
else
echo "Error: Missing parameters for DestinationRewardManager"
exit 1
fi
else
echo "DestinationRewardManager not found in deployment info. Skipping."
fi

# Verify DestinationVerifier if present
if [ "$(get_json_value '.contracts.DestinationVerifier')" != "" ]; then
address=$(get_json_value '.contracts.DestinationVerifier.address')
destinationVerifierProxy=$(get_json_value '.contracts.DestinationVerifier.params.destinationVerifierProxy')

if [ -n "$address" ] && [ -n "$destinationVerifierProxy" ]; then
constructor_args=$(cast abi-encode "constructor(address)" "$destinationVerifierProxy")
verify_contract "DestinationVerifier" "$address" "$constructor_args" "src/v0.8/llo-feeds/v0.4.0/DestinationVerifier.sol"
else
echo "Error: Missing parameters for DestinationVerifier"
exit 1
fi
else
echo "DestinationVerifier not found in deployment info. Skipping."
fi

# Verify DestinationVerifierProxy if present
if [ "$(get_json_value '.contracts.DestinationVerifierProxy')" != "" ]; then
address=$(get_json_value '.contracts.DestinationVerifierProxy.address')

if [ -n "$address" ]; then
verify_contract "DestinationVerifierProxy" "$address" "" "src/v0.8/llo-feeds/v0.4.0/DestinationVerifierProxy.sol"
else
echo "Error: Missing address for DestinationVerifierProxy"
exit 1
fi
else
echo "DestinationVerifierProxy not found in deployment info. Skipping."
fi

echo "All present contracts verified successfully."
1,786 changes: 1,786 additions & 0 deletions core/gethwrappers/llo-feeds/generated/fee_manager_v0_5_0/fee_manager_v0_5_0.go

Large diffs are not rendered by default.

1,318 changes: 0 additions & 1,318 deletions core/gethwrappers/llo-feeds/generated/llo_feeds/llo_feeds.go

This file was deleted.

Loading

0 comments on commit 1db7f34

Please sign in to comment.