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

feat: implement 0x37 - CALLDATACOPY #99

Closed
Eikix opened this issue Oct 20, 2022 · 1 comment
Closed

feat: implement 0x37 - CALLDATACOPY #99

Eikix opened this issue Oct 20, 2022 · 1 comment
Assignees
Labels
cairo cairo Context: isolated no previous knowledge of the codebase required Type: feature a new feature to implement

Comments

@Eikix
Copy link
Member

Eikix commented Oct 20, 2022

Since

Frontier

Group

Environmental Information

Description

0x37 - CALLDATACOPY

Index 1 is top of the stack. See PUSH.

Notes

For out of bound bytes, 0s will be copied.

Stack input

  1. destOffset: byte offset in the memory where the result will be copied.
  2. offset: byte offset in the calldata to copy.
  3. size: byte size to copy.

Examples

Calldata

0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Reproduce in playground.

Error cases

The state changes done by the current context are reverted in those cases:

  • Not enough gas.
  • Not enough values on the stack.

Gas

minimum_word_size = (size + 31) / 32

static_gas = 3
dynamic_gas = 3 * minimum_word_size + memory_expansion_cost

The memory expansion cost explanation can be found here.

@Eikix Eikix added Context: isolated no previous knowledge of the codebase required Difficulty: intermediate cairo cairo Type: feature a new feature to implement labels Oct 20, 2022
@danilowhk
Copy link
Collaborator

I can do this one

AbdelStark pushed a commit that referenced this issue Oct 28, 2022
<!--- Please provide a general summary of your changes in the title
above -->

## Pull request type

<!-- Please try to limit your pull request to one type, submit multiple
pull requests if needed. -->

Please check the type of change your PR introduces:

- [X] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, renaming)
- [X] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying, or
link to a relevant issue. -->

Issue Number: #99 

## What is the new behavior?

<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Added 5 tests for Calldatacopy
- Fixed bugs
- Refactored slice_data function so it can be used by: calldataload,
returndatacopy, extdatacopy, codecopy

## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
@Eikix Eikix closed this as completed Oct 29, 2022
@matthieuauger matthieuauger added this to the Full OPCODE implementation milestone Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cairo cairo Context: isolated no previous knowledge of the codebase required Type: feature a new feature to implement
Projects
None yet
Development

No branches or pull requests

3 participants