Syscall Refactor #845
Stebalien
started this conversation in
Filecoin Virtual Machine
Replies: 1 comment
-
|
Revisiting these layers, I've changed my mind on a few things:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Depends on:
Abstract
Motivation
Currently, the FVM exposes all system information through syscalls
organized into 11 "modules":
debugipldcryptoselfvmactoreventsendrandnetworkgasHowever:
Syscall Changes
I'm proposing that we refactor these syscalls into the following 6 public modules:
debug– debugging syscallsipld1– ipld block syscalls, kept as a separate module to be shared with the IPVM (versioned)crypto1– general-purpose module for cryptographic functions (versioned)fvm1– universal FVM features/syscalls.fvm_actor1– functions related to the FVM's actor model (versioned)fvm_chain1– functions related to the chain state (versioned)And a single
privatemodule.Versions
I'm currently proposing that we version entire "namespaces". Alternatively, we could let actors export some kind of runtime version constant and use that to decide the environment.
Debug
The debug syscalls are not versioned. Instead, the idea is to:
debug::enabledglobal variable, regardless of the version.debugsyscall when debugging is not enabled traps (aborts).Syscall Changes
debug::enableddebug::*ipld::*ipld1::*crypto::hashcrypto1::hashcrypto::recover_secp_public_keycrypto1::recover_secp_public_keycrypto::verify_bls_aggregatecrypto1::verify_bls_aggregateself::rootfvm_actor1::get_state_rootself::set_rootfvm_actor1::set_state_rootvm::exitfvm_actor1::exitself::current_balancefvm_actor1::current_balanceself::self_destructfvm_actor1::self_destructactor::resolve_addressfvm_actor1::resolve_addressactor::lookup_delegated_addressfvm_actor1::lookup_delegated_addressactor::get_actor_code_cidfvm_actor1::get_actor_code_cidactor::balance_offvm_actor1::balance_ofevent::emit_eventfvm_actor1::emit_eventsend::sendfvm_actor1::sendrand::get_chain_randomnessfvm_chain1::get_chain_randomnessrand::get_beacon_randomnessfvm_chain1::get_beacon_randomnessnetwork::tipset_cidfvm_chain1::tipset_cidactor::next_actor_addressprivate::next_actor_addressactor::create_actorprivate::create_actoractor::get_builtin_actor_typeprivate::get_builtin_actor_typeactor::get_code_cid_for_typeprivate::get_code_cid_for_typegas::chargeprivate::charge_gascrypto::verify_postprivate::verify_postcrypto::verify_consensus_faultprivate::verify_consensus_faultcrypto::verify_aggregate_sealsprivate::verify_aggregate_sealscrypto::verify_replica_updateprivate::verify_replica_updatecrypto::batch_verify_sealsprivate::batch_verify_sealsnetwork::total_circ_supplygas::availablevm::message_contextnetwork::contextNew Globals
All globals are constants, except
fvm1::gas_available. However, user code is not allowed to modifyfvm1::gas_available.fvm1::gas_available(u64)fvm_chain1::epoch(u64)fvm_chain1::timestamp(u64)fvm_chain1::base_fee(u64)fvm_chain1::chain_id(u64)fvm_chain1::network_version(u64)fvm_chain1::message_origin(u64)fvm_chain1::message_nonce(u64)fvm_chain1::gas_premium(u64)fvm_actor1::caller(u64)fvm_actor1::self(u64)fvm_actor1::value_received_lo(u64)fvm_actor1::value_received_hi(u64)fvm_actor1::flags(u64)If the actor imports
fvm1::gas_available, we will validate that the import is immutable. Then, we will make it mutable so we can use it for gas instrumentation. This means the initial validation (before gas instrumentation) will statically reject any mutations to this global variable from user-provided code.At the moment, accessing wasm globals is difficult from most languages. However, we can provide tiny wasm "shims" that can be linked (with ldd) to actors before deployment that export small functions for reading these globals. E.g.:
NOTE: This assumes that the method number is passed via the wasm entrypoint as described in #792.
Upgrades
When an FVM upgrade introduces breaking changes in some WASM API, we'll:
fvm1tofvm2.fvm1tofvm2.fvm1. I.e.ld(actor_wasm_module_imports_fvm1, shim_wasm_module) -> new_actor_wasm_module_imports_fvm2This means that the FVM can continue to support exactly one API version while maintaining perfect backwards compatibility on-chain.
Beta Was this translation helpful? Give feedback.
All reactions