Skip to content

Commit

Permalink
Upgrade to go-ethereum 1.10.3 (#104)
Browse files Browse the repository at this point in the history
 change to go-ethereum 1.10.3

Co-authored-by: elv-gilles <[email protected]>
  • Loading branch information
elv-preethi and elv-gilles authored Dec 9, 2022
1 parent be37d5b commit 690694b
Show file tree
Hide file tree
Showing 86 changed files with 97,295 additions and 86,518 deletions.
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.idea/

*~
.DS_Store
*.tmp
/.project
/.settings/
/.vscode/
/.idea/
/bin/
/_bin/
/_build_contracts_go/
63 changes: 63 additions & 0 deletions build-common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
set -Eeuo pipefail

# This script makes sure the required versions of solc are available.
# * unless a solc binary is found in folder '_bin/${platform}/solc/${version},
# the script downloads the solc binary from 'binaries.soliditylang.org'
# * to add a new version: declare a new variable with the value of the version
# and add it to the 'solc_versions' variable.

#
# versions of solc that we need
#
solc_0_4_24="0.4.24"
solc_0_5_4="0.5.4"
solc_versions=(${solc_0_4_24} ${solc_0_5_4})


curr_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
bin_folder="_bin"
abigen_dir=$(realpath "$curr_dir")

platform=""
case $(uname) in
Darwin*)
platform=macosx-amd64
;;
Linux*)
platform=linux-amd64
;;
*)
echo "Not sure what environment this is. Cannot setup solc"
exit 1
;;
esac


solc_folder=${curr_dir}/${bin_folder}/${platform}/solc
mkdir -p ${solc_folder}

