ref-fvm
ref-fvm copied to clipboard
Add a syscall to obtain the originator of a call
The msg_caller syscall returns the immediate caller, i.e. the actor that called the current actor. This is all that built-in actors have needed up until now.
However, it's useful for expose the originator of the call (i.e. the account actor whose transaction initiated the call stack) for many use cases, e.g. escrow, loans, DeFi-like cases, staking, pledging, etc.
As a sidenote: Ethereum has two distinct opcodes for this: CALLER and ORIGIN, so at minimum we will need this capability for EVM compatibility.
NOTE: We'll likely need a case where the origin is "system".
hi~ is this ok for the issue?
btw, is a ActorID(0) enough for the origin "system", or we should define it separately like
pub enum Originator {
System,
Actor(ActorID),
}
I think this is safer and more efficient than an exporting a static constant for the system address, and assuming than the user will perform a comparison.
then there would be a
pub strcut Originator {
pub is_system: bool,
pub actor_id: u64,
}
or something like that in the fvm_shared::sys ?
I think ActorId(0) is actually sufficient. That's the "from" address we're using for implicit calls.