From c0d3f2188086603e3b46d64942d4065f3ceadd05 Mon Sep 17 00:00:00 2001
From: Patrick Raphael <patrick.raphael@block.one>
Date: Thu, 23 Dec 2021 15:22:09 -0500
Subject: [PATCH 1/2] update .cicd/platforms apply Boost fix

---
 .../platforms/pinned/amazon_linux-2-pinned.dockerfile |  4 +++-
 .cicd/platforms/pinned/centos-7.7-pinned.dockerfile   |  4 +++-
 .cicd/platforms/pinned/macos-10.15-pinned.sh          |  2 ++
 .cicd/platforms/pinned/macos-11-pinned.sh             |  2 ++
 .cicd/platforms/pinned/ubuntu-18.04-pinned.dockerfile |  4 +++-
 .cicd/platforms/pinned/ubuntu-20.04-pinned.dockerfile |  4 +++-
 .../unpinned/amazon_linux-2-unpinned.dockerfile       | 11 +++++++----
 .../platforms/unpinned/centos-7.7-unpinned.dockerfile | 10 ++++++----
 .../unpinned/ubuntu-18.04-unpinned.dockerfile         | 10 ++++++----
 .../unpinned/ubuntu-20.04-unpinned.dockerfile         | 10 ++++++----
 10 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/.cicd/platforms/pinned/amazon_linux-2-pinned.dockerfile b/.cicd/platforms/pinned/amazon_linux-2-pinned.dockerfile
index f16bae55ca1..0a1e1482bdb 100644
--- a/.cicd/platforms/pinned/amazon_linux-2-pinned.dockerfile
+++ b/.cicd/platforms/pinned/amazon_linux-2-pinned.dockerfile
@@ -43,9 +43,11 @@ RUN git clone --depth 1 --single-branch --branch llvmorg-10.0.0 https://github.c
     cd / && \
     rm -rf /llvm
 # build boost
-RUN curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2 && \
+ENV BEAST_FIX_URL https://raw.githubusercontent.com/boostorg/beast/3fd090af3b7e69ed7871c64a4b4b86fae45e98da/include/boost/beast/zlib/detail/inflate_stream.ipp
+RUN curl -fsSLO https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2 && \
     tar -xjf boost_1_72_0.tar.bz2 && \
     cd boost_1_72_0 && \
+    curl -fsSLo boost/beast/zlib/detail/inflate_stream.ipp "${BEAST_FIX_URL}" && \
     ./bootstrap.sh --with-toolset=clang --prefix=/usr/local && \
     ./b2 toolset=clang cxxflags='-stdlib=libc++ -D__STRICT_ANSI__ -nostdinc++ -I/usr/local/include/c++/v1 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fpie' linkflags='-stdlib=libc++ -pie' link=static threading=multi --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test -q -j$(nproc) install && \
     cd / && \
diff --git a/.cicd/platforms/pinned/centos-7.7-pinned.dockerfile b/.cicd/platforms/pinned/centos-7.7-pinned.dockerfile
index 53651fc0bb4..3fd083c0606 100644
--- a/.cicd/platforms/pinned/centos-7.7-pinned.dockerfile
+++ b/.cicd/platforms/pinned/centos-7.7-pinned.dockerfile
@@ -49,9 +49,11 @@ RUN git clone --depth 1 --single-branch --branch llvmorg-10.0.0 https://github.c
     cd / && \
     rm -rf /llvm
 # build boost
-RUN curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2 && \
+ENV BEAST_FIX_URL https://raw.githubusercontent.com/boostorg/beast/3fd090af3b7e69ed7871c64a4b4b86fae45e98da/include/boost/beast/zlib/detail/inflate_stream.ipp
+RUN curl -fsSLO https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2 && \
     tar -xjf boost_1_72_0.tar.bz2 && \
     cd boost_1_72_0 && \
+    curl -fsSLo boost/beast/zlib/detail/inflate_stream.ipp "${BEAST_FIX_URL}" && \
     ./bootstrap.sh --with-toolset=clang --prefix=/usr/local && \
     ./b2 toolset=clang cxxflags='-stdlib=libc++ -D__STRICT_ANSI__ -nostdinc++ -I/usr/local/include/c++/v1 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fpie' linkflags='-stdlib=libc++ -pie' link=static threading=multi --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test -q -j$(nproc) install && \
     cd / && \
diff --git a/.cicd/platforms/pinned/macos-10.15-pinned.sh b/.cicd/platforms/pinned/macos-10.15-pinned.sh
index 20c5879211d..b99bb5ae600 100755
--- a/.cicd/platforms/pinned/macos-10.15-pinned.sh
+++ b/.cicd/platforms/pinned/macos-10.15-pinned.sh
@@ -18,6 +18,8 @@ rm -rf clang10
 curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2
 tar -xjf boost_1_72_0.tar.bz2
 cd boost_1_72_0
+BEAST_FIX_URL=https://raw.githubusercontent.com/boostorg/beast/3fd090af3b7e69ed7871c64a4b4b86fae45e98da/include/boost/beast/zlib/detail/inflate_stream.ipp
+curl -fsSLo boost/beast/zlib/detail/inflate_stream.ipp "${BEAST_FIX_URL}"
 ./bootstrap.sh --prefix=/usr/local
 sudo -E ./b2 --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test -q -j$(getconf _NPROCESSORS_ONLN) install
 cd ..
diff --git a/.cicd/platforms/pinned/macos-11-pinned.sh b/.cicd/platforms/pinned/macos-11-pinned.sh
index cd1faf35cce..0e97736d240 100755
--- a/.cicd/platforms/pinned/macos-11-pinned.sh
+++ b/.cicd/platforms/pinned/macos-11-pinned.sh
@@ -16,6 +16,8 @@ rm -rf clang10
 curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2
 tar -xjf boost_1_72_0.tar.bz2
 cd boost_1_72_0
+BEAST_FIX_URL=https://raw.githubusercontent.com/boostorg/beast/3fd090af3b7e69ed7871c64a4b4b86fae45e98da/include/boost/beast/zlib/detail/inflate_stream.ipp
+curl -fsSLo boost/beast/zlib/detail/inflate_stream.ipp "${BEAST_FIX_URL}"
 ./bootstrap.sh --prefix=/usr/local
 sudo -E ./b2 --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test -q -j$(getconf _NPROCESSORS_ONLN) install
 cd ..
diff --git a/.cicd/platforms/pinned/ubuntu-18.04-pinned.dockerfile b/.cicd/platforms/pinned/ubuntu-18.04-pinned.dockerfile
index 1dbed260684..8812beb541f 100644
--- a/.cicd/platforms/pinned/ubuntu-18.04-pinned.dockerfile
+++ b/.cicd/platforms/pinned/ubuntu-18.04-pinned.dockerfile
@@ -41,9 +41,11 @@ RUN git clone --depth 1 --single-branch --branch llvmorg-10.0.0 https://github.c
     cd / && \
     rm -rf /llvm
 # build boost
-RUN curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2 && \
+ENV BEAST_FIX_URL https://raw.githubusercontent.com/boostorg/beast/3fd090af3b7e69ed7871c64a4b4b86fae45e98da/include/boost/beast/zlib/detail/inflate_stream.ipp
+RUN curl -fsSLO https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2 && \
     tar -xjf boost_1_72_0.tar.bz2 && \
     cd boost_1_72_0 && \
+    curl -fsSLo boost/beast/zlib/detail/inflate_stream.ipp "${BEAST_FIX_URL}" && \
     ./bootstrap.sh --with-toolset=clang --prefix=/usr/local && \
     ./b2 toolset=clang cxxflags='-stdlib=libc++ -D__STRICT_ANSI__ -nostdinc++ -I/usr/local/include/c++/v1 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fpie' linkflags='-stdlib=libc++ -pie' link=static threading=multi --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test -q -j$(nproc) install && \
     cd / && \
diff --git a/.cicd/platforms/pinned/ubuntu-20.04-pinned.dockerfile b/.cicd/platforms/pinned/ubuntu-20.04-pinned.dockerfile
index 2c54f29a5c3..95f921bf80f 100644
--- a/.cicd/platforms/pinned/ubuntu-20.04-pinned.dockerfile
+++ b/.cicd/platforms/pinned/ubuntu-20.04-pinned.dockerfile
@@ -40,9 +40,11 @@ RUN git clone --depth 1 --single-branch --branch llvmorg-10.0.0 https://github.c
     cd / && \
     rm -rf /llvm
 # build boost
-RUN curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2 && \
+ENV BEAST_FIX_URL https://raw.githubusercontent.com/boostorg/beast/3fd090af3b7e69ed7871c64a4b4b86fae45e98da/include/boost/beast/zlib/detail/inflate_stream.ipp
+RUN curl -fsSLO https://boostorg.jfrog.io/artifactory/main/release/1.72.0/source/boost_1_72_0.tar.bz2 && \
     tar -xjf boost_1_72_0.tar.bz2 && \
     cd boost_1_72_0 && \
+    curl -fsSLo boost/beast/zlib/detail/inflate_stream.ipp "${BEAST_FIX_URL}" && \
     ./bootstrap.sh --with-toolset=clang --prefix=/usr/local && \
     ./b2 toolset=clang cxxflags='-stdlib=libc++ -D__STRICT_ANSI__ -nostdinc++ -I/usr/local/include/c++/v1 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fpie' linkflags='-stdlib=libc++ -pie' link=static threading=multi --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test -q -j$(nproc) install && \
     cd / && \
diff --git a/.cicd/platforms/unpinned/amazon_linux-2-unpinned.dockerfile b/.cicd/platforms/unpinned/amazon_linux-2-unpinned.dockerfile
index f3e7281911b..ced4f07e209 100644
--- a/.cicd/platforms/unpinned/amazon_linux-2-unpinned.dockerfile
+++ b/.cicd/platforms/unpinned/amazon_linux-2-unpinned.dockerfile
@@ -21,13 +21,16 @@ RUN curl -LO https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.
     make install && \
     rm -rf cmake-3.16.2.tar.gz cmake-3.16.2
 # build boost
-RUN curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.71.0/source/boost_1_71_0.tar.bz2 && \
-    tar -xjf boost_1_71_0.tar.bz2 && \
-    cd boost_1_71_0 && \
+ENV BOOST_VERSION 1_78_0
+ENV BOOST_VERSION_DOT 1.78.0
+RUN curl -fsSLO "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION_DOT}/source/boost_${BOOST_VERSION}.tar.bz2" && \
+    tar -xjf "boost_${BOOST_VERSION}.tar.bz2" && \
+    cd "boost_${BOOST_VERSION}" && \
     ./bootstrap.sh --prefix=/usr/local && \
     ./b2 --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test -q -j$(nproc) install && \
     cd / && \
-    rm -rf boost_1_71_0.tar.bz2 /boost_1_71_0
+    rm -rf "boost_${BOOST_VERSION}.tar.bz2" "/boost_${BOOST_VERSION}"
+
 # install nvm
 RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
 # load nvm in non-interactive shells
diff --git a/.cicd/platforms/unpinned/centos-7.7-unpinned.dockerfile b/.cicd/platforms/unpinned/centos-7.7-unpinned.dockerfile
index 73fe8825ffb..947b988bc52 100644
--- a/.cicd/platforms/unpinned/centos-7.7-unpinned.dockerfile
+++ b/.cicd/platforms/unpinned/centos-7.7-unpinned.dockerfile
@@ -28,15 +28,17 @@ RUN curl -LO https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.
     make install && \
     rm -rf cmake-3.16.2.tar.gz cmake-3.16.2
 # build boost
