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

std::evm functions should take buffer types #891 (Part 1) #895

Merged
merged 14 commits into from
Jul 3, 2023

Conversation

saifalkatout
Copy link
Collaborator

What was wrong?

A number of functions defined in std::evm take offsets and lengths for regions of memory and calldata. These should take buffer types instead.
How was it fixed?

updated revert_mem, return_mem, ext_code_copy, keccak256_mem, create, create2, call, and log

To-Do

-Finish the rest of the functions in part 2

@saifalkatout saifalkatout changed the title std::evm functions should take buffer types #891 (Part 1) #893 std::evm functions should take buffer types #891 (Part 1) Jun 11, 2023
Copy link
Member

@g-r-a-n-t g-r-a-n-t left a comment

Choose a reason for hiding this comment

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

just a couple things, but I think it is good otherwise

output_offset: buf.offset(),
output_len: buf.output_len()
) == 1
buffer:buf
Copy link
Member

Choose a reason for hiding this comment

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

I think still think we should change all buffer identifiers to buf, it looks nice and conventional imo.

this can simply be written as buf instead of buffer: buf

Copy link
Member

Choose a reason for hiding this comment

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

@saifalkatout do you feel that the identifier should be buffer instead of buf?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, I think buffer is better since it will be written more neatly, I guess this is an outdated version ?

Copy link
Member

Choose a reason for hiding this comment

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

yes, the specific code line we are commenting on is outdated. I see that all identifiers have been changed to buffer

if we change all of the parameter names to buf, then we can use buf everywhere, so we wont have to write buffer: buf or buf: buffer anywhere. it can all just be buf

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess stick with buffer on everything because it is more easily understood, my only reservation would be that it can be also easily understood using buf. So the extra characters would be meaningless.

Copy link
Member

Choose a reason for hiding this comment

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

buf is the conventional name for buffer instances and I think we should stick with that

a couple examples:
rust: https://docs.rs/bytes/latest/bytes/buf/trait.Buf.html
java: https://docs.oracle.com/javase/8/docs/api/java/nio/Buffer.html

crates/library/std/src/evm.fe Outdated Show resolved Hide resolved
@saifalkatout
Copy link
Collaborator Author

Sure thing, are we going to incrementally change it ?? so whenever we do sth in a function that has buffer arg. Or do we just do all of them later and in a separate PR for the whole std library ?

@g-r-a-n-t
Copy link
Member

Sure thing, are we going to incrementally change it ?? so whenever we do sth in a function that has buffer arg. Or do we just do all of them later and in a separate PR for the whole std library ?

there were no buffer identifiers in master. we can just change all occurrences of buffer to buf in this PR

@g-r-a-n-t
Copy link
Member

oh, wait. are you getting a naming error? something like buf already exists? sorry didnt consider this

@g-r-a-n-t
Copy link
Member

oh, wait. are you getting a naming error? something like buf already exists? sorry didnt consider this

this is something Yoshi will have fixed in hist v2 branch. for the time being we can just import the buffer by themselves

use ingot::buf::{MemoryBuffer, RawCallBuffer} should work

Snap files for changes on PR ethereum#891
@saifalkatout
Copy link
Collaborator Author

Snap files added, I still need to do the use ingot::buf::{MemoryBuffer, RawCallBuffer}

used the curly bracket import, changed the name of the argument to buf
@saifalkatout
Copy link
Collaborator Author

Changed the argument name to buf.

@g-r-a-n-t g-r-a-n-t self-requested a review June 18, 2023 03:22
Copy link
Member

@g-r-a-n-t g-r-a-n-t left a comment

Choose a reason for hiding this comment

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

nice work 👍

}

pub unsafe fn log1(offset p: u256, len s: u256, topic1 t1: u256) {
return __log1(p, s, t1)
pub fn log1(buf: MemoryBuffer, topic1 t1: u256) {
Copy link
Member

Choose a reason for hiding this comment

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

nice use of labels on these

@g-r-a-n-t g-r-a-n-t self-requested a review June 18, 2023 03:23
@g-r-a-n-t g-r-a-n-t merged commit f115178 into ethereum:master Jul 3, 2023
7 checks passed
saifalkatout added a commit to saifalkatout/fe that referenced this pull request Jul 5, 2023
Merge pull request ethereum#895 from saifalkatout/master
saifalkatout pushed a commit to saifalkatout/fe that referenced this pull request Sep 28, 2023
saifalkatout pushed a commit to saifalkatout/fe that referenced this pull request Sep 28, 2023
saifalkatout pushed a commit to saifalkatout/fe that referenced this pull request Sep 28, 2023
saifalkatout pushed a commit to saifalkatout/fe that referenced this pull request Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants