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

wip: vm opcodes: Implement RETURNDATASIZE and RETURNDATACOPY #15

Open
wants to merge 1 commit into
base: vm-opcodes
Choose a base branch
from

Conversation

whilei
Copy link
Owner

@whilei whilei commented Aug 21, 2018

This change is Reviewable

Copy link
Collaborator

@tzdybal tzdybal left a comment

Choose a reason for hiding this comment

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

Reviewed 10 of 10 files at r1.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @whilei)


core/vm/instructions.go, line 307 at r1 (raw file):

	)

	end := new(big.Int).Add(cOff, l)

Lol, looks like add(cOff, 1) (add one) not add(cOff, l) (add lowercase L). Rename l to len or something.


core/vm/instructions.go, line 308 at r1 (raw file):

	end := new(big.Int).Add(cOff, l)
	if end.BitLen() > 64 || uint64(len(env.ReturnData())) < end.Uint64() {

Actually, if 2^32 <= end <= 2^64, we're doing unnecessary work ;) (as len returns int). This is not a big issue.
Another thing - I would use end.IsUint64() for clarity.


core/vm/jump_table.go, line 26 at r1 (raw file):

	writes bool
	// returns determines whether the operation sets the return data
	returns bool

Same as with writes in previous review - I would create a function IsReturning(op OpCode) bool, and list the 5 opcodes there, instead of adding this to jumpPtr.


core/vm/runtime/env.go, line 44 at r1 (raw file):

	getHashFn func(uint64) common.Hash

	readOnly   bool   // Whether to throw on stateful modifications

readOnly and returnData is repeated in 3 "Env" structs. This doesn't look good.nnn

Copy link
Owner Author

@whilei whilei left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @whilei)


core/vm/instructions.go, line 307 at r1 (raw file):

Previously, tzdybal (Tomasz Zdybał) wrote…

Lol, looks like add(cOff, 1) (add one) not add(cOff, l) (add lowercase L). Rename l to len or something.

Doing.


core/vm/instructions.go, line 308 at r1 (raw file):

Previously, tzdybal (Tomasz Zdybał) wrote…

Actually, if 2^32 <= end <= 2^64, we're doing unnecessary work ;) (as len returns int). This is not a big issue.
Another thing - I would use end.IsUint64() for clarity.

Roger, doing the IsUint64


core/vm/jump_table.go, line 26 at r1 (raw file):

Previously, tzdybal (Tomasz Zdybał) wrote…

Same as with writes in previous review - I would create a function IsReturning(op OpCode) bool, and list the 5 opcodes there, instead of adding this to jumpPtr.

Doing.

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.

2 participants