Skip to content

Commit

Permalink
Merge branch 'feature/mergeBitrice' into 'develop'
Browse files Browse the repository at this point in the history
Merge precompiled contract and other functions

See merge request chainsql/chainsqld!165
  • Loading branch information
luleiHello committed Oct 19, 2021
2 parents 4fdcb29 + fc464f3 commit 5305fe3
Show file tree
Hide file tree
Showing 27 changed files with 565 additions and 120 deletions.
1 change: 1 addition & 0 deletions Builds/CMake/ChainsqldCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ target_sources (chainsqld PRIVATE
src/ripple/basics/impl/UptimeClock.cpp
src/ripple/basics/impl/make_SSLContext.cpp
src/ripple/basics/impl/mulDiv.cpp
src/ripple/basics/impl/Sustain.cpp
#[===============================[
main sources:
subdir: conditions
Expand Down
3 changes: 2 additions & 1 deletion src/peersafe/app/misc/TxPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class TxPool

std::shared_mutex mutable mutexSet_;
std::shared_mutex mutable mutexAvoid_;

std::shared_mutex mutable mutexMapSynced_;
std::size_t mMaxTxsInPool;

using TransactionSet =
Expand All @@ -185,6 +185,7 @@ class TxPool

sync_status mSyncStatus;


beast::Journal j_;
};

