Skip to content

Commit

Permalink
feat: implement inflating tail emission
Browse files Browse the repository at this point in the history
This PR primarily adds tail emission inflation as a featuer; but it does
so using feature gates, which were broken in a few places, and so a big
part of this PR is resolving issues related to feature gates.

== Tail emission inflation

Adds a feature tari_feature_mainnet_emission to allow for tail emission
inflation. See #6122

This change necessitates the addition of 2 new consensus constants:
`inflation_bips` -- the annual inflation rate of the total supply.
and `tail_emission_epoch_length`, which controls the tail emission
inflation. These replace `tail_emission`.

We update the Protobuf definition for ConsensusConstants to account for
the new fields.

== Getting Feature flags working

When formally implementing compiler features, the setting of the `TARI_NETWORK`
and (from now) `TARI_TARGET_NETWORK` envar and the related compiler flags matter.

These changes require that when tests run, the correct network flags are set.

For example, blocks::genesis_block::test::stagenet_genesis_sanity_check should
only run when TARI_NETWORK=stagenet.

While writing this PR, I uncovered a problem:
There is not a 1:1 mapping between the build _target_ and the actual
network the binary may run on. E.g. the mainnet build can run on either
stagenet or mainnet.

Unfortunately the `TARI_NETWORK` envar was used to set both of these
variables. Without using feature flags, this discrepency went unnoticed.
With feature flags, a lot of tests that implicitly assumed say a mainnet
target and a stagenet run would simply fail, with no way to resolve the
issue.

Since these are 2 different things, this commit introduced
`TARI_TARGET_NETWORK` whicg sets the **build target**. In most contexts,
this then decouples the configured network, which is specified by the
`TARI_NETWORK` envar  as usual.

The other changes in this commit revolve around updating merkle roots
and the correct faucet sets to make the target/network/faucet
combination consistent.

== CI workflows

The CI is configured to run tests for each of
* Testnet (Esme)
* Nextnet (Nextnet)
* Mainnet (Mainnet, with some tests specifying stagenet)

=== remove env_logger

I used env_logger to try print the feature list at compiler time, but it
doesn't work, so rather remove it.

A better strategy (implemented in this commit) is to print
"tari_feature" as a prefix to the message emitted by build.rs. Then you
can do soemthing like

`cargo build -vv .... 2>/dev/null` | grep "tari_feature"`

Piping stderr to dev null hides all the noise from rustc, and then you
can grep for the messages you want (or omit the grep to see the usual
build messages among the rest)

===  set network according to pols

Sets the network according to the principle of least surprise. i.e. if
TARI_NETWORK is set, try and make that the default network.
  • Loading branch information
CjS77 committed Feb 9, 2024
1 parent 5e0a6c2 commit 41f1135
Show file tree
Hide file tree
Showing 43 changed files with 1,264 additions and 978 deletions.
12 changes: 12 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,15 @@ slow-timeout = { period = "60s", terminate-after=2}

[profile.ci.junit] # this can be some other profile, too
path = "junit.xml"

[profile.intellij]
retries = 0
slow-timeout = { period = "30s" }
failure-output = "immediate-final"
fail-fast = false

[profile.intellij.junit] # this can be some other profile, too
path = "junit.xml"



2 changes: 2 additions & 0 deletions .github/workflows/base_node_binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ jobs:
run: |
source buildtools/multinet_envs.sh ${{ env.GHA_NETWORK }}
echo ${TARI_NETWORK}
echo ${TARI_TARGET_NETWORK}
echo ${TARI_NETWORK_DIR}
echo "TARI_NETWORK=${TARI_NETWORK}" >> $GITHUB_ENV
echo "TARI_TARGET_NETWORK=${TARI_TARGET_NETWORK}" >> $GITHUB_ENV
echo "TARI_NETWORK_DIR=${TARI_NETWORK_DIR}" >> $GITHUB_ENV
echo "TARI_NETWORK_DIR=${TARI_NETWORK_DIR}" >> $GITHUB_OUTPUT
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build_dockers_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ jobs:
source tari/buildtools/multinet_envs.sh ${{github.ref_name}}
echo ${TARI_NETWORK}
echo "TARI_NETWORK=${TARI_NETWORK}" >> $GITHUB_ENV
echo ${TARI_TARGET_NETWORK}
echo "TARI_TARGET_NETWORK=${TARI_TARGET_NETWORK}" >> $GITHUB_ENV
- name: environment setup
shell: bash
Expand Down Expand Up @@ -225,6 +227,7 @@ jobs:
APP_NAME=${{ matrix.builds.app_name }}
APP_EXEC=${{ matrix.builds.app_exec }}
TARI_NETWORK=${{ env.TARI_NETWORK }}
TARI_TARGET_NETWORK=${{ env.TARI_TARGET_NETWORK }}
${{ env.DOCKER_SUBTAG }}
tags: |
${{ steps.meta.outputs.tags }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build_libffis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ jobs:
run: |
source buildtools/multinet_envs.sh ${{ github.ref_name }}
echo ${TARI_NETWORK}
echo ${TARI_TARGET_NETWORK}
echo ${TARI_NETWORK_CHANGELOG}
echo "TARI_NETWORK=${TARI_NETWORK}" >> $GITHUB_ENV
echo "TARI_TARGET_NETWORK=${TARI_TARGET_NETWORK}" >> $GITHUB_ENV
echo "TARI_NETWORK_CHANGELOG=${TARI_NETWORK_CHANGELOG}" >> $GITHUB_ENV
- name: Declare Android/iOS envs
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ jobs:
permissions:
checks: write
pull-requests: write
strategy:
matrix:
tari_target_network: [
{ target: "testnet", network: "esmeralda" },
{ target: "nextnet", network: "nextnet" },
{ target: "mainnet", network: "stagenet" },
]
env:
TARI_TARGET_NETWORK: ${{ matrix.tari_target_network.target }}
TARI_NETWORK: ${{ matrix.tari_target_network.network }}
RUST_LOG: debug
steps:
- name: checkout
uses: actions/checkout@v4
Expand All @@ -192,14 +203,15 @@ jobs:
~/.cargo/registry/CACHEDIR.TAG
~/.cargo/git
target
key: tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly-${{ hashFiles('**/Cargo.lock') }}
key: tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.tari_target_network.target }}
restore-keys: |
tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.tari_target_network.network }}
tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly-${{ hashFiles('**/Cargo.lock') }}
tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly
- name: Install cargo-nextest
run: cargo install cargo-nextest --locked --force
- name: cargo test compile
run: cargo test --no-run --locked --all-features --release
run: cargo test -vv --no-run --locked --all-features --release
- name: cargo test
run: cargo nextest run --all-features --release -E "not package(tari_integration_tests)" --profile ci
- name: upload artifact
Expand Down

0 comments on commit 41f1135

Please sign in to comment.