Skip to content

Commit

Permalink
Merge branch 'master' into elmattic/drop-v1-proof-support
Browse files Browse the repository at this point in the history
  • Loading branch information
elmattic authored Sep 20, 2023
2 parents 7bb7743 + 6b2c94f commit aba20db
Show file tree
Hide file tree
Showing 7 changed files with 237 additions and 46 deletions.
2 changes: 1 addition & 1 deletion actors/account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@ impl ActorCode for Actor {
Constructor => constructor,
PubkeyAddress => pubkey_address,
AuthenticateMessageExported => authenticate_message,
_ => fallback [raw],
_ => fallback,
}
}
2 changes: 1 addition & 1 deletion actors/ethaccount/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ impl ActorCode for EthAccountActor {

actor_dispatch! {
Constructor => constructor,
_ => fallback [raw],
_ => fallback,
}
}
22 changes: 15 additions & 7 deletions actors/evm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use fil_actors_evm_shared::address::EthAddress;
use fil_actors_runtime::{
actor_dispatch_unrestricted, actor_error, ActorError, AsActorError, EAM_ACTOR_ADDR,
actor_dispatch_unrestricted, actor_error, ActorError, AsActorError, WithCodec, EAM_ACTOR_ADDR,
INIT_ACTOR_ADDR,
};
use fvm_ipld_blockstore::Blockstore;
use fvm_ipld_encoding::ipld_block::IpldBlock;
use fvm_ipld_encoding::BytesSer;
use fvm_ipld_encoding::{BytesSer, DAG_CBOR};
use fvm_shared::address::Address;
use fvm_shared::econ::TokenAmount;
use fvm_shared::error::ExitCode;
Expand Down Expand Up @@ -206,14 +206,20 @@ impl EvmContractActor {
initialize_evm_contract(&mut System::resurrect(rt)?, params.creator, params.initcode.into())
}

/// Invoke the contract with some _alternative_ bytecode. This can only be called by the
/// contract itself and is used to implement the EVM's DELEGATECALL opcode.
///
/// This method expects DAG_CBOR encoded parameters (the linked `params.code` needs to be
/// reachable).
pub fn invoke_contract_delegate<RT>(
rt: &RT,
params: DelegateCallParams,
params: WithCodec<DelegateCallParams, DAG_CBOR>,
) -> Result<DelegateCallReturn, ActorError>
where
RT: Runtime,
RT::Blockstore: Clone,
{
let params = params.0;
rt.validate_immediate_caller_is(&[rt.message().receiver()])?;

let mut system = System::load(rt).map_err(|e| {
Expand Down Expand Up @@ -281,15 +287,17 @@ impl EvmContractActor {

/// Returns the contract's EVM bytecode, or `None` if the contract has been deleted (has called
/// SELFDESTRUCT).
pub fn bytecode(rt: &impl Runtime) -> Result<BytecodeReturn, ActorError> {
///
/// Return value is "dag cbor" as we need the linked bytecode (if present) to be reachable.
pub fn bytecode(rt: &impl Runtime) -> Result<WithCodec<BytecodeReturn, DAG_CBOR>, ActorError> {
// Any caller can fetch the bytecode of a contract; this is now EXT* opcodes work.
rt.validate_immediate_caller_accept_any()?;

let state: State = rt.state()?;
if is_dead(rt, &state) {
Ok(BytecodeReturn { code: None })
Ok(BytecodeReturn { code: None }.into())
} else {
Ok(BytecodeReturn { code: Some(state.bytecode) })
Ok(BytecodeReturn { code: Some(state.bytecode) }.into())
}
}

Expand Down Expand Up @@ -417,6 +425,6 @@ impl ActorCode for EvmContractActor {
GetStorageAt => storage_at,
InvokeContractDelegate => invoke_contract_delegate,
Resurrect => resurrect,
_ => handle_filecoin_method [raw],
_ => handle_filecoin_method,
}
}
6 changes: 4 additions & 2 deletions actors/miner/src/expiration_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ impl<'db, BS: Blockstore> ExpirationQueue<'db, BS> {
let groups = self.find_sectors_by_expiration(sector_size, sectors)?;

// Group sectors by their target expiration, then remove from existing queue entries according to those groups.
let new_quantized_expiration = self.quant.quantize_up(new_expiration);
for mut group in groups {
if group.sector_epoch_set.epoch <= self.quant.quantize_up(new_expiration) {
if group.sector_epoch_set.epoch <= new_quantized_expiration {
// Don't reschedule sectors that are already due to expire on-time before the fault-driven expiration,
// but do represent their power as now faulty.
// Their pledge remains as "on-time".
Expand Down Expand Up @@ -297,10 +298,11 @@ impl<'db, BS: Blockstore> ExpirationQueue<'db, BS> {

let mut mutated_expiration_sets = Vec::<(ChainEpoch, ExpirationSet)>::new();

let quantized_fault_expiration = self.quant.quantize_up(fault_expiration);
self.amt.for_each(|e, expiration_set| {
let epoch: ChainEpoch = e.try_into()?;

if epoch <= self.quant.quantize_up(fault_expiration) {
if epoch <= quantized_fault_expiration {
let mut expiration_set = expiration_set.clone();

// Regardless of whether the sectors were expiring on-time or early, all the power is now faulty.
Expand Down
2 changes: 1 addition & 1 deletion actors/multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,6 @@ impl ActorCode for Actor {
ChangeNumApprovalsThreshold => change_num_approvals_threshold,
LockBalance => lock_balance,
UniversalReceiverHook => universal_receiver_hook,
_ => fallback [raw],
_ => fallback,
}
}
Loading

0 comments on commit aba20db

Please sign in to comment.