Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Typescript migration #72

Merged
merged 25 commits into from
Aug 1, 2019
Merged

Typescript migration #72

merged 25 commits into from
Aug 1, 2019

Conversation

alcuadrado
Copy link
Member

@alcuadrado alcuadrado commented Jul 25, 2019

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 defined a Blockchain interface instead of using ethereumjs-blockchain because this way this module can easily work with other implementations. Our blockchain implementation is too slow for many use-cases, so this is important. I'll submit a PR with something similar in the VM.

  • I removed this validation, as it uses a deprecated method in ethereumjs-blockchain, which is actually a noop.

  • I copied the common-handling logic from chore: remove homestead + update eth dependencies #69. Thanks, @micahriggan !

I'll probably be able to finish this tomorrow.

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

@holgerd77
Copy link
Member

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!

.travis.yml Outdated Show resolved Hide resolved
@alcuadrado
Copy link
Member Author

  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
Copy link
Member Author

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 alcuadrado changed the title [WIP] Typescript migration Typescript migration Jul 29, 2019
@alcuadrado
Copy link
Member Author

Please, take a look at the initial message from this PR, as it's relevant here: ethereumjs/ethereumjs-monorepo#566

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just got through, thanks @alcuadrado, that is really a marvelous update with lots of small improvements all over the place, great, also just realizing the amount of work this has likely taken.

Some things to address, nothing too big though.

.travis.yml Show resolved Hide resolved
.travis.yml Outdated Show resolved Hide resolved
karma.conf.js Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
src/block.ts Outdated Show resolved Hide resolved
src/block.ts Outdated Show resolved Hide resolved

const height = new BN(this.header.number)
return uncleHeader.validate(blockchain, height)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am just not getting the whole picture why this "uncle already included" could be removed, could you give a really quick reasoning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be removed, but there's no way to validate it using ethereumjs-blockchain. The previous code was just calling a function of the blockchain that was a no-op.

This really surprised me, so I spent some time trying to figure out how it happened, but couldn't found the reason. All I know is that that functionality was removed in this PR: https://github.com/ethereumjs/ethereumjs-blockchain/pull/47/files#diff-168726dbe96b3ce427e7fedce31bb0bcR481

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//cc @vpulim

src/block.ts Show resolved Hide resolved
test/header.ts Show resolved Hide resolved
@alcuadrado
Copy link
Member Author

alcuadrado commented Jul 31, 2019

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

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now.

@micahriggan
Copy link

Amazing 😍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typescript migration
3 participants