Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Add ABI version #5

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

jochem-brouwer
Copy link

@jochem-brouwer jochem-brouwer commented Aug 4, 2023

This PR checks if the user input matches the ABI of get(uint256)

src/main.etk Show resolved Hide resolved
src/main.etk Outdated Show resolved Hide resolved
%macro get_input()
%push0()
calldataload
push1 4 # [4]
Copy link
Owner

Choose a reason for hiding this comment

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

oh this is 4 words, you'll actually need to load 1 word and mask out the upper 4 bytes. you can see how to do that here: https://github.com/lightclient/erc20/blob/7b0d75d60f4e746c697a9ff88c62da411ac3f3b5/src/jump_table.etk#L20-L23

Copy link
Author

Choose a reason for hiding this comment

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

Calldataload puts 32 bytes from calldata on stack, and item on stack is the offset?

Copy link
Author

Choose a reason for hiding this comment

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

This does not load function selector but it loads the timestamp input from calldata BTW

Copy link
Contributor

Choose a reason for hiding this comment

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

oh this is 4 words

Nope, the calldataload offset is a byte-offset, not word-offset

func opCallDataLoad(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
	x := scope.Stack.peek()
	if offset, overflow := x.Uint64WithOverflow(); !overflow {
		data := getData(scope.Contract.Input, offset, 32)
		x.SetBytes(data)

So it's correct

Copy link
Owner

Choose a reason for hiding this comment

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

ah you're right i got confused with how i was mloading the data in the other project!

src/main.etk Outdated Show resolved Hide resolved
@jochem-brouwer
Copy link
Author

Also merged master

@jochem-brouwer jochem-brouwer marked this pull request as ready for review August 4, 2023 16:58
Repository owner deleted a comment from tobarbaro Feb 10, 2024
Repository owner deleted a comment from tobarbaro Feb 10, 2024
Repository owner deleted a comment from aatharvauti Feb 21, 2024
Repository owner deleted a comment Mar 1, 2024
Repository owner deleted a comment from jalamari2018 Mar 19, 2024
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.

3 participants