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

Test gas usage of hostios that don't have good EVM equivalents #2767

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

diegoximenes
Copy link
Contributor

@diegoximenes diegoximenes commented Nov 4, 2024

Resolves NIT-2829

Test gas usage of hostios that don't have good EVM equivalents

@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Nov 4, 2024
@diegoximenes diegoximenes marked this pull request as ready for review November 4, 2024 19:24
gligneul
gligneul previously approved these changes Nov 6, 2024
Copy link
Contributor

@gligneul gligneul left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@tsahee tsahee left a comment

Choose a reason for hiding this comment

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

let's have it with multiple values

system_tests/program_gas_test.go Outdated Show resolved Hide resolved
Comment on lines 44 to 48
funcName := matchSnake.ReplaceAllStringFunc(tc.hostio, func(s string) string {
return strings.ToUpper(strings.TrimPrefix(s, "_"))
})
signature := fmt.Sprintf("%v()", funcName)
data := crypto.Keccak256([]byte(signature))[:4]
Copy link
Contributor

Choose a reason for hiding this comment

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

You could create an interface in the solidity mocks to facilitate the generation of the call args.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to avoid doing that 😬.
Ideally we could use an ABI that is generated directly from the rust smart contract, but we don't have a setup for this yet, so I decided to build calldata in a more low level approach since tests are simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants