Skip to content

Commit

Permalink
Update to use Spring instead of Leap
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed May 2, 2024
1 parent c8f1317 commit 94d5044
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 57 deletions.
6 changes: 3 additions & 3 deletions .cicd/defaults.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"leap-dev":{
"target":"hotstuff_integration",
"spring-dev":{
"target":"main",
"prerelease":false
},
"cdt":{
"target":"hotstuff_integration",
"target":"main",
"prerelease":false
}
}
36 changes: 18 additions & 18 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ on:
pull_request:
workflow_dispatch:
inputs:
override-leap-dev:
description: Override leap-dev target
override-spring-dev:
description: Override spring-dev target
type: string
override-leap-dev-prerelease:
override-spring-dev-prerelease:
type: choice
description: Override leap-dev prelease
description: Override spring-dev prelease
options:
- default
- true
Expand All @@ -38,22 +38,22 @@ jobs:
name: Build & Test
runs-on: ubuntu-22.04
steps:
- name: Setup leap-dev & cdt versions
- name: Setup spring-dev & cdt versions
id: versions
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
DEFAULTS_JSON=$(curl -sSfL $(gh api https://api.github.com/repos/${{github.repository}}/contents/.cicd/defaults.json?ref=${{github.sha}} --jq .download_url))
echo leap-dev-target=$(echo "$DEFAULTS_JSON" | jq -r '."leap-dev".target') >> $GITHUB_OUTPUT
echo leap-dev-prerelease=$(echo "$DEFAULTS_JSON" | jq -r '."leap-dev".prerelease') >> $GITHUB_OUTPUT
echo spring-dev-target=$(echo "$DEFAULTS_JSON" | jq -r '."spring-dev".target') >> $GITHUB_OUTPUT
echo spring-dev-prerelease=$(echo "$DEFAULTS_JSON" | jq -r '."spring-dev".prerelease') >> $GITHUB_OUTPUT
echo cdt-target=$(echo "$DEFAULTS_JSON" | jq -r '.cdt.target') >> $GITHUB_OUTPUT
echo cdt-prerelease=$(echo "$DEFAULTS_JSON" | jq -r '.cdt.prerelease') >> $GITHUB_OUTPUT
if [[ "${{inputs.override-leap-dev}}" != "" ]]; then
echo leap-dev-target=${{inputs.override-leap-dev}} >> $GITHUB_OUTPUT
if [[ "${{inputs.override-spring-dev}}" != "" ]]; then
echo spring-dev-target=${{inputs.override-spring-dev}} >> $GITHUB_OUTPUT
fi
if [[ "${{inputs.override-leap-dev-prerelease}}" == +(true|false) ]]; then
echo leap-dev-prerelease=${{inputs.override-leap-dev-prerelease}} >> $GITHUB_OUTPUT
if [[ "${{inputs.override-spring-dev-prerelease}}" == +(true|false) ]]; then
echo spring-dev-prerelease=${{inputs.override-spring-dev-prerelease}} >> $GITHUB_OUTPUT
fi
if [[ "${{inputs.override-cdt}}" != "" ]]; then
echo cdt-target=${{inputs.override-cdt}} >> $GITHUB_OUTPUT
Expand All @@ -70,15 +70,15 @@ jobs:
target: '${{steps.versions.outputs.cdt-target}}'
prereleases: ${{fromJSON(steps.versions.outputs.cdt-prerelease)}}
artifact-name: cdt_ubuntu_package_amd64
- name: Download leap-dev
- name: Download spring-dev
uses: AntelopeIO/asset-artifact-download-action@v3
with:
owner: AntelopeIO
repo: leap
file: 'leap-dev.*ubuntu22\.04_amd64.deb'
target: '${{steps.versions.outputs.leap-dev-target}}'
prereleases: ${{fromJSON(steps.versions.outputs.leap-dev-prerelease)}}
artifact-name: leap-dev-ubuntu22-amd64
repo: spring
file: 'spring-dev.*ubuntu22\.04_amd64.deb'
target: '${{steps.versions.outputs.spring-dev-target}}'
prereleases: ${{fromJSON(steps.versions.outputs.spring-dev-prerelease)}}
artifact-name: spring-dev-ubuntu22-amd64
container-package: experimental-binaries
- name: Install packages
run: |
Expand All @@ -91,7 +91,7 @@ jobs:
path: src
- name: Build & Test
run: |
cmake -S src -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=On -DSYSTEM_ENABLE_LEAP_VERSION_CHECK=Off -DSYSTEM_ENABLE_CDT_VERSION_CHECK=Off
cmake -S src -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=On -DSYSTEM_ENABLE_SPRING_VERSION_CHECK=Off -DSYSTEM_ENABLE_CDT_VERSION_CHECK=Off
cmake --build build -- -j $(nproc)
tar zcf build.tar.gz build
ctest --test-dir build/tests --output-on-failure -j $(nproc)
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ option(SYSTEM_CONFIGURABLE_WASM_LIMITS
option(SYSTEM_BLOCKCHAIN_PARAMETERS
"Enables use of the host functions activated by the BLOCKCHAIN_PARAMETERS protocol feature" ON)

option(SYSTEM_ENABLE_LEAP_VERSION_CHECK
"Enables a configure-time check that the version of Leap's tester library is compatible with this project's unit tests" ON)
option(SYSTEM_ENABLE_SPRING_VERSION_CHECK
"Enables a configure-time check that the version of Spring's tester library is compatible with this project's unit tests" ON)

option(SYSTEM_ENABLE_CDT_VERSION_CHECK
"Enables a configure-time check that the version of CDT is compatible with this project's contracts" ON)
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The `main` branch contains the latest state of development; do not use this for

[CDT](https://github.com/AntelopeIO/cdt) is required to build contracts. Any operating systems supported by CDT is sufficient to build the reference contracts.

To build and run the tests as well, [Leap](https://github.com/AntelopeIO/leap) is also required as a dependency, which may have its further restrictions on supported operating systems.
To build and run the tests as well, [Spring](https://github.com/AntelopeIO/spring) is also required as a dependency, which may have its further restrictions on supported operating systems.
## Building

The build guide below will assume you are running Ubuntu 20.04. However, as mentioned above, other operating systems may also be supported.
Expand All @@ -49,40 +49,40 @@ The easiest way to satisfy this dependency is to install CDT on your system thro

Alternatively, you can build CDT from source. Please refer to the guide in the [CDT README](https://github.com/AntelopeIO/cdt#building-from-source) for instructions on how to do this. If you choose to go with building CDT from source, please keep the path to the build directory in the shell environment variable `CDT_BUILD_PATH` for later use when building the reference contracts.

### Optionally build Leap dependency
### Optionally build Spring dependency

The Leap dependency is optional. It is only needed if you wish to also build the tests using the `BUILD_TESTS` CMake flag.
The Spring dependency is optional. It is only needed if you wish to also build the tests using the `BUILD_TESTS` CMake flag.

Unfortunately, it is not currently possible to satisfy the contract testing dependencies through the Leap packages made available from the [Leap releases page](https://github.com/AntelopeIO/leap/releases). So if you want to build the contract tests, you will first need to build Leap from source.
Unfortunately, it is not currently possible to satisfy the contract testing dependencies through the Spring packages made available from the [Spring releases page](https://github.com/AntelopeIO/spring/releases). So if you want to build the contract tests, you will first need to build Spring from source.

Please refer to the guide in the [Leap README](https://github.com/AntelopeIO/leap#building-from-source) for instructions on how to do this. If you choose to go with building Leap from source, please keep the path to the build directory in the shell environment variable `LEAP_BUILD_PATH` for later use when building the reference contracts.
Please refer to the guide in the [Spring README](https://github.com/AntelopeIO/spring#building-from-source) for instructions on how to do this. If you choose to go with building Spring from source, please keep the path to the build directory in the shell environment variable `SPRING_BUILD_PATH` for later use when building the reference contracts.

### Build reference contracts

Beyond CDT and optionally Leap (if also building the tests), no additional dependencies are required to build the reference contracts.
Beyond CDT and optionally Spring (if also building the tests), no additional dependencies are required to build the reference contracts.

The instructions below assume you are building the reference contracts with tests, have already built Leap from source, and have the CDT dependency installed on your system. For some other configurations, expand the hidden panels placed lower within this section.
The instructions below assume you are building the reference contracts with tests, have already built Spring from source, and have the CDT dependency installed on your system. For some other configurations, expand the hidden panels placed lower within this section.

For all configurations, you should first `cd` into the directory containing cloned reference contracts repository.

Build reference contracts with tests using Leap built from source and with installed CDT package:
Build reference contracts with tests using Spring built from source and with installed CDT package:

```
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -Dleap_DIR="${LEAP_BUILD_PATH}/lib/cmake/leap" ..
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -Dspring_DIR="${SPRING_BUILD_PATH}/lib/cmake/spring" ..
make -j $(nproc)
```

**Note:** `CMAKE_BUILD_TYPE` has no impact on the WASM files generated for the contracts. It only impacts how the test binaries are built. Use `-DCMAKE_BUILD_TYPE=Debug` if you want to create test binaries that you can debug.

<details>
<summary>Build reference contracts with tests using Leap and CDT both built from source</summary>
<summary>Build reference contracts with tests using Spring and CDT both built from source</summary>

```
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -Dcdt_DIR="${CDT_BUILD_PATH}/lib/cmake/cdt" -Dleap_DIR="${LEAP_BUILD_PATH}/lib/cmake/leap" ..
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -Dcdt_DIR="${CDT_BUILD_PATH}/lib/cmake/cdt" -Dspring_DIR="${SPRING_BUILD_PATH}/lib/cmake/spring" ..
make -j $(nproc)
```
</details>
Expand Down
18 changes: 9 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eo pipefail
function usage() {
printf "Usage: $0 OPTION...
-c DIR Path to CDT installation/build directory. (Optional if using CDT installled at standard system location.)
-l DIR Path to Leap build directory. Optional, but must be specified to build tests.
-l DIR Path to Spring build directory. Optional, but must be specified to build tests.
-h Print this help menu.
\\n" "$0" 1>&2
exit 1
Expand All @@ -19,7 +19,7 @@ if [ $# -ne 0 ]; then
CDT_INSTALL_DIR=$(realpath $OPTARG)
;;
l )
LEAP_BUILD_DIR=$(realpath $OPTARG)
SPRING_BUILD_DIR=$(realpath $OPTARG)
BUILD_TESTS=ON
;;
h )
Expand All @@ -40,19 +40,19 @@ if [ $# -ne 0 ]; then
done
fi

LEAP_DIR_CMAKE_OPTION=''
SPRING_DIR_CMAKE_OPTION=''

if [[ "${BUILD_TESTS}" == "ON" ]]; then
if [[ ! -f "$LEAP_BUILD_DIR/lib/cmake/leap/leap-config.cmake" ]]; then
echo "Invalid path to Leap build directory: $LEAP_BUILD_DIR"
echo "Leap build directory is required to build tests. If you do not wish to build tests, leave off the -l option."
if [[ ! -f "$SPRING_BUILD_DIR/lib/cmake/spring/spring-config.cmake" ]]; then
echo "Invalid path to Spring build directory: $SPRING_BUILD_DIR"
echo "Spring build directory is required to build tests. If you do not wish to build tests, leave off the -l option."
echo "Cannot proceed. Exiting..."
exit 1;
fi

echo "Using Leap build directory at: $LEAP_BUILD_DIR"
echo "Using Spring build directory at: $SPRING_BUILD_DIR"
echo ""
LEAP_DIR_CMAKE_OPTION="-Dleap_DIR=${LEAP_BUILD_DIR}/lib/cmake/leap"
SPRING_DIR_CMAKE_OPTION="-Dspring_DIR=${SPRING_BUILD_DIR}/lib/cmake/spring"
fi

CDT_DIR_CMAKE_OPTION=''
Expand All @@ -79,6 +79,6 @@ NC='\033[0m'
CPU_CORES=$(getconf _NPROCESSORS_ONLN)
mkdir -p build
pushd build &> /dev/null
cmake -DBUILD_TESTS=${BUILD_TESTS} ${LEAP_DIR_CMAKE_OPTION} ${CDT_DIR_CMAKE_OPTION} ../
cmake -DBUILD_TESTS=${BUILD_TESTS} ${SPRING_DIR_CMAKE_OPTION} ${CDT_DIR_CMAKE_OPTION} ../
make -j $CPU_CORES
popd &> /dev/null
2 changes: 1 addition & 1 deletion docs/01_key-concepts/02_ram.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ RAM is a very important system resource because of the following reasons:

RAM is a scarce resource priced according to the unique Bancor liquidity algorithm which is implemented in the system contract [here](https://github.com/AntelopeIO/reference-contracts/blob/main/contracts/eosio.system/include/eosio.system/exchange_state.hpp).

The RAM system resource must be purchased using the system token. Refer to the [cleos manual](https://github.com/AntelopeIO/leap/blob/main/docs/02_cleos/02_how-to-guides/how-to-buy-ram.md) to learn how to buy RAM via the command line interface.
The RAM system resource must be purchased using the system token. Refer to the [cleos manual](https://github.com/AntelopeIO/spring/blob/main/docs/02_cleos/02_how-to-guides/how-to-buy-ram.md) to learn how to buy RAM via the command line interface.
4 changes: 2 additions & 2 deletions docs/01_key-concepts/05_stake.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Antelope-based blockchain accounts need sufficient system resources, RAM, CPU an

### Stake NET and CPU

The CPU and NET system resources are allocated by the account owner via the staking mechanism. Refer to the [cleos manual](https://github.com/AntelopeIO/leap/blob/main/docs/02_cleos/02_how-to-guides/how-to-stake-resource.md) on how to do it via the command line interface.
The CPU and NET system resources are allocated by the account owner via the staking mechanism. Refer to the [cleos manual](https://github.com/AntelopeIO/spring/blob/main/docs/02_cleos/02_how-to-guides/how-to-stake-resource.md) on how to do it via the command line interface.

You will also find that staking/unstaking is at times referred to as delegating/undelegating. The economics of staking is also to provably commit to a promise that you will hold the staked tokens, either for NET or CPU, for a pre-established period of time, in spite of inflation caused by minting new tokens in order to reward BPs for their services every 24 hours.

Expand Down Expand Up @@ -46,4 +46,4 @@ This formula has the following outcomes:

### Buy RAM

The RAM resource must be bought using the system token. Refer to the [cleos manual](https://github.com/AntelopeIO/leap/blob/main/docs/02_cleos/02_how-to-guides/how-to-buy-ram.md) to learn how to do it via the command line interface. When an account consumes all its allocated RAM can not store any additional information on the blockchain database until it frees some of the occupied RAM or more RAM is allocated to the account through the RAM buying process.
The RAM resource must be bought using the system token. Refer to the [cleos manual](https://github.com/AntelopeIO/spring/blob/main/docs/02_cleos/02_how-to-guides/how-to-buy-ram.md) to learn how to do it via the command line interface. When an account consumes all its allocated RAM can not store any additional information on the blockchain database until it frees some of the occupied RAM or more RAM is allocated to the account through the RAM buying process.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ executed transaction: 60d334850151cb95c35fe31ce2e8b536b51441c5fd4c3f2fea98edcc6d
# bob <= eosio.token::transfer {"from":"eosio","to":"bob","quantity":"25.0000 SYS","memo":"m"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
```
Now check if "bob" got the tokens using [cleos get currency balance](https://github.com/AntelopeIO/leap/blob/main/docs/02_cleos/03_command-reference/get/currency-balance.md)
Now check if "bob" got the tokens using [cleos get currency balance](https://github.com/AntelopeIO/spring/blob/main/docs/02_cleos/03_command-reference/get/currency-balance.md)

```shell
cleos get currency balance eosio.token bob SYS
Expand Down
16 changes: 8 additions & 8 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
cmake_minimum_required(VERSION 3.5)

set(EOSIO_VERSION_MIN "3.1")
set(EOSIO_VERSION_SOFT_MAX "5.0")
set(EOSIO_VERSION_MIN "1.0")
set(EOSIO_VERSION_SOFT_MAX "1.0")
# set(EOSIO_VERSION_HARD_MAX "")

find_package(leap)
find_package(spring)

# Check the version of Leap
if(SYSTEM_ENABLE_LEAP_VERSION_CHECK)
# Check the version of Spring
if(SYSTEM_ENABLE_SPRING_VERSION_CHECK)
set(VERSION_MATCH_ERROR_MSG "")
eosio_check_version(VERSION_OUTPUT "${EOSIO_VERSION}" "${EOSIO_VERSION_MIN}" "${EOSIO_VERSION_SOFT_MAX}"
"${EOSIO_VERSION_HARD_MAX}" VERSION_MATCH_ERROR_MSG)
if(VERSION_OUTPUT STREQUAL "MATCH")
message(STATUS "Using Leap version ${EOSIO_VERSION}")
message(STATUS "Using Spring version ${EOSIO_VERSION}")
elseif(VERSION_OUTPUT STREQUAL "WARN")
message(
WARNING
"Using Leap version ${EOSIO_VERSION} even though it exceeds the maximum supported version of ${EOSIO_VERSION_SOFT_MAX}; continuing with configuration, however build may fail.\nIt is recommended to use Leap version ${EOSIO_VERSION_SOFT_MAX}.x"
"Using Spring version ${EOSIO_VERSION} even though it exceeds the maximum supported version of ${EOSIO_VERSION_SOFT_MAX}; continuing with configuration, however build may fail.\nIt is recommended to use Spring version ${EOSIO_VERSION_SOFT_MAX}.x"
)
else() # INVALID OR MISMATCH
message(
FATAL_ERROR
"Found Leap version ${EOSIO_VERSION} but it does not satisfy version requirements: ${VERSION_MATCH_ERROR_MSG}\nPlease use Leap version ${EOSIO_VERSION_SOFT_MAX}.x"
"Found Spring version ${EOSIO_VERSION} but it does not satisfy version requirements: ${VERSION_MATCH_ERROR_MSG}\nPlease use Spring version ${EOSIO_VERSION_SOFT_MAX}.x"
)
endif(VERSION_OUTPUT STREQUAL "MATCH")
endif()
Expand Down
4 changes: 2 additions & 2 deletions tests/eosio.bios_inst_fin_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ BOOST_AUTO_TEST_SUITE(eosio_bios_if_tests)

// one finalizer in finalizer policy
BOOST_FIXTURE_TEST_CASE( set_1_finalizer, eosio_bios_if_tester ) try {
// public_key and pop are generated by leap-util
// public_key and pop are generated by spring-util
push_action("iftester"_n, "setfinalizer"_n, "iftester"_n, mvo()
("finalizer_policy", mvo()
("threshold", 2)
Expand All @@ -65,7 +65,7 @@ BOOST_FIXTURE_TEST_CASE( set_1_finalizer, eosio_bios_if_tester ) try {

// two finalizers in finalizer policy
BOOST_FIXTURE_TEST_CASE( set_2_finalizers, eosio_bios_if_tester ) try {
// public_key and pop are generated by leap-util
// public_key and pop are generated by spring-util
push_action("iftester"_n, "setfinalizer"_n, "iftester"_n, mvo()
("finalizer_policy", mvo()
("threshold", 5)
Expand Down

0 comments on commit 94d5044

Please sign in to comment.