-RUN curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.71.0/source/boost_1_71_0.tar.bz2 && \
+ENV BOOST_VERSION 1_78_0
+ENV BOOST_VERSION_DOT 1.78.0
+RUN curl -fsSLO "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION_DOT}/source/boost_${BOOST_VERSION}.tar.bz2" && \
     source /opt/rh/devtoolset-8/enable && \
     source /opt/rh/rh-python36/enable && \
-    tar -xjf boost_1_71_0.tar.bz2 && \
-    cd boost_1_71_0 && \
+    tar -xjf "boost_${BOOST_VERSION}.tar.bz2" && \
+    cd "boost_${BOOST_VERSION}" && \
     ./bootstrap.sh --prefix=/usr/local && \
     ./b2 --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test -q -j$(nproc) install && \
     cd / && \
-    rm -rf boost_1_71_0.tar.bz2 /boost_1_71_0
+    rm -rf "boost_${BOOST_VERSION}.tar.bz2" "/boost_${BOOST_VERSION}"
 # install nvm
 RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
 # load nvm in non-interactive shells
diff --git a/.cicd/platforms/unpinned/ubuntu-18.04-unpinned.dockerfile b/.cicd/platforms/unpinned/ubuntu-18.04-unpinned.dockerfile
index 6cbe36345ca..10ad934a280 100644
--- a/.cicd/platforms/unpinned/ubuntu-18.04-unpinned.dockerfile
+++ b/.cicd/platforms/unpinned/ubuntu-18.04-unpinned.dockerfile
@@ -19,13 +19,15 @@ RUN curl -LO https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.
     make install && \
     rm -rf cmake-3.16.2.tar.gz cmake-3.16.2
 # build boost
-RUN curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.71.0/source/boost_1_71_0.tar.bz2 && \
-    tar -xjf boost_1_71_0.tar.bz2 && \
-    cd boost_1_71_0 && \
+ENV BOOST_VERSION 1_78_0
+ENV BOOST_VERSION_DOT 1.78.0
+RUN curl -fsSLO "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION_DOT}/source/boost_${BOOST_VERSION}.tar.bz2" && \
+    tar -xjf "boost_${BOOST_VERSION}.tar.bz2" && \
+    cd "boost_${BOOST_VERSION}" && \
     ./bootstrap.sh --prefix=/usr/local && \
     ./b2 --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test -j$(nproc) install && \
     cd / && \
-    rm -rf boost_1_71_0.tar.bz2 /boost_1_71_0
+    rm -rf "boost_${BOOST_VERSION}.tar.bz2" "/boost_${BOOST_VERSION}"
 # install nvm
 RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
 # load nvm in non-interactive shells
diff --git a/.cicd/platforms/unpinned/ubuntu-20.04-unpinned.dockerfile b/.cicd/platforms/unpinned/ubuntu-20.04-unpinned.dockerfile
index 32072a9601b..a3b2f6dfaaa 100644
--- a/.cicd/platforms/unpinned/ubuntu-20.04-unpinned.dockerfile
+++ b/.cicd/platforms/unpinned/ubuntu-20.04-unpinned.dockerfile
@@ -20,13 +20,15 @@ RUN curl -LO https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.
     make install && \
     rm -rf cmake-3.16.2.tar.gz cmake-3.16.2
 # build boost
-RUN curl -LO https://boostorg.jfrog.io/artifactory/main/release/1.71.0/source/boost_1_71_0.tar.bz2 && \
-    tar -xjf boost_1_71_0.tar.bz2 && \
-    cd boost_1_71_0 && \
+ENV BOOST_VERSION 1_78_0
+ENV BOOST_VERSION_DOT 1.78.0
+RUN curl -fsSLO "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION_DOT}/source/boost_${BOOST_VERSION}.tar.bz2" && \
+    tar -xjf "boost_${BOOST_VERSION}.tar.bz2" && \
+    cd "boost_${BOOST_VERSION}" && \
     ./bootstrap.sh --prefix=/usr/local && \
     ./b2 --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test -j$(nproc) install && \
     cd / && \
-    rm -rf boost_1_71_0.tar.bz2 /boost_1_71_0
+    rm -rf "boost_${BOOST_VERSION}.tar.bz2" "/boost_${BOOST_VERSION}"
 # install node 12
 RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
     . /etc/lsb-release && \

From 5b41e95536a277cb5ef117d13f85aa5d331dd77a Mon Sep 17 00:00:00 2001
From: Patrick Raphael <patrick.raphael@block.one>
Date: Thu, 23 Dec 2021 14:15:35 -0500
Subject: [PATCH 2/2] apply Boost fix to build scripts

---
 scripts/.build_vars      | 9 +++++++--
 scripts/helpers/eosio.sh | 2 ++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/scripts/.build_vars b/scripts/.build_vars
index d2444fec0a0..e64b26b5ea7 100644
--- a/scripts/.build_vars
+++ b/scripts/.build_vars
@@ -14,8 +14,13 @@ export CMAKE_VERSION_PATCH=2
 export CMAKE_VERSION=${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}.${CMAKE_VERSION_PATCH}
 
 # BOOST
-export BOOST_VERSION_MAJOR=1
-export BOOST_VERSION_MINOR=72
+if $PIN_COMPILER; then
+    export BOOST_VERSION_MAJOR=1
+    export BOOST_VERSION_MINOR=72
+else
+    export BOOST_VERSION_MAJOR=1
+    export BOOST_VERSION_MINOR=78
+fi
 export BOOST_VERSION_PATCH=0
 export BOOST_VERSION=${BOOST_VERSION_MAJOR}_${BOOST_VERSION_MINOR}_${BOOST_VERSION_PATCH}
 export BOOST_ROOT=${BOOST_LOCATION:-${SRC_DIR}/boost_${BOOST_VERSION}}
diff --git a/scripts/helpers/eosio.sh b/scripts/helpers/eosio.sh
index 7f114b310dd..c21d99548ba 100755
--- a/scripts/helpers/eosio.sh
+++ b/scripts/helpers/eosio.sh
@@ -223,6 +223,7 @@ function ensure-boost() {
     [[ $ARCH == "Darwin" ]] && export CPATH="$(python-config --includes | awk '{print $1}' | cut -dI -f2):$CPATH" # Boost has trouble finding pyconfig.h
     echo "${COLOR_CYAN}[Ensuring Boost $( echo $BOOST_VERSION | sed 's/_/./g' ) library installation]${COLOR_NC}"
     BOOSTVERSION=$( grep "#define BOOST_VERSION" "$BOOST_ROOT/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\  -f3 || true )
+    BEAST_FIX_URL="https://raw.githubusercontent.com/boostorg/beast/3fd090af3b7e69ed7871c64a4b4b86fae45e98da/include/boost/beast/zlib/detail/inflate_stream.ipp"
     if [[ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]]; then
         B2_FLAGS="-q -j${JOBS} --with-iostreams --with-date_time --with-filesystem --with-system --with-program_options --with-chrono --with-test install"
         BOOTSTRAP_FLAGS=""
@@ -236,6 +237,7 @@ function ensure-boost() {
         curl -LO https://boostorg.jfrog.io/artifactory/main/release/$BOOST_VERSION_MAJOR.$BOOST_VERSION_MINOR.$BOOST_VERSION_PATCH/source/boost_$BOOST_VERSION.tar.bz2 \
         && tar -xjf boost_$BOOST_VERSION.tar.bz2 \
         && cd $BOOST_ROOT \
+        && if "$PIN_COMPILER"; then curl -fsSLo boost/beast/zlib/detail/inflate_stream.ipp "${BEAST_FIX_URL}"; fi \
         && SDKROOT="$SDKROOT" ./bootstrap.sh ${BOOTSTRAP_FLAGS} --prefix=$BOOST_ROOT \
         && SDKROOT="$SDKROOT" ./b2 ${B2_FLAGS} \
         && cd .. \