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

RocksDB Linux ARM support. #5845

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

donbeave
Copy link

What does this PR do?

Upgraded version to the latest minor version of rocksdbjni.

Why are these changes required?

This upgrade added support for Linux ARM64. Related to #4692.

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Can try this docker image, it built with these changes, it works on amd64/arm64 linux: https://hub.docker.com/r/donbeave/docker-tron-full-node

Here are Dockerfiles for this docker build:

  1. ARM64/AArch64: https://github.com/ChainArgos/docker-tron-full-node/blob/main/Dockerfile.arm64
  2. x86-64: https://github.com/ChainArgos/docker-tron-full-node/blob/main/Dockerfile.amd64

@lvs007 lvs007 requested a review from halibobo1205 June 3, 2024 04:16
@halibobo1205
Copy link
Contributor

As far as I know, the following work is needed to support the ARM architecture:
Unlike some of the numeric methods of class StrictMath, all implementations of the equivalent functions of class Math are not defined to return the bit-for-bit same results.
Because TRON uses math.pow instead of strictMath.pow in jdk8_x86_64, some numerical calculations are inconsistent across architectures or higher jdk. The code is shown below:

    logger.debug("balance: " + balance);
    long newBalance = balance + quant;
    logger.debug("balance + quant: " + newBalance);

    double issuedSupply = -supply * (1.0 - Math.pow(1.0 + (double) quant / newBalance, 0.0005));
    logger.debug("issuedSupply: " + issuedSupply);
    long out = (long) issuedSupply;
    supply += out;

    return out;
  }

The test cases are as follows:

 @Test
  public void testPow() {
    double x = 29218;
    double q = 4761432;
    double ret = Math.pow(1.0 + x / q, 0.0005);
    double ret2 = StrictMath.pow(1.0 + x / q, 0.0005);

    System.out.printf("%s%n", doubleToHex(ret)); //  3ff000033518c576
    System.out.printf("%s%n", doubleToHex(ret2)); // 3ff000033518c575
    Assert.assertEquals(0, Double.compare(ret, ret2)); // fail in jdk8_X86.
  }

  public static String doubleToHex(double input) {
    // Convert the starting value to the equivalent value in a long
    long doubleAsLong = Double.doubleToRawLongBits(input);
    // and then convert the long to a hex string
    return Long.toHexString(doubleAsLong);
  }

We are trying to solve this problem but don't have good ideas.

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.

3 participants