General purpose instructions for bytes #49

Open
opened 2021-07-05 16:46:55 +00:00 by kwannoel · 0 comments
kwannoel commented 2021-07-05 16:46:55 +00:00 (Migrated from github.com)

Part of https://gitlab.com/mukn/glow/-/issues/80.

Features

Batch 1 (Merged: https://github.com/fare/gerbil-ethereum/pull/46)

  • Methods for known-size bytes
    • Compat with bytes larger than EVM Word
    • Store at free memory pointer
    • Load at free memory pointer
    • Push for large bytes
  • Unit tests
  • Integration tests
  • Invariant assertions

Batch 2 (WIP: https://github.com/fare/gerbil-ethereum/pull/50)

  • Call by reference methods (by storing offset, length on stack)
  • Static offset methods for load, store. Glow compiler uses mstoreat, mloadat.
  • Support types with have variable sizes during runtime.
    For example, given a Bytestring with a UInt64 length,
    during compile time we do not know the actual length / contents of the bytestring.
    instead we generate instructions to store the length:
    - on stack is just takes up a slot.
    - in memory it takes up 8bytes.
    And use it to decode the contents:
    - LOAD:
    Use the offset and length on stack to retrieve the entire bytestring from memory
    - STORE:
    Use length on stack to store bytestring in memory
  • memcpy
  • Hashing
  • calldataload, calldatacopy.
  • Limit memory offset to 16/24 bytes due to gas limits, rather than 32.

Batch 3

  • Integrate with existing EVM-Types - Extend? Create new types?
    • Either use .box? directly to handle boxed / unboxed types
    • or use it implicitly, with a general .evm<- method for marshalling data to EVM.

Batch 4

  • Handle singletons.
  • Benchmark gas for methods
  • Support for marshalling? (further investigation needed)
Part of https://gitlab.com/mukn/glow/-/issues/80. ## Features ### Batch 1 (Merged: https://github.com/fare/gerbil-ethereum/pull/46) - [x] Methods for known-size bytes - [x] Compat with bytes larger than EVM Word - [x] Store at free memory pointer - [x] Load at free memory pointer - [x] Push for large bytes - [x] Unit tests - [x] Integration tests - [x] Invariant assertions ### Batch 2 (WIP: https://github.com/fare/gerbil-ethereum/pull/50) - [ ] Call by reference methods (by storing offset, length on stack) - [ ] Static offset methods for load, store. Glow compiler uses `mstoreat`, `mloadat`. - [ ] Support types with have variable sizes during runtime. For example, given a `Bytestring` with a `UInt64` length, during compile time we do not know the actual length / contents of the bytestring. instead we generate instructions to store the length: - on stack is just takes up a slot. - in memory it takes up 8bytes. And use it to decode the contents: - LOAD: Use the offset and length on stack to retrieve the entire bytestring from memory - STORE: Use length on stack to store bytestring in memory - [ ] memcpy - [ ] Hashing - [ ] calldataload, calldatacopy. - [ ] Limit memory offset to 16/24 bytes due to gas limits, rather than 32. ### Batch 3 - [ ] Integrate with existing EVM-Types - Extend? Create new types? - [ ] Either use .box? directly to handle boxed / unboxed types - [ ] or use it implicitly, with a general `.evm<-` method for marshalling data to EVM. ### Batch 4 - [ ] Handle singletons. - [ ] Benchmark gas for methods - [ ] Support for marshalling? (further investigation needed)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mighty-gerbils/gerbil-ethereum#49
No description provided.