-
Notifications
You must be signed in to change notification settings - Fork 778
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
Conversation
Phew. 😄 |
Ah, so this is actually ready for review? Misunderstood first. |
Just scrolled through for a first round, think this will be manageable for review. 😀😛 |
There was a problem hiding this 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) | ||
} |
There was a problem hiding this comment.
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 | |||
} | |||
} |
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
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] } | |||
} |
There was a problem hiding this comment.
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 | ||
} | ||
} |
There was a problem hiding this comment.
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 | ||
} | ||
} |
There was a problem hiding this comment.
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 | ||
} | ||
} |
There was a problem hiding this comment.
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 | ||
} | ||
} |
There was a problem hiding this comment.
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 | ||
} | ||
} |
There was a problem hiding this comment.
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 | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
Happy for now with precompiles, but the rest are still subject to change. E.g.
Message
's constructor gets anopts: any
, which doesn't utilize typescript's benefits.I also tried migrating
Interpreter
andLoop
but realized halfway that they need some changes before they can be typed well.(To be merged into #479)