Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

[needs review] 946 feature HeaderWithItsEntry #2006

Open
wants to merge 111 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
98ea160
Add incomplete work on chain-pair, discontinuing for now.
jamesray1 Nov 11, 2019
c5be663
Add more work, still incomplete
jamesray1 Nov 18, 2019
2a2aa67
More work on reworking entry_with_header and EntryWithHeader and depe…
jamesray1 Nov 18, 2019
09f5ece
Fix formatting errors and some logical errors
jamesray1 Nov 19, 2019
57d9ed2
Add work on implementing Display for HeaderEntryMismatch: several err…
jamesray1 Nov 19, 2019
4cf1b56
Don't deref self
jamesray1 Nov 19, 2019
ee46a2d
Add fixes.
jamesray1 Nov 19, 2019
ac42df2
Fix errors, e.g. with handling errors when creating a chain pair
jamesray1 Nov 20, 2019
7ad80a2
Fixes. Merge changes from develop, fix conflicts
jamesray1 Nov 21, 2019
8b25845
track chain_pair.rs, commit
jamesray1 Nov 21, 2019
06f1548
Merge branch 'develop' of https://github.com/holochain/holochain-rust…
jamesray1 Nov 21, 2019
ec2b4c3
Save work
jamesray1 Nov 21, 2019
88cf486
Re-add chain_pair.rs with revisions from upstream, delete entry_with_…
jamesray1 Nov 21, 2019
9ca847d
use try_from_header_and_entry and remove new for ChainPair.
jamesray1 Nov 22, 2019
9dcf231
Fixing errors. Noticed that retry_validations was missing so added ma…
jamesray1 Nov 23, 2019
85c9d84
Fixes, use try_validate_from_entry_and_header to reduce boilerplate
jamesray1 Nov 23, 2019
7948745
Merge from upstream, fixing conflicts
jamesray1 Nov 24, 2019
20c3921
Move try_validate_from_entry_and_header to impl PendingValidationStruct
jamesray1 Nov 24, 2019
3794020
Merge branch 'develop' of https://github.com/holochain/holochain-rust…
jamesray1 Nov 24, 2019
afe3c3f
Manually got hold_entry_remove and mod workflows from upstream develo…
jamesray1 Nov 24, 2019
8d81539
Add hold_entry_update.rs from upstream develop, was removed with othe…
jamesray1 Nov 24, 2019
a9dbf02
Fixed errors, cargo build passing
jamesray1 Nov 25, 2019
05d8366
Merge upstream, fix conflicts
jamesray1 Nov 25, 2019
f7f61ed
Merge branch 'develop' of https://github.com/holochain/holochain-rust…
jamesray1 Nov 25, 2019
1d7baff
Merge branch 'develop' of https://github.com/holochain/holochain-rust…
jamesray1 Nov 25, 2019
a24266b
fmt
jamesray1 Nov 25, 2019
4eb85f5
Merge branch 'develop' of https://github.com/holochain/holochain-rust…
jamesray1 Nov 26, 2019
c708e79
Merge branch 'develop' into 946-feature-chain-pair
jamesray1 Nov 29, 2019
d85e200
Fix error in test
jamesray1 Nov 29, 2019
d3797b7
Try fix the same error
jamesray1 Nov 29, 2019
d5faf71
Try fix another error
jamesray1 Nov 29, 2019
4061e1a
Revert added lines
jamesray1 Nov 29, 2019
254bd73
Revert added line
jamesray1 Nov 29, 2019
30263e2
Fix create_pending_validation
jamesray1 Nov 29, 2019
c9dd37d
Merge branch '946-feature-chain-pair' of https://github.com/jamesray1…
jamesray1 Nov 29, 2019
4bbec8d
Fix un-closed delimiter
jamesray1 Nov 29, 2019
27c52ca
Fix ownership error; clone test_entry
jamesray1 Nov 29, 2019
f6cf084
Merge branch '946-feature-chain-pair' of https://github.com/jamesray1…
jamesray1 Nov 29, 2019
1523189
fmt
jamesray1 Nov 29, 2019
f57cd85
handle error for add_header_for_entry
jamesray1 Nov 30, 2019
e1bc59f
Add match, fix error
jamesray1 Nov 30, 2019
dc226c4
Fix syntax error, add debug for a test that failed in a previous buil…
jamesray1 Nov 30, 2019
e007330
Add ;
jamesray1 Nov 30, 2019
1d80926
fmt
jamesray1 Nov 30, 2019
0f5d1b5
Enable logging, add extra debugging for failing tests
jamesray1 Nov 30, 2019
4fea585
Merge branch 'develop' into 946-feature-chain-pair
jamesray1 Nov 30, 2019
de65add
rm incorrect header.entry()
jamesray1 Nov 30, 2019
a71354d
Merge branch '946-feature-chain-pair' of https://github.com/jamesray1…
jamesray1 Nov 30, 2019
5ef4827
Fix errors
jamesray1 Nov 30, 2019
3994788
Fix error with use of ActionResponse, same now as upstream develop
jamesray1 Nov 30, 2019
abbe652
use test_chain_header_for_sys_entry to try fix broken test
jamesray1 Nov 30, 2019
4e178ce
rm delimiter
jamesray1 Nov 30, 2019
9549635
fix errors
jamesray1 Nov 30, 2019
4e14193
fix error
jamesray1 Nov 30, 2019
0fa1e43
fix error
jamesray1 Nov 30, 2019
7d5aac4
fix error
jamesray1 Nov 30, 2019
32ef6d5
re-add closing delim
jamesray1 Nov 30, 2019
55dca08
Fetch upstream changes
jamesray1 Nov 30, 2019
9e2506f
fm unused imports, don't know and haven't checked why they've become…
jamesray1 Nov 30, 2019
32e40fa
rm braces
jamesray1 Nov 30, 2019
079e5ea
fix import
jamesray1 Nov 30, 2019
4d9a8af
use new test_link_entry and test_chain_header_for_link_entry with try…
jamesray1 Nov 30, 2019
27321d1
import test_chain_header_for_link_entry
jamesray1 Nov 30, 2019
9d91615
fmt
jamesray1 Nov 30, 2019
bc34b0a
fix errors
jamesray1 Nov 30, 2019
72a5770
Merge branch 'develop' into 946-feature-chain-pair
jamesray1 Dec 1, 2019
ba9e668
fixes
jamesray1 Dec 1, 2019
d6ff0ba
Merge branch '946-feature-chain-pair' of https://github.com/jamesray1…
jamesray1 Dec 1, 2019
2c60dfb
fix
jamesray1 Dec 1, 2019
a0b7810
fmt
jamesray1 Dec 1, 2019
8b2b955
Fix clippy error
jamesray1 Dec 1, 2019
bb683d9
Merge branch 'develop' into 946-feature-chain-pair
jamesray1 Dec 2, 2019
f7a8aea
Merge branch 'develop' into 946-feature-chain-pair
jamesray1 Dec 3, 2019
23513ba
use ChainPair in validation_dependencies.rs tests
jamesray1 Dec 3, 2019
1f38296
rename PendingValidationStruct::try_validate_from_entry_and_header to…
jamesray1 Dec 3, 2019
bb6907c
use try_pending_validation_for_entry instead of pending_validation_fo…
jamesray1 Dec 3, 2019
ff8fa8a
impl ValidationDependenies for ChainPair rather than EntryWithHeader
jamesray1 Dec 3, 2019
bf81355
Replace EntryWithHeader with ChainPair in commented out code in store.rs
jamesray1 Dec 3, 2019
5dc06d2
fix errors, rename
jamesray1 Dec 3, 2019
9862b54
more fixes, can't build on laptop, internet still not available
jamesray1 Dec 3, 2019
ac65d97
Merge branch 'develop' into 946-feature-chain-pair
jamesray1 Dec 9, 2019
1a54ee0
Merge branch 'develop' into 946-feature-chain-pair
jamesray1 Dec 12, 2019
c004f00
use ChainPair and chain_pair instead of EntryWithHeader and entry_wit…
jamesray1 Dec 12, 2019
7487a07
Fix errors from tests
jamesray1 Dec 12, 2019
bb77f03
fix more tests
jamesray1 Dec 12, 2019
ce506e9
fix err
jamesray1 Dec 13, 2019
d4bce73
Merge branch 'develop' into 946-feature-chain-pair
jamesray1 Dec 14, 2019
f124765
Fix errors, linking fails locally for compiling holochain_conductor_lib
jamesray1 Dec 14, 2019
7257faf
gitignore .vscode/
jamesray1 Dec 20, 2019
99eb093
Merge branch '946-feature-chain-pair' of https://github.com/jamesray1…
jamesray1 Dec 20, 2019
9e58119
Merge branch 'develop' into 946-feature-chain-pair
jamesray1 Dec 20, 2019
a8259f0
temporarily save unfinished to merge to get out of it
jamesray1 Dec 20, 2019
90f75b7
add convenience functions for testing, fixes
jamesray1 Dec 21, 2019
b3a3659
Merge upstream develop
jamesray1 Dec 21, 2019
724ca2e
fmt, nt passes
jamesray1 Dec 21, 2019
ea7b9c9
fixing clippy errors: redudant clones
jamesray1 Dec 21, 2019
dbfd1b2
rename ChainPair to EntryHeaderPair; chain_pair to entry_header_pair
jamesray1 Dec 21, 2019
cf6d3ec
rename chain_pair.rs
jamesray1 Dec 21, 2019
70f0c5e
cargo fmt in nh
jamesray1 Dec 21, 2019
387a526
a -> an
jamesray1 Dec 21, 2019
82b8cbc
track crates/core/src/network/entry_header_pair.rs; nt, nc, nf all pass
jamesray1 Dec 21, 2019
358f1fe
rename EntryHeaderPair to HeaderWithItsEntry, etc.
jamesray1 Dec 21, 2019
5e57135
actually rename entry_header_pair, EntryHeaderPair to header_with_its…
jamesray1 Dec 21, 2019
9069cab
Merge branch 'develop' into 946-feature-chain-pair
jameschrray Dec 21, 2019
4a7b451
Merge branch 'develop' into 946-feature-chain-pair
jameschrray Dec 22, 2019
c2cf67b
Merge branch 'develop' into 946-feature-chain-pair
jameschrray Dec 22, 2019
f029fac
Merge branch 'develop' into 946-feature-chain-pair
jameschrray Dec 23, 2019
7f96c83
Merge branch 'develop' of https://github.com/holochain/holochain-rust…
jamesray1 Dec 29, 2019
36237f8
Merge branch 'develop' into 946-feature-chain-pair
thedavidmeister Jan 4, 2020
960b28f
return result
jamesray1 Mar 17, 2020
0f6a7c0
Merge branch '946-feature-chain-pair' of https://github.com/jameschrr…
jamesray1 Mar 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ Cargo.lock
!/Cargo.lock