Expand Down
8 changes: 4 additions & 4 deletions src/peersafe/app/misc/impl/Executive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ bool Executive::call(CallParametersR const& _p, uint256 const& _gasPrice, Accoun
if (ter != tesSUCCESS)
{
m_excepted = ter;
auto output = get<1>(retPre);
m_output =
eth::owning_bytes_ref{std::move(output), 0, output.size()};
return true;
}
}
auto output = get<1>(retPre);
if (output.size() > 0)
m_output = eth::owning_bytes_ref{std::move(output), 0, output.size()};
}
else
{
m_gas = _p.gas;
Expand Down
13 changes: 7 additions & 6 deletions src/peersafe/app/misc/impl/SleOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,14 +531,15 @@ namespace ripple {
Json::Value jvCommand, tableJson;
jvCommand[jss::tx_json][jss::Owner] = to_string(_owner);
jvCommand[jss::tx_json][jss::Account] = to_string(_account);
Json::Value _fields(Json::arrayValue);//select fields
jvCommand[jss::tx_json][jss::Raw].append(_fields);//append select fields
if (!_raw.empty())//append select conditions
{
Json::Value _condition;
Json::Reader().parse(_raw, _condition);
jvCommand[jss::tx_json][jss::Raw].append(_condition);
}
jvCommand[jss::tx_json][jss::Raw] = _raw;
}
else
{
Json::Value _fields(Json::arrayValue); // select fields
jvCommand[jss::tx_json][jss::Raw].append(_fields); // append select fields
}
jvCommand[jss::tx_json][jss::OpType] = R_GET;
tableJson[jss::Table][jss::TableName] = _sTableName;

Expand Down
1 change: 1 addition & 0 deletions src/peersafe/app/misc/impl/TxPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ TxPool::removeTxs(
void
TxPool::checkSyncStatus(LedgerIndex ledgerSeq, uint256 const& prevHash)
{
std::lock_guard lock(mutexMapSynced_);
// update sync_status
if (mTxsSet.size() == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/peersafe/app/table/TableSync.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TableSync
bool isExist(std::list<std::shared_ptr <TableSyncItem>> listTableInfo_, AccountID accountID, std::string sTableName, TableSyncItem::SyncTargetType eTargeType);

bool
isSync(std::list<std::shared_ptr<TableSyncItem>> listTableInfo_, AccountID accountID, std::string sTableName, TableSyncItem::SyncTargetType eTargeType);
isSync(std::list<std::shared_ptr<TableSyncItem>> listTableInfo_, std::string uTxDBName, TableSyncItem::SyncTargetType eTargeType);

//get reply
bool GotSyncReply(std::shared_ptr <protocol::TMTableData> const& m, std::weak_ptr<Peer> const& wPeer);
Expand Down
28 changes: 16 additions & 12 deletions src/peersafe/app/table/impl/TableSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,15 +553,20 @@ TableSync::ParseSyncAccount(std::string line)

AccountID userAccount;
SecretKey secret_key;
if (vec.size() == 2 && (vec[1][0] == 'p' || vec[1][0] == 'x'))
if (vec.size() == 2)
{
auto tup = ParseSecret(vec[1], "");
if (std::get<2>(tup))
if ((vec[1][0] == 'p' || vec[1][0] == 'x'))
{
userAccount = std::get<0>(tup);
secret_key = std::get<1>(tup);
auto tup = ParseSecret(vec[1], "");
if (std::get<2>(tup))
{
userAccount = std::get<0>(tup);
secret_key = std::get<1>(tup);
}
return std::make_tuple(*oAccountID, userAccount,secret_key, true);
}
return std::make_tuple(*oAccountID, userAccount,secret_key, true);
return std::make_tuple(*oAccountID, beast::zero, SecretKey(), false);

}
else
{
Expand Down Expand Up @@ -954,13 +959,12 @@ bool TableSync::isExist(std::list<std::shared_ptr <TableSyncItem>> listTableInf


bool
TableSync::isSync(std::list<std::shared_ptr<TableSyncItem>> listTableInfo_, AccountID accountID, std::string sTableName, TableSyncItem::SyncTargetType eTargeType)
TableSync::isSync(std::list<std::shared_ptr<TableSyncItem>> listTableInfo_, std::string uTxDBName, TableSyncItem::SyncTargetType eTargeType)
{
std::lock_guard lock(mutexlistTable_);
std::list<std::shared_ptr<TableSyncItem>>::iterator iter = std::find_if(listTableInfo_.begin(),listTableInfo_.end(),
[accountID, sTableName, eTargeType](std::shared_ptr<TableSyncItem> pItem) {
bool bExist = (pItem->GetTableName() == sTableName) &&
(pItem->GetAccount() == accountID) &&
[uTxDBName, eTargeType](std::shared_ptr<TableSyncItem> pItem) {
bool bExist = (pItem->TableNameInDB() == uTxDBName) &&
(pItem->TargetType() == eTargeType) &&
(pItem->GetSyncState() != TableSyncItem::SYNC_DELETING &&
pItem->GetSyncState() != TableSyncItem::SYNC_REMOVE &&
Expand Down Expand Up @@ -1845,7 +1849,7 @@ void TableSync::CheckSyncTableTxs(std::shared_ptr<Ledger const> const& ledger)
bool bDBTableSync = false;
if (mapTxDBNam2Sync.find(uTxDBName) == mapTxDBNam2Sync.end())
{
bDBTableSync = isSync(listTableInfo_, accountID, tableName, TableSyncItem::SyncTarget_db);
bDBTableSync = isSync(listTableInfo_, to_string(uTxDBName), TableSyncItem::SyncTarget_db);
mapTxDBNam2Sync[uTxDBName] = bDBTableSync;
}
else
Expand All @@ -1854,7 +1858,7 @@ void TableSync::CheckSyncTableTxs(std::shared_ptr<Ledger const> const& ledger)
}
if (!bDBTableSync)
{
app_.getOPs().pubTableTxs(accountID, tableName, *pSTTX, std::make_tuple("db_acctSecretError", "", ""), false);
app_.getOPs().pubTableTxs(accountID, tableName, *pSTTX, std::make_tuple("db_notInSync", "", ""), false);
break;
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/peersafe/app/tx/impl/DirectApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ namespace ripple {
applyDirect(Schema& app, ApplyView& view, STTx const& tx, beast::Journal j)
{
auto pfresult = preflight(app, view.openView().rules(), tx, view.flags()| tapNO_CHECK_SIGN, j);
auto pcresult = preclaimDirect(pfresult, app, view.openView());
// construct a openview copy,and apply change to it
std::shared_ptr<OpenView> openView =
std::make_shared<OpenView>(view.openView());
((ApplyViewImpl&)view).items().apply(*openView);

auto pcresult = preclaimDirect(pfresult, app, *openView);
auto ret = doApplyDirect(pcresult, app, view);
return ret;
//return doApplyDirect(pcresult, app, view);
Expand Down
4 changes: 3 additions & 1 deletion src/peersafe/consensus/Adaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ class Adaptor
bool haveCorrectLCL);

virtual void
InitAnnounce(STInitAnnounce const& initAnnounce);
InitAnnounce(
STInitAnnounce const& initAnnounce,
boost::optional<PublicKey> pubKey = boost::none);

void
signMessage(protocol::TMConsensus& consensus);
Expand Down
2 changes: 2 additions & 0 deletions src/peersafe/consensus/ConsensusBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class ConsensusBase

// Last validated ledger ID provided to consensus
typename Ledger_t::ID prevLedgerID_;
Ledger_t::Seq prevLedgerSeq_;

// Last validated ledger seen by consensus
Ledger_t previousLedger_;

Expand Down
9 changes: 6 additions & 3 deletions src/peersafe/consensus/impl/Adaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Adaptor::notify(
}

void
Adaptor::InitAnnounce(STInitAnnounce const& initAnnounce)
Adaptor::InitAnnounce(STInitAnnounce const& initAnnounce, boost::optional<PublicKey> pubKey /* = boost::none */)
{
Blob v = initAnnounce.getSerialized();

Expand All @@ -172,7 +172,10 @@ Adaptor::InitAnnounce(STInitAnnounce const& initAnnounce)
consensus.set_msgtype(ConsensusMessageType::mtINITANNOUNCE);
consensus.set_schemaid(app_.schemaId().begin(), uint256::size());

signAndSendMessage(consensus);
if (pubKey)
signAndSendMessage(*pubKey, consensus);
else
signAndSendMessage(consensus);
}

void
Expand Down Expand Up @@ -275,7 +278,7 @@ void
Adaptor::touchAcquringLedger(LedgerHash const& prevLedgerHash)
{
auto inboundLedger = app_.getInboundLedgers().find(prevLedgerHash);
if (inboundLedger)
if (inboundLedger && !inboundLedger->isComplete() && !inboundLedger->isFailed())
{
JLOG(j_.warn()) << "touch inboundLedger for " << prevLedgerHash;
inboundLedger->touch();
Expand Down
3 changes: 3 additions & 0 deletions src/peersafe/consensus/pop/PopConsensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class PopConsensus : public ConsensusBase

std::recursive_mutex lock_;

Ledger_t::ID initAcquireLedgerID_ = beast::zero;
public:
/** Constructor.
Expand Down Expand Up @@ -180,6 +181,8 @@ class PopConsensus : public ConsensusBase

void
initAnnounce();
void
initAnnounceToPeer(PublicKey const& pubKey);

void
startRoundInternal(
Expand Down
Loading

0 comments on commit 5305fe3

Please sign in to comment.