ethereumjs / ethereumjs-block

Project is in active development and has been moved to the EthereumJS VM monorepo.
https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/block
Mozilla Public License 2.0
42 stars 49 forks source link

Typescript migration #72

Closed alcuadrado closed 5 years ago

alcuadrado commented 5 years ago

This is a WIP PR migrating this library to Typescript.

Things missing are:

  1. Decide if we keep the json rpc functionality. Personally, as someone that works a lot with the RPC, I'd never expected that from this module.

  2. Update code inline docs.

  3. Keeping the callbacks-based API while modernizing the code (i.e. removing async) was kind of hard. Especially since browserify doesn't work well with promisify and callbackify. Maybe it's because of a combination of TS+borwserify+karma, but it made me lose a lot of time. I'm not sure if keeping that legacy API is worth the hassle. What do you think?

Some things to note:

I'll probably be able to finish this tomorrow.

closes #71, #67, #63, #43, #69, #68

holgerd77 commented 5 years ago

Great that your are tackling this so quickly, cool!

  1. Definitely not worth keeping - we have e.g. already decided on the VM to completely drop the callback based API in exchange with @s1na and some extended community-expert-hearing 😛 - so just throw the old stuff away 😄, that would be a great along-improvement.

Blockchain interface: whew, that's a deep-dive-analytical change, pretty interesting to hear (blockchain slow) and very cool that you stumble and directly tackle stuff like this.

@alcuadrado @micahriggan Ah, I wrote this comment before scanning over the work and explanations here, so comment seems to be already outdated respectively answered through the active process here.

@micahriggan Thanks for your work on the original PR and working out the problem space more clearly together!

alcuadrado commented 5 years ago
  1. Definitely not worth keeping - we have e.g. already decided on the VM to completely drop the callback based API in exchange with @s1na and some extended community-expert-hearing 😛 - so just throw the old stuff away 😄, that would be a great along-improvement.

Awesome! 🎉

I wrote this comment before scanning over the work and explanations here

Oops, same here. I answered in the other PR.

Blockchain interface: whew, that's a deep-dive-analytical change, pretty interesting to hear (blockchain slow) and very cool that you stumble and directly tackle stuff like this.

I'll open an issue with an explanation in the blockchain repo later today.

alcuadrado commented 5 years ago

I think this PR is ready to be reviewed now.

I ported the RPC-related functions, removed the callback-based API, fix the travis config, and documented the missing uncles' validation.

As a summary that could be added to the changelog, the main changes that this PR introduces are:

  1. The codebase has been ported to TypeScript.
  2. This library only offers a Promise-based API now.
  3. Errors now are instances of Error instead of strings.
  4. Updated ethereum-util and ethereumjs-tx to their latest versions.
alcuadrado commented 5 years ago

Please, take a look at the initial message from this PR, as it's relevant here: https://github.com/ethereumjs/ethereumjs-vm/pull/566

alcuadrado commented 5 years ago

@holgerd77 I addressed all the issues. Just not sure if something different can be done about this one.

micahriggan commented 5 years ago

Amazing 😍