stress-test/passthrough-dna.dna.json

.vscode/
2 changes: 1 addition & 1 deletion crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn run() -> HolochainResult<()> {
return Err(HolochainError::Default(format_err!(
"Failed to parse properties argument as JSON: {:?}",
e
)))
)));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/conductor_lib/src/conductor/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl ConductorAdmin for Conductor {
return Err(HolochainError::ConfigError(format!(
"Invalid storage option: {}",
s
)))
)));
}
};

Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
network::{
direct_message::DirectMessage,
entry_aspect::EntryAspect,
entry_with_header::EntryWithHeader,
header_with_its_entry::HeaderWithItsEntry,
query::{GetLinksNetworkQuery, NetworkQueryResult},
state::NetworkState,
},
Expand Down Expand Up @@ -127,7 +127,7 @@ pub enum Action {
HoldAspect(EntryAspect),

//action for updating crudstatus
CrudStatus((EntryWithHeader, CrudStatus)),
CrudStatus((HeaderWithItsEntry, CrudStatus)),

// ----------------
// Network actions:
Expand Down
10 changes: 5 additions & 5 deletions crates/core/src/agent/state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
action::{Action, ActionWrapper, AgentReduceFn},
agent::chain_store::{ChainStore, ChainStoreIterator},
network::entry_with_header::EntryWithHeader,
network::header_with_its_entry::HeaderWithItsEntry,
state::State,
};
use holochain_persistence_api::cas::content::{Address, AddressableContent, Content};
Expand Down Expand Up @@ -221,13 +221,13 @@ pub fn create_new_chain_header(
))
}

