Giter Site home page Giter Site logo

Comments (6)

holgerd77 avatar holgerd77 commented on May 23, 2024 1

I think we should directly fix the addresses, should be doable with some clever search-and-replace.

from ethereumjs-common.

vpulim avatar vpulim commented on May 23, 2024 1

What is with the values, there is also some hex-decimal mix on this. Just have checked, at least this is consistent along a separate chain genesis file (e.g. mainnet.json). Would you also say that this is at least correctly working for now? My assumption without following the code paths is that non-prefixed values are regarded as being decimal?

Since no one uses the genesisStates files yet, it's hard to make a judgment about if the values are working correctly. It's really up to the user of the genesisStates to properly handle the mixed types. I think there can be three possible types for account balances:

  1. Number: This is a simple case where the value is obviously a decimal integer, but it can't be used for large numbers (more than 53 bits)
  2. String w/ 0x prefix: This is obviously a hex value and should be loaded with BN to hold the number value. This can be used for numbers larger than 53 bits.
  3. String w/o 0x prefix: This is the confusing case and should be avoided (in my opinion). It's unclear whether this is a raw string value (not possible for account balances), a number encoded in hex but with the 0x prefix missing, or a regular decimal number as a string (not hex-encoded).

Until we switch to TypeScript, my preference would be to always use a 0x prefix and hex encode numbers when they are encoded as string, or just use a plain number value (not a string).

from ethereumjs-common.

holgerd77 avatar holgerd77 commented on May 23, 2024

I think the real solution to this is really to stop this nonsense and be more strict in the utility functions in ethereumjs-util and just throw on stuff like this on the next breaking release. Then people can handle things like that properly.

We should really put some dedicated thought into that, makes probably sense to do this along the TypeScript transition (or directly before as a first and separate step).

from ethereumjs-common.

holgerd77 avatar holgerd77 commented on May 23, 2024

What is with the values, there is also some hex-decimal mix on this. Just have checked, at least this is consistent along a separate chain genesis file (e.g. mainnet.json). Would you also say that this is at least correctly working for now? My assumption without following the code paths is that non-prefixed values are regarded as being decimal?

from ethereumjs-common.

vpulim avatar vpulim commented on May 23, 2024

I think the real solution to this is really to stop this nonsense and be more strict in the utility functions in ethereumjs-util and just throw on stuff like this on the next breaking release. Then people can handle things like that properly.

We should really put some dedicated thought into that, makes probably sense to do this along the TypeScript transition (or directly before as a first and separate step).

Yes, totally agree. Great example of where TypeScript can really help.

from ethereumjs-common.

holgerd77 avatar holgerd77 commented on May 23, 2024

Closed by #33.

from ethereumjs-common.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.