Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix block validation failure in Windows for Rust tool-chain nightly-2020-06-10 #2035

Conversation

hansieodendaal
Copy link
Contributor

@hansieodendaal hansieodendaal commented Jul 1, 2020

Description

  1. Commit df95cee introduced a bug in Windows builds that resulted in certain blocks failing validation tests. The cause
    was traced to inconsistent implementation of the std::f64::powi function in certain Rust toolchains, where
    the Tari Windows code would give a slightly different floating-point result than Linux. This affected the
    missionSchedule::block_reward calculation, which caused block validation for certain block numbers to fail.
    The solution was to use crate num::pow for the power calculation.
    (See related Rust issue: Implementation of std::f64::powi function gives inconsistent answers in multiple Rust tool-chains rust-lang/rust#73920)

  2. Changed two other instances where std::f64::powi were used.

Example,

std::f64::powi(0.9999995604090385, 9182) => 0.9959718099156295 expected, but returns 0.9959718099154268

results in

EmissionSchedule::block_reward(9182) => 5517534590 expected, but returns 5516534589

This closes #2022.

Motivation and Context

When using Rust toolchain nightly-2020-06-10 all block validation tests should pass, otherwise a base node will not be able to sync to the blockchain.

How Has This Been Tested?

Tested in Windows 10 and Linux Ubuntu 18.04.4 LTS .

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Feature refactor (No new feature or functional changes, but performance or technical debt improvements)
  • New Tests
  • Documentation

Checklist:

  • I'm merging against the development branch.
  • I ran cargo-fmt --all before pushing.
  • I have squashed my commits into a single commit.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

…rtain

blocks failing validation tests. The cause was traced to an erroneous implementation of the std::f64::powi
function in Rust toolchain nightly-2020-06-10, where Windows would give a slightly different floating point
result than Linux. This affected the EmissionSchedule::block_reward calculation, which caused block validation
for certain block numbers to fail.
@hansieodendaal hansieodendaal changed the title Fix block validation failure in Windows for Rust tool-chain nightly-2020-06-10 Jul 1, 2020
@stringhandler stringhandler merged commit 03ad21d into tari-project:development Jul 3, 2020
@hansieodendaal hansieodendaal deleted the ho_fix_block_validation_error branch July 6, 2020 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rust toolchain nightly-2020-06-10 causing block validation in Windows to fail.
2 participants