Skip to content

Commit

Permalink
Merge pull request #88 from amazingdatamachine/sander/fix-voting-conf…
Browse files Browse the repository at this point in the history
…licts

Use chain state to determine object finalization
  • Loading branch information
sanderpick authored Jun 10, 2024
2 parents 31674f5 + 06679f6 commit d720e6b
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 139 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions fendermint/actors/objectstore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ version = "0.1.0"
crate-type = ["cdylib", "lib"]

[dependencies]
anyhow = { workspace = true }
cid = { workspace = true, default-features = false }
frc42_dispatch = { workspace = true }
num-derive = { workspace = true }
num-traits = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_tuple = { workspace = true }

fil_actors_runtime = { workspace = true, optional = true, features = [
"fil-actor",
] }
fvm_shared = { workspace = true }
fvm_ipld_encoding = { workspace = true }
fvm_ipld_blockstore = { workspace = true }
fvm_ipld_hamt = { workspace = true }
num-derive = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_tuple = { workspace = true }
num-traits = { workspace = true }
frc42_dispatch = { workspace = true }
anyhow = { workspace = true }

fendermint_actor_machine = { path = "../machine" }
objectstore_actor_sdk = { path = "../../../textile/objectstore_actor_sdk" }

[dev-dependencies]
fil_actors_runtime = { workspace = true, features = [
Expand Down
15 changes: 4 additions & 11 deletions fendermint/actors/objectstore/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ impl Actor {
Ok(())
}

// Deleting an object removes the key from the store, but not from the underlying storage.
// So, we can't just delete it here via syscall.
// Once implemented, the DA mechanism may cause the data to be entangled with other data.
// The retention policies will handle deleting / GC.
fn delete_object(rt: &impl Runtime, params: DeleteParams) -> Result<Cid, ActorError> {
Self::ensure_write_allowed(rt)?;

Expand All @@ -74,17 +78,6 @@ impl Actor {
e.downcast_default(ExitCode::USR_ILLEGAL_STATE, "failed to delete object")
})
})?;

// Clean up external object storage if it existed.
if let Some(Object::External((v, _))) = res.0 {
objectstore_actor_sdk::cid_rm(v.0).map_err(|en| {
ActorError::checked(
ExitCode::USR_ILLEGAL_STATE,
format!("cid_rm syscall failed with {en}"),
None,
)
})?;
}
Ok(res.1)
}

Expand Down
2 changes: 1 addition & 1 deletion fendermint/actors/objectstore/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl State {
}
}
}
// Don't error here in case key was deleted before value was resolved.
// Don't error here in case the key was deleted before the value was resolved.
None => Ok(()),
}
}
Expand Down
27 changes: 24 additions & 3 deletions fendermint/app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,10 @@ where
Genesis = Vec<u8>,
Output = FvmGenesisOutput,
>,
I: ProposalInterpreter<State = ChainEnv, Message = Vec<u8>>,
I: ProposalInterpreter<
State = (ChainEnv, FvmExecState<ReadOnlyBlockstore<SS>>),
Message = Vec<u8>,
>,
I: ExecInterpreter<
State = (ChainEnv, FvmExecState<SS>),
Message = Vec<u8>,
Expand Down Expand Up @@ -641,11 +644,20 @@ where
time = request.time.to_string(),
"prepare proposal"
);
let state = self.committed_state()?;
let exec_state = FvmExecState::new(
ReadOnlyBlockstore::new(self.state_store_clone()),
self.multi_engine.as_ref(),
state.block_height as ChainEpoch,
state.state_params,
)
.context("error creating execution state")?;

let txs = request.txs.into_iter().map(|tx| tx.to_vec()).collect();

let txs = self
.interpreter
.prepare(self.chain_env.clone(), txs)
.prepare((self.chain_env.clone(), exec_state), txs)
.await
.context("failed to prepare proposal")?;

Expand All @@ -665,12 +677,21 @@ where
time = request.time.to_string(),
"process proposal"
);
let state = self.committed_state()?;
let exec_state = FvmExecState::new(
ReadOnlyBlockstore::new(self.state_store_clone()),
self.multi_engine.as_ref(),
state.block_height as ChainEpoch,
state.state_params,
)
.context("error creating execution state")?;

let txs: Vec<_> = request.txs.into_iter().map(|tx| tx.to_vec()).collect();
let num_txs = txs.len();

let accept = self
.interpreter
.process(self.chain_env.clone(), txs)
.process((self.chain_env.clone(), exec_state), txs)
.await
.context("failed to process proposal")?;

Expand Down
Loading

0 comments on commit d720e6b

Please sign in to comment.