ithacaxyz / odyssey

A testnet open-source Layer 2 from the future, co-designed with the developer tools stack.
https://www.ithaca.xyz/updates/odyssey
Apache License 2.0
209 stars 52 forks source link

Integrate r55 #81

Open gakonst opened 3 weeks ago

gakonst commented 3 weeks ago

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 commented 3 weeks ago

@gakonst imo it can be done after

0xurb commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

Hi I would love to take on this

0xurb commented 3 weeks ago

I finish, trying to deploy ERC-20

gakonst commented 3 weeks ago

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 commented 3 weeks ago

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.