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

Implement NTCALL opcodes for NTs #74

Open
2 tasks
PaulRBerg opened this issue Apr 15, 2024 · 3 comments
Open
2 tasks

Implement NTCALL opcodes for NTs #74

PaulRBerg opened this issue Apr 15, 2024 · 3 comments
Assignees
Labels
effort: epic Multi-stage task that may require multiple PRs. priority: 0 Do this first before everything else. This is critical and nothing works without this. type: feature New feature or request. work: chaotic Act-sense-respond. No clear relationship between cause and effect. work: complex Probe-sense-respond. The relationship between cause and effect can only be perceived in retrospect.
Milestone

Comments

@PaulRBerg
Copy link
Member

PaulRBerg commented Apr 15, 2024

Tasks

  • Implement the NTCALL, NTCALLVALUE, and NTDELEGATECALL opcodes to take a variable number of token IDs and token amounts instead of a single ETH amount.
  • Refactor the existing CALL, CALLCODE, CALLVALUE, and DELEGATECALL opcodes to act as "stand-ins" to the new opcodes. Each existing opcode would fall back to its newer counterpart by passing a pair of (BASE_TOKEN_ID,value).

Spec

The proposed spec for NTCALL (analogous logic applies to the other opcodes) expects the token IDs and values to be put on the stack:

  • Delete the value input at position 3 (alternatively, turn this value into a no-op; more research required)
  • Add a new value called tokensLength, which signifies the number of token transfers
  • If tokensLength == 0, do nothing; this call does not transfer any tokens
  • Add tokensLength pairs of (token_id,value) pairs

Notes

  • Since the stack can support only up to 1024 elements, a limited number of tokens can be transferred (but this should be high enough for all practical use cases)
  • In practice, we should set the upper limit for tokensLength to something like 512 to make it difficult for the callee to run afoul of the stack limit
  • See this StackExchange post

References

@PaulRBerg PaulRBerg added effort: epic Multi-stage task that may require multiple PRs. work: complex Probe-sense-respond. The relationship between cause and effect can only be perceived in retrospect. priority: 0 Do this first before everything else. This is critical and nothing works without this. type: feature New feature or request. work: chaotic Act-sense-respond. No clear relationship between cause and effect. labels Apr 15, 2024
@PaulRBerg PaulRBerg added this to the Genesis milestone Apr 15, 2024
@IaroslavMazur IaroslavMazur self-assigned this Apr 16, 2024
@IaroslavMazur
Copy link
Member

IaroslavMazur commented Apr 16, 2024

Thanks for the Spec, @PaulRBerg!


Delete the value input at position 3 (alternatively, turn this value into a no-op; more research required)

I don't see why we'd have the value opcode argument alongside the new, MNA-specific ones. Especially given that we're talking about the completely new opcodes that won't need to try to be backwards-compatible.

@PaulRBerg
Copy link
Member Author

PaulRBerg commented Apr 16, 2024

You're right. It should be fine to remove the value input.

@PaulRBerg PaulRBerg changed the title Implement CALL2 opcodes for MNAs Implement CALL2 opcodes for MNTs May 15, 2024
This was referenced May 24, 2024
@PaulRBerg PaulRBerg changed the title Implement CALL2 opcodes for MNTs Implement NTCALL opcodes for NTs May 28, 2024
@PaulRBerg
Copy link
Member Author

While working on Native Tokens, we have come to realize that implementing these opcodes will be challenging. Precompiles weren't designed to manipulate the state of the EVM, and this poses problems like this.

Moving this task from Genesis to Odyssey.

@PaulRBerg PaulRBerg modified the milestones: Genesis, Odyssey May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: epic Multi-stage task that may require multiple PRs. priority: 0 Do this first before everything else. This is critical and nothing works without this. type: feature New feature or request. work: chaotic Act-sense-respond. No clear relationship between cause and effect. work: complex Probe-sense-respond. The relationship between cause and effect can only be perceived in retrospect.
Projects
None yet
Development

No branches or pull requests

2 participants