Skip to content

Commit

Permalink
Feature 1: Any asset fees (#45)
Browse files Browse the repository at this point in the history
Modification of Elements blockchain to support paying the transaction fees in any asset that is issued on chain. Includes features like:

  - Switch variable in chainparams for any_asset_fees feature
  - Exchange rates to compare assets value in order to calculate fees
  - Denomination field in issue asset to interpret the amount with different decimals in clients
  - Initial testnet parameters for Sequentia network
  ...
  • Loading branch information
Mixa84 authored Sep 9, 2024
1 parent fc9dda3 commit 34128e7
Show file tree
Hide file tree
Showing 255 changed files with 37,333 additions and 5,738 deletions.
38 changes: 22 additions & 16 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,30 @@ base_template: &BASE_TEMPLATE

main_template: &MAIN_TEMPLATE
timeout_in: 120m # https://cirrus-ci.org/faq/#instance-timed-out
ccache_cache:
folder: "/tmp/ccache_dir"
ci_script:
- ./ci/test_run_all.sh

global_task_template: &GLOBAL_TASK_TEMPLATE
<< : *BASE_TEMPLATE
container:
# https://cirrus-ci.org/faq/#are-there-any-limits
# Each project has 16 CPU in total, assign 2 to each container, so that 8 tasks run in parallel
cpu: 2
greedy: true
memory: 8G # Set to 8GB to avoid OOM. https://cirrus-ci.org/guide/linux/#linux-containers
ccache_cache:
folder: "/tmp/ccache_dir"
depends_built_cache:
folder: "depends/built"
fingerprint_script: echo $CIRRUS_TASK_NAME $(git rev-list -1 HEAD ./depends)
ci_script:
- ./ci/test_run_all.sh
<< : *MAIN_TEMPLATE

global_task_template: &GLOBAL_TASK_TEMPLATE
macos_native_task_template: &MACOS_NATIVE_TASK_TEMPLATE
<< : *BASE_TEMPLATE
check_clang_script:
- clang --version
brew_install_script:
- brew install boost libevent qt@5 miniupnpc libnatpmp ccache zeromq qrencode libtool automake gnu-getopt
<< : *MAIN_TEMPLATE

compute_credits_template: &CREDITS_TEMPLATE
Expand Down Expand Up @@ -86,9 +94,9 @@ task:
CI_VCPKG_TAG: '2021.05.12'
VCPKG_DOWNLOADS: 'C:\Users\ContainerAdministrator\AppData\Local\vcpkg\downloads'
VCPKG_DEFAULT_BINARY_CACHE: 'C:\Users\ContainerAdministrator\AppData\Local\vcpkg\archives'
QT_DOWNLOAD_URL: 'https://download.qt.io/official_releases/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.zip'
QT_LOCAL_PATH: 'C:\qt-everywhere-src-5.15.2.zip'
QT_SOURCE_DIR: 'C:\qt-everywhere-src-5.15.2'
QT_DOWNLOAD_URL: 'https://download.qt.io/official_releases/qt/5.15/5.15.3/single/qt-everywhere-opensource-src-5.15.3.zip'
QT_LOCAL_PATH: 'C:\qt-everywhere-opensource-src-5.15.3.zip'
QT_SOURCE_DIR: 'C:\qt-everywhere-src-5.15.3'
QTBASEDIR: 'C:\Qt_static'
x64_NATIVE_TOOLS: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"'
IgnoreWarnIntDirInTempDetected: 'true'
Expand Down Expand Up @@ -263,13 +271,13 @@ task:
FILE_ENV: "./ci/test/00_setup_env_i686_multiprocess.sh"

task:
name: '[no wallet, libbitcoinkernel] [bionic]'
name: '[no wallet] [bionic]'
<< : *GLOBAL_TASK_TEMPLATE
container:
image: ubuntu:bionic
env:
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV
FILE_ENV: "./ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh"
FILE_ENV: "./ci/test/00_setup_env_native_nowallet.sh"

task:
name: 'macOS 10.15 [gui, no tests] [focal]'
Expand All @@ -286,18 +294,16 @@ task:
FILE_ENV: "./ci/test/00_setup_env_mac.sh"

task:
name: 'macOS 12 native [gui, system sqlite only] [no depends]'
brew_install_script:
- brew install boost libevent qt@5 miniupnpc libnatpmp ccache zeromq qrencode libtool automake gnu-getopt
<< : *GLOBAL_TASK_TEMPLATE
name: 'macOS 13 native arm64 [gui, sqlite only] [no depends]'
macos_instance:
# Use latest image, but hardcode version to avoid silent upgrades (and breaks)
image: monterey-xcode-13.2 # https://cirrus-ci.org/guide/macOS
image: ghcr.io/cirruslabs/macos-ventura-xcode:14.1 # https://cirrus-ci.org/guide/macOS
<< : *MACOS_NATIVE_TASK_TEMPLATE
env:
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV
CI_USE_APT_INSTALL: "no"
PACKAGE_MANAGER_INSTALL: "echo" # Nothing to do
FILE_ENV: "./ci/test/00_setup_env_mac_host.sh"
FILE_ENV: "./ci/test/00_setup_env_mac_native_arm64.sh"

task:
name: 'ARM64 Android APK [focal]'
Expand Down
120 changes: 100 additions & 20 deletions .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Sequentia Core CI
name: Build-dev

on:
workflow_dispatch:
Expand All @@ -12,42 +12,122 @@ on:
- dev

jobs:
build:
runs-on: ubuntu-20.04
build_and_test:
runs-on: ubuntu-22.04

continue-on-error: true
strategy:
matrix:
target: [x86_64-pc-linux-gnu, x86_64-w64-mingw32, x86_64-apple-darwin]
env:
TARGET: ${{matrix.target}}

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install ccache build-essential libtool autotools-dev automake pkg-config bsdmainutils python3 libevent-dev libboost-dev
wget -O - "https://apt.llvm.org/llvm.sh" | sudo bash -s 15
sudo apt-get install ccache build-essential libtool autotools-dev automake pkg-config bsdmainutils python3
sudo /usr/sbin/update-ccache-symlinks
echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a ~/.bashrc
source ~/.bashrc
- name: Install Windows dependencies
if: ${{ env.TARGET == 'x86_64-w64-mingw32' }}
run: sudo apt-get install zip g++-mingw-w64-x86-64-posix

- name: Install OSX dependencies
if: ${{ env.TARGET == 'x86_64-apple-darwin' }}
run: |
sudo apt-get install curl bsdmainutils cmake libz-dev python3-setuptools libtinfo5 xorriso cpio
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.job }}-${{ env.TARGET }}
max-size: 1G
append-timestamp: false