downloadSolc() {
local version=$1
local jq_cmd=".releases[\"${version}\"]"
local binary

# cat solc_macosx-amd64_list.json | jq '.releases["0.3.6"]'
binary=$( curl -q -s "https://raw.githubusercontent.com/ethereum/solc-bin/gh-pages/${platform}/list.json" | jq "${jq_cmd}" )
binary=${binary//'+'/'%2B'}
binary=${binary%\"}
binary=${binary#\"}

mkdir ${solc_folder}/${version}
curl -q -s -o ${solc_folder}/${version}/solc "https://binaries.soliditylang.org/${platform}/${binary}"
chmod ugo+x ${solc_folder}/${version}/solc
}

# get solc binaries
for f in ${solc_versions[@]}; do
if ! [ -f ${solc_folder}/${f}/solc ]; then
downloadSolc ${f}
fi
# check solc
"${solc_folder}/${f}/solc" --version | grep "Version: ${f}+"
done
84 changes: 59 additions & 25 deletions build-go.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
#!/bin/bash
set -Eeuo pipefail

if [ -z "${2-}" ]; then
echo "Usage: $0 SOLC_0_4_24_DIR SOLC_0_5_4_DIR"
exit 1
fi
#
# This build script regenerates go bindings for go-ethereum 1.10.2
# NOTE:
# * abigen does not anymore invoke solc (solc output must be explicitly provided).

solc_0_4_24_dir=$(realpath "$1")
solc_0_5_4_dir=$(realpath "$2")

# check solc
"$solc_0_4_24_dir/solc" --version | grep "Version: 0.4.24+"
"$solc_0_5_4_dir/solc" --version | grep "Version: 0.5.4+"

# build abigen
(
echo "#### building abigen command"
cd cmds
pushd cmds
go build -o ../abigen ./abigen
popd
)

source ./build-common.sh


# solc ./base_content_space.sol --combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize | abigen --pkg=contracts --out build/base_content_space.go --combined-json -
abigen(){
# 1: solc version
# 2: contract file (.sol)
# 3: package name
# 4: output file - go bindings
local version=$1
solc_bin="${solc_folder}/${version}/solc"

"${solc_bin}" "$2" --combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize | "$abigen_dir/abigen" --pkg=${3} --out "${4}" --combined-json -
###./abigen --sol "${sol_dir}/${2}" --pkg=${3} --out "${out_dir}/${5}"
ret=$?
if [[ $ret -ne 0 ]]; then
echo "FAILED : error creating go binding for ${2}!"
exit 1
else
echo "SUCCESS : go binding for ${2} generated at ${4}"
fi
}

# checkout 'known' versions of contracts in folder _build_contracts_go
# and produce go-bindings in ../../contracts-go
mkdir -p _build_contracts_go
(
cd _build_contracts_go
Expand All @@ -34,33 +54,47 @@ mkdir -p _build_contracts_go

# recent contracts require solc 0.5.4
(
hash -d solc 2>/dev/null || : # clear cache for solc location
# shellcheck disable=SC2030
PATH="$solc_0_5_4_dir:$PATH"
export PATH

echo "#### generating latest contracts"
../../abigen --sol base_content_space.sol --pkg contracts --out ../../contracts-go/contracts/base_content_space.go
mkdir -p ../../contracts-go/contracts
mkdir -p ../../contracts-go/tradable
abigen $solc_0_5_4 base_content_space.sol contracts ../../contracts-go/contracts/base_content_space.go
echo "#### generating latest contracts/tradable"
../../abigen --sol tradable/elv_tradable_full.sol --pkg tradable --out ../../contracts-go/tradable/elv_tradable_full.go
abigen $solc_0_5_4 tradable/elv_tradable_full.sol tradable ../../contracts-go/tradable/elv_tradable_full.go
)

# older contracts require solc 0.4.24
(
hash -d solc 2>/dev/null || : # clear cache for solc location
PATH="$solc_0_4_24_dir:$PATH"
export PATH

git checkout "53ee85a858257d32c9650ff76f50e5ee2a1379d9"
echo "#### generating contracts_20190331"
../../abigen --sol base_content_space.sol --pkg contracts_20190331 --out ../../contracts-go/contracts_20190331/base_content_space.go
mkdir -p ../../contracts-go/contracts_20190331
abigen $solc_0_4_24 base_content_space.sol contracts_20190331 ../../contracts-go/contracts_20190331/base_content_space.go

git checkout "5ed6b64537175315be6c79fdbfb9a3d35086344d"
echo "#### generating contracts_20200206"
../../abigen --sol base_content_space.sol --pkg contracts_20200206 --out ../../contracts-go/contracts_20200206/base_content_space.go
mkdir -p ../../contracts-go/contracts_20200206
abigen $solc_0_4_24 base_content_space.sol contracts_20200206 ../../contracts-go/contracts_20200206/base_content_space.go

git checkout "133cb66c6e67fc946c6b73d7f7db3bbb913d4859"
# 133cb66 is the revision used in the fabric but does not contain all events
# git checkout "133cb66c6e67fc946c6b73d7f7db3bbb913d4859" # 2020-08-06
git checkout "2536dfb9b29e394feedcc1c5c7d16f67d21a35bb" # 2020-08-11
echo "#### generating contracts_20200803"
../../abigen --sol base_content_space.sol --pkg contracts_20200803 --out ../../contracts-go/contracts_20200803/base_content_space.go
mkdir -p ../../contracts-go/contracts_20200803
abigen $solc_0_4_24 base_content_space.sol contracts_20200803 ../../contracts-go/contracts_20200803/base_content_space.go
)
)

# all good - now copy bindings to their 'legacy' locations
cd ${curr_dir}
rm -rf _build_contracts_go
mkdir -p build
mkdir -p build/20190331
mkdir -p build/20200206
mkdir -p build/20200803
mkdir -p build/tradable

cp contracts-go/contracts/base_content_space.go build/base_content_space.go
cp contracts-go/contracts_20190331/base_content_space.go build/20190331/base_content_space.go
cp contracts-go/contracts_20200206/base_content_space.go build/20200206/base_content_space.go
cp contracts-go/contracts_20200803/base_content_space.go build/20200803/base_content_space.go
cp contracts-go/tradable/elv_tradable_full.go build/tradable/elv_tradable_full.go
38 changes: 14 additions & 24 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,48 +1,39 @@
#!/bin/bash
set -Eeuo pipefail

# Must use:
# - solc 0.5.4
badreq=
solc --version | grep -q 0.5.4+commit.9549d8ff || badreq=true
if test $badreq; then
echo "Must use abigen 1.9.19 and solc 0.5.4"
exit
fi

source ./build-common.sh

## NOTE: this script does not generate go-bindings anymore.
## Use build-go.sh to generate go-bindings

run_solc() {
bsc_name=$(basename "${1}")
local version=$1
solc_bin="${solc_folder}/${version}/solc"

if $(solc "${1}" --abi --hashes --optimize -o "${abi_dir}" --overwrite) ; then
bsc_name=$(basename "${2}")

if $($solc_bin "${2}" --abi --hashes --optimize -o "${abi_dir}" --overwrite) ; then
echo -e "\n SUCCESS : ${bsc_name} ABI and function hashes present in ${abi_dir}"
fi

if $(solc "${1}" --bin --optimize -o "${abi_dir}/bin" --overwrite) ; then
if $($solc_bin "${2}" --bin --optimize -o "${abi_dir}/bin" --overwrite) ; then
echo -e "\n SUCCESS : ${bsc_name} BIN present in ${abi_dir}/bin"
fi
}

# to get path to sol folder
sol_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
abi_dir=$sol_dir/dist
base_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
abi_dir=$base_dir/dist

separator="====================================================================================================="

hash solc || {
echo "Error : solc is not found"
exit 1
}

run_solc "${sol_dir}/base_content_space.sol"

run_solc $solc_0_5_4 "${base_dir}/base_content_space.sol"
echo -e "\n${separator}\n"
#run_solc "${sol_dir}/lv_recording.sol"
#echo -e "\n${separator}\n"
#run_solc "${sol_dir}/payment_service.sol"
#echo -e "\n${separator}\n"
run_solc "${sol_dir}/tradable/elv_tradable_full.sol"

run_solc $solc_0_5_4 "${base_dir}/tradable/elv_tradable_full.sol"
echo -e "\n${separator}\n"

pushd cmds > /dev/null 2>&1
Expand All @@ -53,4 +44,3 @@ if [[ $? -ne 0 ]]; then
echo "FAILED : error occurred while parsing abi"
exit 1
fi

Loading

0 comments on commit 690694b

Please sign in to comment.