Giter VIP home page Giter VIP logo

ethereumjs-block's People

Contributors

alcuadrado avatar alextsg avatar ausiv avatar axic avatar cdetrio avatar danjm avatar evertonfraga avatar fanatid avatar greenkeeperio-bot avatar holgerd77 avatar jwasinger avatar kostasx avatar kumavis avatar nicholasjpaterno avatar ryanio avatar s1na avatar serapath avatar tcoulter avatar vpulim avatar wanderer avatar whymarrh avatar wolovim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ethereumjs-block's Issues

Invalid Signature when validating pre-homestead blocks

https://github.com/ethereumjs/ethereumjs-block/blob/master/index.js#L76

This line appears to set homestead to true, even for blocks that happen before homestead.

When processing blocks before the fork, I often get an invalid signature error for transactions due to https://github.com/ethereumjs/ethereumjs-tx/blob/471037fb1146983884bf45206dba021b04867f59/index.js#L194

For me I changed index.js to only turn homestead on for blocks that happened after the fork

  // parse transactions
  const height = new BN(this.header.number).toNumber()
  for (i = 0; i < rawTransactions.length; i++) {
    var tx = new Tx(rawTransactions[i])
    tx._homestead = height >= 1150000;
    this.transactions.push(tx)
  }

As an aside, current version of ethereumjs-tx appear to use ethereumjs-common to try to determine hardfork settings.

Browserify fails when ethereumjs-block is a dependency of a dependency

When trying to browserify code that depends on ethereumjs-block, browserify fails because it cannot find the appropriate babel preset relative to the ethereumjs-block project. Removing the "browserify" section from ethereumjs-block's package.json seemed to fix the issue.

For example:

garbados@zebu:~/code/sat-home$ npm run build

> [email protected] build /home/garbados/code/sat-home
> browserify index.js -o app.js

Error: Couldn't find preset "es2015" relative to directory "/home/garbados/code/cubesat-db/node_modules/ethereumjs-block" while parsing file: /home/garbados/code/cubesat-db/node_modules/ethereumjs-block/header.js
    at /home/garbados/code/cubesat-db/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (/home/garbados/code/cubesat-db/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/home/garbados/code/cubesat-db/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/home/garbados/code/cubesat-db/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/home/garbados/code/cubesat-db/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at File.initOptions (/home/garbados/code/cubesat-db/node_modules/babel-core/lib/transformation/file/index.js:212:65)
    at new File (/home/garbados/code/cubesat-db/node_modules/babel-core/lib/transformation/file/index.js:135:24)
    at Pipeline.transform (/home/garbados/code/cubesat-db/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at Babelify._flush (/home/garbados/code/cubesat-db/node_modules/babelify/index.js:26:24)

Remove ethereumjs-testing dependency

Currently the very heavy (several 100 MB) ethereumjs-testing version is pulled into the library (over and above in an outdated version) and just used to include a single file with const testDataGenesis = testing.getSingleFile('BasicTests/genesishashestest.json') in block.js and header.js test files.

This should be replaced by a static copy-and-paste approach like being done for the difficulty files and the dependency should be removed.

The copied over file from the tests repository should be extended with a structure:

{
  "source": "https://github.com/ethereum/tests/blob/develop/BasicTests/genesishashestest.json",
  "commit": "149cc9b",
  "date": "2018-10-12",
  "tests": {
  }
}

so that it is becoming clear where this is coming from and what version has being used.

Backport block validation based on hardfork

The block validation code in the canonicalDifficulty() method has been updated on the Byzantium release to fit the new formula.

This has to be backported to allow for block validation for pre-Byzantium blocks in the context of ethereumjs-client usage. The code is still there in the repository history, this shouldn't just be taken as a loose blueprint and implemented more cleanly in the context of the switch. Hardfork switch will be done by the ethereumjs-common library, see PR below.

Depends on #44.

TypeScript support

It'd be nice if this and other commonly-used ethereumjs projects had *.d.ts files so that they could be used with TypeScript projects.

Type interface for Block

It would be nice if we had an exportable type for Block.

We are using any in ethereumjs-blockchain and it's no fun.

A question about validate difficulty

When validate a block difficultly header use:

return dif.cmp(new BN(this.difficulty)) === 0>

emmm, if a difficulty is current, this.difficulty should be equal to dif.
So code should be

return dif.cmp(new BN(this.difficulty)) === 1

Why we you zero in header code?

Typescript migration

Not having types in this library was by far the major source of bugs I had when working with the VM. I think we should consider migrating it.

Uninitialized dif variable cases in canonicalDifficulty()

Just wanted to update the blockchain library with the new v2.2.2 block version. Tests are currently breaking in the "mismatched chains" section with:

TAP version 13
# blockchain test
# mismatched chains

/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-blockchain/node_modules/ethereumjs-block/header.js:172
  if (dif.cmp(minimumDifficulty) === -1) {
          ^
TypeError: Cannot read property 'cmp' of undefined
    at module.exports.BlockHeader.canonicalDifficulty (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-blockchain/node_modules/ethereumjs-block/header.js:172:11)
    at Test.<anonymous> (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-blockchain/test/index.ts:888:52)
    at Test.bound [as _cb] (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-blockchain/node_modules/tape/lib/test.js:76:32)
    at Test.run (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-blockchain/node_modules/tape/lib/test.js:95:10)
    at Test.bound [as run] (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-blockchain/node_modules/tape/lib/test.js:76:32)
    at Test._end (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-blockchain/node_modules/tape/lib/test.js:164:11)
    at Test.bound [as _end] (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-blockchain/node_modules/tape/lib/test.js:76:32)
    at Immediate._onImmediate (/Users/hdrewes/Documents/DEV/EthereumJS/ethereumjs-blockchain/node_modules/tape/lib/test.js:117:18)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)

This is caused by a triggered case where dif is not initialized and can be fixed by initializing diff with var dif = BN(0).

This would unfortunately need another v2.2.3 release on the backport side, we should also make sure that this gets applied to master as well, so there might be the need to open two PRs here (one fix + v2.2.3 release PR branched off from the release/v2.2.2 backport branch and one just with the fix (TypeScript-adjusted) towards master.

I will unfortunately not find the time to do this, @evertonfraga: not sure, can you jump in here?

testBlockchainTotalDifficulty fails in ethereumjs-vm using version 2.0.0 of block

npm run testBlockchainTotalDifficulty fails in ethereumjs-vm (versions 2.3.5 and 2.4.0) after replacing ethereumjs-block 1.7.0 with 2.0.0 in package.json.

Sample of test output:

# BlockchainTests
# file: lotsOfBranches test: lotsOfBranches_Byzantium
ok 1 correct pre stateRoot
ok 2 correct genesis RLP
ok 3 last block hash
ok 4 correct header block
# file: lotsOfBranchesOverrideAtTheEnd test: lotsOfBranchesOverrideAtTheEnd_Byzantium
ok 5 correct pre stateRoot
ok 6 correct genesis RLP
not ok 7 last block hash
  ---
    operator: equal
    expected: |-
      '81ad10692f377ca6aecc0c878f0705249e11e94722694ef0aac7c9708e2d99de'
    actual: |-
      '0e45d702a567610b812f2e8994e58355f76f3d85962f2252b4abc83b8a98844f'
    at: self.blockDb.get (/Users/vpulim/dev/ethereumjs-vm/node_modules/ethereumjs-blockchain/index.js:331:7)
  ...
not ok 8 correct header block
  ---
    operator: equal
    expected: |-
      '81ad10692f377ca6aecc0c878f0705249e11e94722694ef0aac7c9708e2d99de'
    actual: |-
      '0e45d702a567610b812f2e8994e58355f76f3d85962f2252b4abc83b8a98844f'
    at: replenish (/Users/vpulim/dev/ethereumjs-vm/node_modules/async/dist/async.js:993:25)
  ...

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.