/// Create an entry-with-header for a header.
/// Creates a `HeaderWithItsEntry` for a `ChainHeader`.
/// Since published headers are treated as entries, the header must also
/// have its own header!
pub fn create_entry_with_header_for_header(
pub fn create_header_with_its_entry_for_header(
root_state: &StateWrapper,
chain_header: ChainHeader,
) -> Result<EntryWithHeader, HolochainError> {
) -> Result<HeaderWithItsEntry, HolochainError> {
let timestamp = chain_header.timestamp().clone();
let entry = Entry::ChainHeader(chain_header);
// This header entry needs its own header so we can publish it.
Expand All @@ -251,7 +251,7 @@ pub fn create_entry_with_header_for_header(
&None,
&timestamp,
);
Ok(EntryWithHeader { entry, header })
HeaderWithItsEntry::try_from_header_and_entry(header, entry)
}

/// Do a Commit Action against an agent state.
Expand Down
105 changes: 71 additions & 34 deletions crates/core/src/dht/dht_reducers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
dht_store::DhtStore,
pending_validations::{PendingValidationWithTimeout, ValidationTimeout},
},
error::HolochainError,
};
use std::sync::Arc;

Expand Down Expand Up @@ -81,10 +82,22 @@ pub(crate) fn reduce_hold_aspect(
match aspect {
EntryAspect::Content(entry, header) => {
match reduce_store_entry_inner(&mut new_store, entry) {
Ok(()) => {
new_store.add_header_for_entry(&entry, &header).ok()?;
Some(new_store)
}
Ok(()) => match new_store.add_header_for_entry(&entry, &header) {
Ok(()) => Some(new_store),
Err(err) => {
let err_msg = format!(
"Tried to add the header for entry to the new
store in reduce_hold_aspect, got error. {}",
err
);
debug!(
"{}, entry:\n{:?}\nheader:\n{:?} \nnew_store:\n{:?}",
err_msg, entry, header, new_store
);
error!("{}", err_msg);
None
}
},
Err(e) => {
error!("{}", e);
None
Expand Down Expand Up @@ -191,7 +204,11 @@ pub fn reduce_prune(old_store: &DhtStore, _action_wrapper: &ActionWrapper) -> Op
.unique_by(|p| {
(
p.pending.workflow.clone(),
p.pending.entry_with_header.header.entry_address(),
p.pending
.header_with_its_entry
.header()
.entry_address()
.clone(),
)
})
.cloned()
Expand Down Expand Up @@ -251,15 +268,18 @@ pub mod tests {
pending_validations::{PendingValidation, PendingValidationStruct, ValidatingWorkflow},
},
instance::tests::test_context,
network::entry_with_header::EntryWithHeader,
network::header_with_its_entry::HeaderWithItsEntry,
state::test_store,
};
use bitflags::_core::time::Duration;
use holochain_core_types::{
agent::{test_agent_id, test_agent_id_with_name},
chain_header::test_chain_header,
chain_header::{
test_chain_header, test_chain_header_for_link_entry, test_chain_header_for_sys_entry,
ChainHeader,
},
eav::Attribute,
entry::{test_entry, test_sys_entry, Entry},
entry::{test_entry, test_link_entry, test_sys_entry, Entry},
link::{link_data::LinkData, Link, LinkActionKind},
network::entry_aspect::EntryAspect,
};
Expand All @@ -280,6 +300,7 @@ pub mod tests {

#[test]
fn reduce_hold_aspect_test() {
enable_logging_for_test();
let context = test_context("bob", None);
let store = test_store(context);

Expand All @@ -290,7 +311,7 @@ pub mod tests {
&store.dht(),
&ActionWrapper::new(Action::HoldAspect(EntryAspect::Content(
sys_entry.clone(),
test_chain_header(),
test_chain_header_for_sys_entry(),
))),
)
.expect("there should be a new store for committing a sys entry");
Expand Down Expand Up @@ -541,23 +562,47 @@ pub mod tests {
assert_eq!(&entry, &result_entry,);
}

fn create_pending_validation(entry: Entry, workflow: ValidatingWorkflow) -> PendingValidation {
let entry_with_header = EntryWithHeader {
entry: entry.clone(),
header: test_chain_header(),
};

Arc::new(PendingValidationStruct::new(entry_with_header, workflow))
fn try_create_pending_validation(
entry: Entry,
header: ChainHeader,
workflow: ValidatingWorkflow,
) -> Result<PendingValidation, HolochainError> {
match HeaderWithItsEntry::try_from_header_and_entry(header.clone(), entry.clone()) {
Ok(header_with_its_entry) => Arc::new(PendingValidationStruct::new(
header_with_its_entry,
workflow,
)),
Err(err) => {
let err_msg = format!(
"Tried to create a pending validation, got an error: {}",
err
);
debug!(
"{}, entry:\n{:?}\nheader from test_chain_header():\n{:?}\n",
err_msg, entry, header
);
Err(err_msg)
}
}
}

// Causes a header and entry mismatch when calling try_create_pending_validation()
// -> try_from_header_and_entry().
// Should be since link_entry doesn't match with test chain header
#[test]
pub fn test_holding_queue() {
enable_logging_for_test();
let context = test_context("test", None);
let store = DhtStore::new(context.dht_storage.clone(), context.eav_storage.clone());
assert_eq!(store.queued_holding_workflows().len(), 0);

let test_entry = test_entry();
let hold = create_pending_validation(test_entry.clone(), ValidatingWorkflow::HoldEntry);
let test_header = test_chain_header();
let hold = try_create_pending_validation(
test_entry.clone(),
test_header.clone(),
ValidatingWorkflow::HoldEntry,
);
let action = ActionWrapper::new(Action::QueueHoldingWorkflow((
hold.clone(),
Some((SystemTime::now(), Duration::from_secs(10000))),
Expand All @@ -567,23 +612,11 @@ pub mod tests {
assert_eq!(store.queued_holding_workflows().len(), 1);
assert!(store.has_exact_queued_holding_workflow(&hold));

let test_link = String::from("test_link");
let test_tag = String::from("test-tag");
let link = Link::new(
&test_entry.address(),
&test_entry.address(),
&test_link.clone(),
&test_tag.clone(),
let hold_link = try_create_pending_validation(
test_link_entry(),
test_chain_header_for_link_entry(),
ValidatingWorkflow::HoldLink,
);
let link_data = LinkData::from_link(
&link,
LinkActionKind::ADD,
test_chain_header(),
test_agent_id(),
);

let link_entry = Entry::LinkAdd(link_data.clone());
let hold_link = create_pending_validation(link_entry, ValidatingWorkflow::HoldLink);
let action = ActionWrapper::new(Action::QueueHoldingWorkflow((hold_link.clone(), None)));
let store = reduce_queue_holding_workflow(&store, &action).unwrap();

Expand All @@ -597,7 +630,11 @@ pub mod tests {
let (next_pending, _) = store.next_queued_holding_workflow().unwrap();
assert_eq!(hold_link, next_pending);

let update = create_pending_validation(test_entry.clone(), ValidatingWorkflow::UpdateEntry);
let update = try_create_pending_validation(
test_entry.clone(),
test_header,
ValidatingWorkflow::UpdateEntry,
);
let action = ActionWrapper::new(Action::QueueHoldingWorkflow((update.clone(), None)));
let store = reduce_queue_holding_workflow(&store, &action).unwrap();

Expand Down
Loading