Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playback via ledger entries #721

Merged
merged 58 commits into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
5b2244b
use status messages to send append entries and deserialise/store them…
olgavrou Jan 15, 2020
20f8283
deserialise but don't commit
olgavrou Jan 16, 2020
07ddead
playback request on the same tx
olgavrou Jan 16, 2020
a99332e
remove local hooks, ae tracked by Pbft
olgavrou Jan 16, 2020
ea450c0
cleanup
olgavrou Jan 16, 2020
cbf19f2
cleanup
olgavrou Jan 16, 2020
70a4bbb
more tidying up
olgavrou Jan 17, 2020
f555293
fixing node_suspension, sending append entries message from status on…
olgavrou Jan 22, 2020
53a0b1f
send append entries until last-stable seqno
olgavrou Jan 24, 2020
a9c5a9b
refactor execute tentative request for playback and normal execution
olgavrou Jan 24, 2020
65074ef
re-using transaction in playback pre prepare
olgavrou Jan 24, 2020
3c6c306
added view change trace logging
olgavrou Jan 24, 2020
2337779
cleanup
olgavrou Jan 24, 2020
6c44b2f
removing un-needed locks
olgavrou Jan 24, 2020
9695ec2
check principal is configured before accepting certificate
olgavrou Jan 24, 2020
0ed2bd1
killing backups and making sure new nodes still make progress
olgavrou Jan 24, 2020
8e18dcf
rename node_suspension to late_joiners and add to CI
olgavrou Jan 24, 2020
7ab9f0f
merge from master
olgavrou Jan 24, 2020
a7ecd94
Merge branch 'master' into playback_via_ae
olgavrou Jan 24, 2020
99aab08
cleanup
olgavrou Jan 27, 2020
6eab092
Merge branch 'playback_via_ae' of github.com:microsoft/CCF into playb…
olgavrou Jan 27, 2020
973be03
remove un-used type
olgavrou Jan 27, 2020
b2abda8
merge from masger
olgavrou Jan 27, 2020
ef822da
actually use the transaction on playback
olgavrou Jan 28, 2020
1451a10
replacing append_entries_index with store->current_version() as they …
olgavrou Jan 28, 2020
a724888
remove un-used
olgavrou Jan 28, 2020
91d54f8
addressing some PR comments
olgavrou Jan 29, 2020
6c7b48d
trying to strip out an AppendEntriesIndex for both AppendEntries
olgavrou Jan 29, 2020
aea1bc2
cleanup and formatting
olgavrou Jan 29, 2020
20cc7f1
refactoring python test
olgavrou Jan 29, 2020
d778ecd
Merge branch 'consensus_ae_index' into playback_via_ae
olgavrou Jan 29, 2020
cc079eb
separating append entries index
olgavrou Jan 29, 2020
4b764f4
cleanup late_joiners.py
olgavrou Jan 29, 2020
72d91c5
indentation
olgavrou Jan 29, 2020
69a06ce
merging from master
olgavrou Jan 30, 2020
305edfc
cleanup
olgavrou Jan 30, 2020
a7dc790
addressing PR comments
olgavrou Jan 30, 2020
f294d21
cmake formatting
olgavrou Jan 30, 2020
75b77f2
fix ledger replay test
olgavrou Jan 30, 2020
e631f8c
Merge branch 'master' into playback_via_ae
olgavrou Jan 30, 2020
7d0ae50
print seed
olgavrou Jan 30, 2020
04ce745
Merge branch 'master' into playback_via_ae
olgavrou Jan 30, 2020
fba4b96
error handling
olgavrou Jan 30, 2020
30f3ea0
Merge branch 'playback_via_ae' of github.com:microsoft/CCF into playb…
olgavrou Jan 30, 2020
a3e46a9
Merge branch 'master' into playback_via_ae
olgavrou Jan 30, 2020
330cef6
Merge branch 'playback_via_ae' of github.com:microsoft/CCF into playb…
olgavrou Jan 30, 2020
805a48a
Merge branch 'master' into playback_via_ae
achamayou Jan 31, 2020
2979fc3
Merge branch 'playback_via_ae' of github.com:microsoft/CCF into playb…
olgavrou Jan 31, 2020
aa5a22a
Merge branch 'master' into playback_via_ae
jumaffre Jan 31, 2020
d069f07
remove set_reserved_version and address minor PR comments
olgavrou Jan 31, 2020
72e376f
Merge branch 'playback_via_ae' of github.com:microsoft/CCF into playb…
olgavrou Jan 31, 2020
ea1b7b3
remove commit bool from deserialise_views
olgavrou Jan 31, 2020
c6b0f17
removing playback bool from exec_command and execute_tentative_reques…
olgavrou Jan 31, 2020
9869c90
formatting
olgavrou Jan 31, 2020
1c2468e
Replace void* ctx in global_commit_cb and mark_stable_cb
olgavrou Jan 31, 2020
375db55
formatting
olgavrou Jan 31, 2020
470d04a
Merge branch 'master' into playback_via_ae
achamayou Feb 3, 2020
10163d8
disabing late joiners test for a stable CI - will re-enable with roll…
olgavrou Feb 3, 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
6 changes: 6 additions & 0 deletions cmake/pbft.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
add_definitions(-DSIGN_BATCH)
set(SIGN_BATCH ON)

if(SAN)
add_definitions(-DUSE_STD_MALLOC)
endif()

set(PBFT_SRC
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/globalstate.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Client.cpp
Expand Down Expand Up @@ -47,6 +51,7 @@ set(PBFT_SRC
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/request_id_gen.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/New_principal.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Network_open.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Append_entries.cpp
)

if("sgx" IN_LIST TARGET)
Expand Down Expand Up @@ -114,6 +119,7 @@ if("virtual" IN_LIST TARGET)
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test ${EVERCRYPT_INC}
)

add_dependencies(libcommontest.mock flatbuffers)
target_compile_options(libcommontest.mock PRIVATE -stdlib=libc++)

function(use_libbyz name)
Expand Down
20 changes: 20 additions & 0 deletions src/consensus/consensustypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,24 @@ namespace ccf
{
using ObjectId = uint64_t;
using NodeId = ObjectId;
using Index = int64_t;
using Node2NodeMsg = uint64_t;
}

namespace consensus
{
#pragma pack(push, 1)
template <typename T = ccf::Node2NodeMsg>
struct ConsensusHeader
{
T msg;
olgavrou marked this conversation as resolved.
Show resolved Hide resolved
ccf::NodeId from_node;
};

struct AppendEntriesIndex
{
ccf::Index idx;
ccf::Index prev_idx;
};
#pragma pack(pop)
}
11 changes: 11 additions & 0 deletions src/consensus/ledgerenclave.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ namespace consensus
serialized::skip(data, size, entry_len);
}

std::pair<std::vector<uint8_t>, bool> get_entry(
olgavrou marked this conversation as resolved.
Show resolved Hide resolved
const uint8_t*& data, size_t& size)
{
auto entry_len = serialized::read<uint32_t>(data, size);
std::vector<uint8_t> entry(data, data + entry_len);

serialized::skip(data, size, entry_len);

return std::make_pair(std::move(entry), true);
}

/**
* Truncate the ledger at a given index.
*
Expand Down
36 changes: 36 additions & 0 deletions src/consensus/pbft/libbyz/Append_entries.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) Microsoft Corporation.
// Copyright (c) 1999 Miguel Castro, Barbara Liskov.
// Copyright (c) 2000, 2001 Miguel Castro, Rodrigo Rodrigues, Barbara Liskov.
// Licensed under the MIT license.
#include "Append_entries.h"

#include "Message_tags.h"
#include "ds/logger.h"
#include "pbft_assert.h"

Append_entries::Append_entries() :
Message(Append_entries_tag, sizeof(Append_entries_rep))
{}

bool Append_entries::verify()
{
return true;
}

bool Append_entries::convert(Message* m1, Append_entries*& m2)
{
if (!m1->has_tag(Append_entries_tag, sizeof(Append_entries_rep)))
{
return false;
}

m1->trim();
m2 = (Append_entries*)m1;
return true;
}

Append_entries_rep& Append_entries::rep() const
{
PBFT_ASSERT(ALIGNED(msg), "Improperly aligned pointer");
olgavrou marked this conversation as resolved.
Show resolved Hide resolved
return *((Append_entries_rep*)msg);
}
30 changes: 30 additions & 0 deletions src/consensus/pbft/libbyz/Append_entries.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation.
// Copyright (c) 1999 Miguel Castro, Barbara Liskov.
// Copyright (c) 2000, 2001 Miguel Castro, Rodrigo Rodrigues, Barbara Liskov.
// Licensed under the MIT license.
#pragma once

#include "Message.h"
#include "nodeinfo.h"

//
// Append entries messages have the following format:
//
#pragma pack(push)
#pragma pack(1)
struct Append_entries_rep : public Message_rep
{};
#pragma pack(pop)

class Append_entries : public Message
{
public:
Append_entries();

bool verify();

static bool convert(Message* m1, Append_entries*& m2);

private:
Append_entries_rep& rep() const;
};
10 changes: 10 additions & 0 deletions src/consensus/pbft/libbyz/Certificate.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,16 @@ void Certificate<T>::reset_f()
template <class T>
bool Certificate<T>::add(T* m)
{
auto principal = pbft::GlobalState::get_node().get_principal(m->id());
if (!principal)
{
LOG_INFO_FMT(
"Principal with id {} has not been configured yet, rejecting the message",
m->id());
delete m;
return false;
}

if (bmap.none() && f != pbft::GlobalState::get_node().f())
{
reset_f();
Expand Down
7 changes: 6 additions & 1 deletion src/consensus/pbft/libbyz/LedgerWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Request.h"

LedgerWriter::LedgerWriter(
pbft::Store& store_, pbft::PrePreparesMap& pbft_pre_prepares_map_) :
pbft::PbftStore& store_, pbft::PrePreparesMap& pbft_pre_prepares_map_) :
store(store_),
pbft_pre_prepares_map(pbft_pre_prepares_map_)
{}
Expand Down Expand Up @@ -34,6 +34,11 @@ void LedgerWriter::write_prepare(
}
}

void LedgerWriter::write_pre_prepare(ccf::Store::Tx& tx)
{
store.commit_tx(tx);
}

void LedgerWriter::write_pre_prepare(Pre_prepare* pp)
{
store.commit_pre_prepare(
Expand Down
5 changes: 3 additions & 2 deletions src/consensus/pbft/libbyz/LedgerWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
class LedgerWriter
{
private:
pbft::Store& store;
pbft::PbftStore& store;
pbft::PrePreparesMap& pbft_pre_prepares_map;

public:
LedgerWriter(
pbft::Store& store_, pbft::PrePreparesMap& pbft_pre_prepares_map_);
pbft::PbftStore& store_, pbft::PrePreparesMap& pbft_pre_prepares_map_);
virtual ~LedgerWriter() = default;
void write_prepare(const Prepared_cert& prepared_cert, Seqno seqno);
void write_pre_prepare(Pre_prepare* pp);
void write_pre_prepare(ccf::Store::Tx& tx);
void write_view_change(View_change* vc);
};
3 changes: 2 additions & 1 deletion src/consensus/pbft/libbyz/Message_tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const short Fetch_tag = 15;
const short Query_stable_tag = 16;
const short Reply_stable_tag = 17;
const short Network_open_tag = 18;
const short Max_message_tag = 19;
const short Append_entries_tag = 19;
const short Max_message_tag = 20;
olgavrou marked this conversation as resolved.
Show resolved Hide resolved

// Message used for testing are in the 100+ range
const short New_principal_tag = 100;
5 changes: 5 additions & 0 deletions src/consensus/pbft/libbyz/Pre_prepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ bool Pre_prepare::pre_verify()
{
auto sender_principal =
pbft::GlobalState::get_node().get_principal(sender);
if (!sender_principal)
{
LOG_INFO_FMT("Sender principal has not been configured yet {}", sender);
return false;
}

if (
!sender_principal->has_certificate_set() &&
Expand Down
14 changes: 12 additions & 2 deletions src/consensus/pbft/libbyz/Prepared_cert.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,18 @@ class Prepared_cert

inline bool Prepared_cert::add(Prepare* m)
{
#ifdef SIGN_BATCH
int id = m->id();
auto principal = pbft::GlobalState::get_node().get_principal(id);
if (!principal)
{
LOG_INFO_FMT(
"Principal with id {} has not been configured yet, rejecting prepare",
id);
delete m;
return false;
}

#ifdef SIGN_BATCH
PbftSignature& digest_sig = m->digest_sig();
PrePrepareProof proof;
std::copy(
Expand All @@ -153,7 +163,7 @@ inline bool Prepared_cert::add(Prepare* m)
#ifdef SIGN_BATCH
if (result)
{
proof.cert = pbft::GlobalState::get_node().get_principal(id)->get_cert();
proof.cert = principal->get_cert();
pre_prepare_proof.insert({id, proof});
}
#endif
Expand Down
Loading