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
-
Depends on:
Abstract
Motivation
Currently, the FVM exposes all system information through syscalls
organized into 11 "modules":
debug
ipld
crypto
self
vm
actor
event
send
rand
network
gas
However:
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
private
module.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::enabled
global variable, regardless of the version.debug
syscall when debugging is not enabled traps (aborts).Syscall Changes
debug::enabled
debug::*
ipld::*
ipld1::*
crypto::hash
crypto1::hash
crypto::recover_secp_public_key
crypto1::recover_secp_public_key
crypto::verify_bls_aggregate
crypto1::verify_bls_aggregate
self::root
fvm_actor1::get_state_root
self::set_root
fvm_actor1::set_state_root
vm::exit
fvm_actor1::exit
self::current_balance
fvm_actor1::current_balance
self::self_destruct
fvm_actor1::self_destruct
actor::resolve_address
fvm_actor1::resolve_address
actor::lookup_delegated_address
fvm_actor1::lookup_delegated_address
actor::get_actor_code_cid
fvm_actor1::get_actor_code_cid
actor::balance_of
fvm_actor1::balance_of
event::emit_event
fvm_actor1::emit_event
send::send
fvm_actor1::send
rand::get_chain_randomness
fvm_chain1::get_chain_randomness
rand::get_beacon_randomness
fvm_chain1::get_beacon_randomness
network::tipset_cid
fvm_chain1::tipset_cid
actor::next_actor_address
private::next_actor_address
actor::create_actor
private::create_actor
actor::get_builtin_actor_type
private::get_builtin_actor_type
actor::get_code_cid_for_type
private::get_code_cid_for_type
gas::charge
private::charge_gas
crypto::verify_post
private::verify_post
crypto::verify_consensus_fault
private::verify_consensus_fault
crypto::verify_aggregate_seals
private::verify_aggregate_seals
crypto::verify_replica_update
private::verify_replica_update
crypto::batch_verify_seals
private::batch_verify_seals
network::total_circ_supply
gas::available
vm::message_context
network::context
New 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:
fvm1
tofvm2
.fvm1
tofvm2
.fvm1
. I.e.ld(actor_wasm_module_imports_fvm1, shim_wasm_module) -> new_actor_wasm_module_imports_fvm2
This 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