evmdoc

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package evmdoc contains internal documentation about EVM support in ISC.

EVM support

The main components of the EVM subsystem are:

  • The EVM emulator, in package emulator
  • The evm core contract interface, in package evm
  • The evm core contract implementation, in package evmimpl
  • The Solidity interface of the ISC magic contract, in package iscmagic
  • The JSONRPC service, in package jsonrpc)

Tests are grouped in the following packages:

Handling Ethereum Transactions

Let's follow the path of an Ethereum transaction.

  • The sender connects their Metamask client to the JSON-RPC.

    Each Wasp node provides a JSONRPC service (see jsonrpc.EthService), available via HTTP and websocket transports. When setting up a chain in Metamask, the user must configure the JSONRPC endpoint (like `<node-api>/chain/<isc-chainid>/evm/jsonrpc`).

  • The sender sends the signed EVM transaction via Metamask.

    Metamask signs the EVM transaction with the sender's Ethereum private key, and then calls the eth_sendRawTransaction JSONRPC endpoint.

  • The method jsonrpc.EthService.SendRawTransaction is invoked.

  • After decoding the transaction and performing several validations, the transaction is sent to the backend for processing, by calling jsonrpc.ChainBackend.EVMSendTransaction.

    The main implementation of the ChainBackend interface is jsonrpc.WaspEVMBackend. So, jsonrpc.WaspEVMBackend.EVMSendTransaction is called.

  • The Ethereum transaction is wrapped into an ISC off-ledger request by calling isc.NewEVMOffLedgerTxRequest, and sent to the mempool for later processing by the ISC chain, by calling chain.ChainRequests.ReceiveOffLedgerRequest.

  • Some time later the ISC request is picked up by the consensus, and consequently processed by the ISC VM. The `evmOffLedgerTxRequest` acts as a regular ISC off-ledger request that calls the evm core contract's evm.FuncSendTransaction entry point with a single parameter:: the serialized Ethereum transaction. (See methods CallTarget and Params of type `isc.evmOffLedgerTxRequest`.)

  • The evm.FuncSendTransaction entry point is handled by the evm core contract's function `applyTransaction` in package evmimpl.

  • The evm core contract calls emulator.EVMEmulator.SendTransaction, which in turn calls [emulator.EVMEmulator.applyMessage], which calls core.ApplyMessage. This actually executes the EVM code.

Gas Estimation

Metamask usually calls eth_estimateGas before eth_sendRawTransaction. This is processed differently:

View Calls

When Metamask calls eth_call to perform a view call, the execution path is similar to the gas estimation case:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL