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

Migrate precompiles, opcodes, eei, message, txContext to typescript #497

Merged
merged 24 commits into from
Apr 21, 2019

Conversation

s1na
Copy link
Contributor

@s1na s1na commented Apr 19, 2019

Happy for now with precompiles, but the rest are still subject to change. E.g. Message's constructor gets an opts: any, which doesn't utilize typescript's benefits.

I also tried migrating Interpreter and Loop but realized halfway that they need some changes before they can be typed well.

(To be merged into #479)

@holgerd77
Copy link
Member

Phew. 😄

@s1na
Copy link
Contributor Author

s1na commented Apr 19, 2019

Sorry didn't expect the diff to become so large 🙈

Might be easier to go through these commits:

Btw, the large commit history is because I'm reusing the same branch for the last couple of PRs.

@holgerd77
Copy link
Member

Ah, so this is actually ready for review? Misunderstood first.

@holgerd77
Copy link
Member

Just scrolled through for a first round, think this will be manageable for review. 😀😛

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 all good, thanks Sina for all this constant work, really great! Enjoy easter holidays 🐰 🌷 👍!!

throw new VmError(err)
}

const MASK_160 = new BN(1).shln(160).subn(1)
function addressToBuffer (address) {
function addressToBuffer (address: BN) {
return address.and(MASK_160).toArrayLike(Buffer, 'be', 20)
}
Copy link
Member

Choose a reason for hiding this comment

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

Looks good (eei.ts).

@@ -17,7 +31,7 @@ module.exports = class Message {
this.delegatecall = opts.delegatecall || false
}

get codeAddress () {
get codeAddress (): Buffer {
return this._codeAddress ? this._codeAddress : this.to
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Ok (message.ts).

fee: number;
dynamic: boolean;
isAsync: boolean;
}
Copy link
Member

Choose a reason for hiding this comment

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

Nice. 😄

@@ -192,5 +200,5 @@ module.exports = function (op, full, freeLogs) {
}
}

return {name: opcode, opcode: op, fee: fee, dynamic: code[2], async: code[3]}
return { name: opcode, opcode: op, fee: fee, dynamic: code[2], isAsync: code[3] }
}
Copy link
Member

Choose a reason for hiding this comment

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

Ok (opcodes.ts).

exception: 0, // 0 means VM fail (in this case because of OOG)
exceptionError: ERROR.OUT_OF_GAS
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Really really nice to have these new precompile interfaces and to have this more systematically structured and wrapped like this.

return: data,
exception: 1
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Ok.

return: R.toArrayLike(Buffer, 'be', mLen.toNumber()),
exception: 1
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Ok.

return: returnData,
exception: 1
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Ok.

return: returnData,
exception: 1
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Ok.

return: returnData,
exception: 1
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Ok.

@s1na s1na merged commit e66ae9d into v4 Apr 21, 2019
@s1na s1na mentioned this pull request Apr 21, 2019
23 tasks
@axic axic deleted the typescript branch May 15, 2019 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants