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

Integrate r55 #81

Open
gakonst opened this issue Nov 7, 2024 · 10 comments · May be fixed by #82
Open

Integrate r55 #81

gakonst opened this issue Nov 7, 2024 · 10 comments · May be fixed by #82
Labels
A-node C-enhancement New feature or request C-external-contribution Opportunity for external contributors to participate in the Odyssey roadmap

Comments

@gakonst
Copy link
Contributor

gakonst commented Nov 7, 2024

r55 lets us write smart contracts in rust: https://github.com/leonardoalt/r55

this would be sick as part of the executor, might be as simple as integrating here: https://github.com/ithacaxyz/odyssey/blob/main/crates/node/src/evm.rs#L231

here's an example integration https://github.com/leonardoalt/r55/blob/main/r55/src/exec.rs#L23-L270

@0xurb
Copy link
Contributor

0xurb commented Nov 7, 2024

@gakonst imo it can be done after

  • revm release with interpreter trait (with ability to integrate custom interp with bytecode type for RISC-V, which starts with 0xFF and etc.)
  • all freq used opcodes implemented as r55 syscalls (I mean, we easily can implement not all bytecodes for first iteration, but it needs to be at least enough for basic contracts)

@0xurb
Copy link
Contributor

0xurb commented Nov 7, 2024

Interpreter must be like:
“setup emulator from elf if the first byte of the bytecode is 0xff”

Don’t see the way to do it without kinda interpreter wiring released on revm, which we depends on here, because e.g.

we got RISC-V bytecode as interpreter input, it parses like legacy, then stripped 2 first bytes and flow goes incorrect, not going to handler

Maybe I’m missed smth

@leonardoalt
Copy link

Btw the "starts with 0xff" thing was a quick convention hack we chose to make it work quickly, but should be improved. Any convention/architecture that makes it easier for revm is welcome

@0xurb
Copy link
Contributor

0xurb commented Nov 7, 2024

Maybe 2 bytes like other formats (such as EOF / EIP-7702)
To easily slice all types of code in equal way

https://github.com/bluealloy/revm/blob/main/crates/bytecode/src/bytecode.rs#L105-L115

prob with opcode 0xEF and some 2-bytes version will be good - https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7702.md#delegation-designation

@gakonst
Copy link
Contributor Author

gakonst commented Nov 7, 2024

revm release with interpreter trait (with ability to integrate custom interp with bytecode type for RISC-V, which starts with 0xFF and etc.)

why not re-use the handler implementation Leo did above, which lets you re-use both EVM and RISCV?

@0xurb
Copy link
Contributor

0xurb commented Nov 7, 2024

revm release with interpreter trait (with ability to integrate custom interp with bytecode type for RISC-V, which starts with 0xFF and etc.)

why not re-use the handler implementation Leo did above, which lets you re-use both EVM and RISCV?

Was aware about how bytecode goes - will it be interp first like legacy
I intrigued and try to code now

@mahmudsudo
Copy link
Contributor

Hi I would love to take on this

@0xurb
Copy link
Contributor

0xurb commented Nov 8, 2024

I finish, trying to deploy ERC-20

@0xurb 0xurb linked a pull request Nov 8, 2024 that will close this issue
@gakonst
Copy link
Contributor Author

gakonst commented Nov 8, 2024

Contract size can get large quite quickly. Find ways to compress/optimize it.

@leonardoalt do we just turn off bytecode size limit for r5 contracts? I guess not. Mb we need to price it better?

@leonardoalt
Copy link

Contract size can get large quite quickly. Find ways to compress/optimize it.

@leonardoalt do we just turn off bytecode size limit for r5 contracts?

Currently yes, here afaik: https://github.com/r55-eth/r55/blob/main/r55/src/exec.rs#L25

Though I suspect the reason why even the basic token contract is large is because we're using software TinyKeccak for Mapping instead of the Keccak syscall which is still unimplemented.

@onbjerg onbjerg added C-enhancement New feature or request A-node labels Nov 26, 2024
@jenpaff jenpaff added the C-external-contribution Opportunity for external contributors to participate in the Odyssey roadmap label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-node C-enhancement New feature or request C-external-contribution Opportunity for external contributors to participate in the Odyssey roadmap
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants