WebAssembly / WebAssembly/WASI

Blockchain call extension

Open
#56 23 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P-blockchain S-inactive
Dominant language
Rust
Stars
5.8k
Forks
333
Avg merge
2d 13h
Merged PRs (30d)
3

Description

Most blockchain functions map well to WASI except for call/transact, which is an RPC augmented with the ability to transfer the platform's native token (e.g., Eth) from the caller to the callee. It's possible to do this out-of band, but not efficiently: it'd require making two transactions, passing around receipts, and handling rollbacks/refunds.

As long as we're going the WASI module route, it might be worth adding a single function to the "blockchain" module to support Ethereum-like blockchains:

__wasi_blockchain_transact(
	callee_addr: *const u8,
	value: u64,
	input: *const u8,
	input_len: u64,
	fd: *mut __wasi_fd_t
) -> __wasi_errno_t;
  • callee_addr is a fixed-length byte sequence with length known by the platform. For instance, Ethereum addresses are 20 bytes long.
  • value is the amount of native token to transfer from the calling account to the callee
  • input/input_len - a C slice containing the input to the transaction. input_len = 0 for simple balance transfer.
  • fd - a capability to read the output of the transaction

The errno result would be

  • success: ESUCCESS
  • no account at callee address: EADDRNOTAVAIL
  • insufficient funds for value transfer: ENOBAL (this one would have to be assigned a number
  • anything else: application specific
  • (running out of computation resources, or gas, is unrecoverable and results in the process aborting)

Upon ESUCCESS, fd would be of type SOCKET_STREAM and have read-only pipe
semantics.

This proposal would support most existing smart contract platforms including those with a synchronous RPC model (e.g. Ethereum, EOS) and those with asynchronous cross-shard RPCs (e.g, Near).

Note: left out of this call function, but perhaps desirable, is the amount of gas allocated to the sub-transaction. The alternative is to simply give the callee the full amount of remaining gas. One would presumably not call untrusted code, so there should be no need to limit gas for security reasons.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named. Start by reading the linked WASI RFC pull request and the proposed transaction signature, then determine whether the blockchain module and errno/FD semantics are accepted. Done would be an agreed, implementable interface with resolved gas and platform-behavior questions.

Written by the indexing model from the issue text.

Assessment

Tech stack
blockchain, rust, wasm
Domain
blockchain
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.