- name: Depends cache
id: deps-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/depends/${{ env.TARGET }}
key: ${{ env.TARGET }}-deps

- name: OSX SDK cache
id: osx-sdk-cache
if: ${{ env.TARGET == 'x86_64-apple-darwin' }}
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/depends/SDKs
key: ${{ env.TARGET }}-osx-sdk

- name: Extract XCode SDK
if: ${{ env.TARGET == 'x86_64-apple-darwin' && steps.osx-sdk-cache.outputs.cache-hit != 'true' }}
run: |
cd depends && mkdir SDKs && cd SDKs
wget http://mixakuca.ddns.net:8000/Xcode-12.2.tar.gz
tar -xzf Xcode-12.2.tar.gz
- name: Build depends
if: ${{ steps.deps-cache.outputs.cache-hit != 'true' }}
run: make -j$(nproc) -C depends HOST=${{env.TARGET}} NO_QT=1 NO_NATPMP=1 NO_UPNP=1 NO_ZMQ=1 NO_USDT=1

- name: Build
env:
BDB_PREFIX: '/home/runner/work/SEQ-Core-Elements/SEQ-Core-Elements/db4'
BDB_LIBS: '-L${BDB_PREFIX}/lib -ldb_cxx-4.8'
BDB_CFLAGS: '-I${BDB_PREFIX}/include'
CC: clang-15
CXX: clang++-15
CONFIG_SITE: ${{ github.workspace }}/depends/${{ env.TARGET }}/share/config.site
NOWARN_CXXFLAGS: -Wno-deprecated -Wno-unused-result
run: |
./autogen.sh
./contrib/install_db4.sh .
./configure --disable-bench --without-gui --without-natpmp --without-miniupnpc
./configure --enable-any-asset-fees
make clean
make -j$(nproc)
- name: Publish artifact - linux
- name: Run tests
id: tests
if: ${{ env.TARGET == 'x86_64-pc-linux-gnu' }}
run: |
echo "Running tests"
./test/functional/test_runner.py
- name: Prepare artifacts - Linux
if: ${{ env.TARGET == 'x86_64-pc-linux-gnu' && ( success() || ( failure() && steps.tests.conclusion == 'failure' ) ) }}
run: |
mkdir -p sequentia-dev-linux/bin sequentia-dev-linux/lib
cp src/elementsd src/elements-cli* src/elements-tx* src/elements-util* src/elements-wallet* sequentia-dev-linux/bin/
cp src/.libs/libelementsconsensus.so* sequentia-dev-linux/lib/
tar -cvf sequentia-dev-linux.tar --owner=0 --group=0 --numeric-owner sequentia-dev-linux
- name: Prepare artifacts - Windows
if: ${{ env.TARGET == 'x86_64-w64-mingw32' }}
run: |
mkdir -p sequentia-dev-win64/bin sequentia-dev-win64/lib
cp src/elementsd.exe src/elements-cli* src/elements-tx* src/elements-util* src/elements-wallet* sequentia-dev-win64/bin/
cp src/.libs/libelementsconsensus-0.dll sequentia-dev-win64/lib/
zip -r sequentia-dev-win64.zip sequentia-dev-win64
- name: Prepare artifacts - OSX
if: ${{ env.TARGET == 'x86_64-apple-darwin' }}
run: |
mkdir -p sequentia-dev-osx/bin sequentia-dev-osx/lib
cp src/elementsd src/elements-cli src/elements-tx src/elements-util src/elements-wallet sequentia-dev-osx/bin/
cp src/.libs/*.dylib sequentia-dev-osx/lib/
tar -cvf sequentia-dev-osx.tar --owner=0 --group=0 --numeric-owner sequentia-dev-osx
- name: Publish artifact
if: ${{ env.TARGET != 'x86_64-w64-mingw32' && ( success() || ( failure() && steps.tests.conclusion == 'failure' ) ) }}
uses: actions/upload-artifact@v4
with:
name: sequentia-dev-${{ env.TARGET }}
path: |
*.tar
- name: Publish artifact Windows
if: ${{ env.TARGET == 'x86_64-w64-mingw32' && ( success() || ( failure() && steps.tests.conclusion == 'failure' ) ) }}
uses: actions/upload-artifact@v4
with:
name: sequentia-linux
name: sequentia-dev-${{ env.TARGET }}
path: |
src/elementsd
src/elements-cli
src/elements-tx
src/elements-util
src/elements-wallet
*.zip
23 changes: 23 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint

on:
workflow_dispatch:
push:
branches:
- master
- dev
pull_request:
branches:
- master
- dev

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Run lint
run: |
sudo ./ci/lint_run_all.sh
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ src/elements-gui
src/elements-node
src/elements-tx
src/elements-util
src/elements-chainstate
src/elements-wallet
src/test/fuzz/fuzz
src/test/test_bitcoin
Expand Down Expand Up @@ -154,4 +153,4 @@ dist/
/guix-build-*

# nix
result
result
2 changes: 1 addition & 1 deletion .tx/config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[main]
host = https://www.transifex.com

[bitcoin.qt-translation-023x]
[o:bitcoin:p:bitcoin:r:qt-translation-023x]
file_filter = src/qt/locale/bitcoin_<lang>.xlf
source_file = src/qt/locale/bitcoin_en.xlf
source_lang = en
81 changes: 81 additions & 0 deletions README-nix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Building and Running with Nix

## Setup

### Installing Nix

If you aren't using Nix yet, install it from the
[Nix download page](https://nixos.org/download/).

On Linux (or Windows using WSL), this is typically as follows
(on macOS, omit the `--daemon`):
```
sh <(curl -L https://nixos.org/nix/install) --daemon
```

Another option is the
[Determinate Nix Installer](https://determinate.systems/posts/determinate-nix-installer/).

### Configuring Nix

Once you installed Nix, you can configure it to use our pre-compiled packages
instead of recompiling everything from source,
by creating or editing your `~/.config/nix/nix.conf` and adding these lines:
```
substituters = https://cache.nixos.org https://cache.nixos.org/ https://mukn.cachix.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= mukn.cachix.org-1:ujoZLZMpGNQMeZbLBxmOcO7aj+7E5XSnZxwFpuhhsqs=
```

## Building and Running the Software with Nix

### Building the Software

You can build the whole software package with:
```
nix-build
```

This will create a package under your `/nix/store/` and a symlink to it as `./result`.

### Running the Software as Built

After building the software as above, you can invoke the binaries directly with commands such as:
```
./result/bin/elements-cli
```

You can also install the package in your nix profile with either
`nix-env -i result` (if you use `nix-env`) or
`nix profile install result` (if you use `nix profile`).

TODO: In the future, we will also make it work with `nix flake`, and
when the project is stable and launched maybe submit it upstream onto Nixpkgs.

### Using a Nix shell for Development

To modify the source code and interactively build with all the dependencies
that would be used by Nix, you may enter a nix shell as follows:
```shell
nix-shell
```

You may then configure with the following command:
```bash
configurePhase
```

And build with this one:
```bash
buildPhase
```

Finally, you can run the tests with:
```bash
checkPhase
```

The `./src/` directory will have been added to your `PATH`
so you can run commands simply with:
```bash
elements-cli -?
```
4 changes: 2 additions & 2 deletions build_msvc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Qt
---------------------
To build Bitcoin Core with the GUI, a static build of Qt is required.

1. Download a single ZIP archive of Qt source code from https://download.qt.io/official_releases/qt/ (e.g., [`qt-everywhere-src-5.15.2.zip`](https://download.qt.io/official_releases/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.zip)), and expand it into a dedicated folder. The following instructions assume that this folder is `C:\dev\qt-source`.
1. Download a single ZIP archive of Qt source code from https://download.qt.io/official_releases/qt/ (e.g., [`qt-everywhere-opensource-src-5.15.3.zip`](https://download.qt.io/official_releases/qt/5.15/5.15.3/single/qt-everywhere-opensource-src-5.15.3.zip)), and expand it into a dedicated folder. The following instructions assume that this folder is `C:\dev\qt-source`.

2. Open "x64 Native Tools Command Prompt for VS 2019", and input the following commands:
```cmd
Expand Down Expand Up @@ -83,4 +83,4 @@ If is it enabled then in the output `Dynamic base` will be listed in the `DLL ch
Terminal Server Aware
```

This may not disable all stack randomization as versions of windows employ additional stack randomization protections. These protections must be turned off in the OS configuration.
This may not disable all stack randomization as versions of windows employ additional stack randomization protections. These protections must be turned off in the OS configuration.
Loading

0 comments on commit 34128e7

Please sign in to comment.