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

Merge bugfixes and changes #319

Merged
merged 8 commits into from
Mar 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions Builds/VisualStudio2013/RippleD.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\tx\LocalTxs.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\tx\Transaction.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
Expand Down Expand Up @@ -2559,6 +2565,7 @@
<ClInclude Include="..\..\src\ripple_app\transactors\Transactor.h" />
<ClInclude Include="..\..\src\ripple_app\transactors\TrustSetTransactor.h" />
<ClInclude Include="..\..\src\ripple_app\transactors\WalletAddTransactor.h" />
<ClInclude Include="..\..\src\ripple_app\tx\LocalTxs.h" />
<ClInclude Include="..\..\src\ripple_app\tx\Transaction.h" />
<ClInclude Include="..\..\src\ripple_app\tx\TransactionAcquire.h" />
<ClInclude Include="..\..\src\ripple_app\tx\TransactionEngine.h" />
Expand Down
6 changes: 6 additions & 0 deletions Builds/VisualStudio2013/RippleD.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,9 @@
<ClCompile Include="..\..\src\ripple_app\main\Main.cpp">
<Filter>[2] Old Ripple\ripple_app\main</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\tx\LocalTxs.cpp">
<Filter>[2] Old Ripple\ripple_app\tx</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\ripple_basics\containers\RangeSet.h">
Expand Down Expand Up @@ -3057,6 +3060,9 @@
<ClInclude Include="..\..\src\ripple_core\functional\JobTypes.h">
<Filter>[2] Old Ripple\ripple_core\functional</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_app\tx\LocalTxs.h">
<Filter>[2] Old Ripple\ripple_app\tx</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\src\ripple_data\protocol\ripple.proto">
Expand Down
1 change: 1 addition & 0 deletions src/ripple/resource/api/Fees.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ extern Charge const feeLightRPC; // A normal RPC command
extern Charge const feeLowBurdenRPC; // A slightly burdensome RPC load
extern Charge const feeMediumBurdenRPC; // A somewhat burdensome RPC load
extern Charge const feeHighBurdenRPC; // A very burdensome RPC load
extern Charge const feePathFindUpdate; // An update to an existing PF request

// Good things
extern Charge const feeNewTrustedNote; // A new transaction/validation/proposal we trust
Expand Down
17 changes: 9 additions & 8 deletions src/ripple/resource/impl/Fees.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,20 @@ Charge const feeInvalidRPC ( 10, "malformed RPC" );
Charge const feeReferenceRPC ( 2, "reference RPC" );
Charge const feeExceptionRPC ( 10, "exceptioned RPC" );
Charge const feeLightRPC ( 5, "light RPC" ); // DAVID: Check the cost
Charge const feeLowBurdenRPC ( 10, "low RPC" );
Charge const feeMediumBurdenRPC ( 20, "medium RPC" );
Charge const feeHighBurdenRPC ( 50, "heavy RPC" );
Charge const feeLowBurdenRPC ( 20, "low RPC" );
Charge const feeMediumBurdenRPC ( 40, "medium RPC" );
Charge const feeHighBurdenRPC ( 300, "heavy RPC" );
Charge const feePathFindUpdate ( 100, "path update" );

Charge const feeNewTrustedNote ( 10, "trusted note" );
Charge const feeNewValidTx ( 2, "valid tx" );
Charge const feeNewValidTx ( 10, "valid tx" );
Charge const feeSatisfiedRequest ( 10, "needed data" );

Charge const feeRequestedData ( 5, "costly request" );
Charge const feeCheapQuery ( 1, "trivial query" );
Charge const feeRequestedData ( 50, "costly request" );
Charge const feeCheapQuery ( 10, "trivial query" );

Charge const feeWarning ( 10, "received warning" ); // DAVID: Check the cost
Charge const feeDrop ( 100, "dropped" ); // DAVID: Check the cost
Charge const feeWarning ( 200, "received warning" );
Charge const feeDrop ( 300, "dropped" );

}
}
4 changes: 2 additions & 2 deletions src/ripple/resource/impl/Tuning.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ namespace Resource {
enum
{
// Balance at which a warning is issued
warningThreshold = 1000
warningThreshold = 500

// Balance at which the consumer is disconnected
,dropThreshold = 5000
,dropThreshold = 1500

// The number of seconds until an inactive table item is removed
,secondsUntilExpiration = 300
Expand Down
27 changes: 19 additions & 8 deletions src/ripple_app/consensus/LedgerConsensus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ class LedgerConsensusImp

static char const* getCountedObjectName () { return "LedgerConsensus"; }

LedgerConsensusImp (clock_type& clock, LedgerHash const & prevLCLHash,
LedgerConsensusImp (clock_type& clock, LocalTxs& localtx,
LedgerHash const & prevLCLHash,
Ledger::ref previousLedger, std::uint32_t closeTime)
: m_clock (clock)
, m_localTX (localtx)
, mState (lcsPRE_CLOSE)
, mCloseTime (closeTime)
, mPrevLedgerHash (prevLCLHash)
Expand Down Expand Up @@ -518,7 +520,7 @@ class LedgerConsensusImp
&getApp().getInboundLedgers(),
mPrevLedgerHash, 0, InboundLedger::fcCONSENSUS));
mHaveCorrectLCL = false;
}
}
return;
}

Expand Down Expand Up @@ -849,15 +851,16 @@ class LedgerConsensusImp
*/
void accept (SHAMap::pointer set)
{
if (set->getHash ().isNonZero ())
// put our set where others can get it later
getApp().getOPs ().takePosition (mPreviousLedger
->getLedgerSeq (), set);

{
Application::ScopedLockType lock
(getApp ().getMasterLock ());

// put our set where others can get it later
if (set->getHash ().isNonZero ())
getApp().getOPs ().takePosition (
mPreviousLedger->getLedgerSeq (), set);

assert (set->getHash () == mOurPosition->getCurrentHash ());
// these are now obsolete
getApp().getOPs ().peekStoredProposals ().clear ();
Expand Down Expand Up @@ -1010,6 +1013,12 @@ class LedgerConsensusImp
applyTransactions (getApp().getLedgerMaster ().getCurrentLedger
()->peekTransactionMap (), newOL, newLCL,
failedTransactions, true);

{
TransactionEngine engine (newOL);
m_localTX.apply (engine);
}

getApp().getLedgerMaster ().pushLedger (newLCL, newOL);
mNewLedgerHash = newLCL->getHash ();
mState = lcsACCEPTED;
Expand Down Expand Up @@ -1863,6 +1872,7 @@ class LedgerConsensusImp
}
private:
clock_type& m_clock;
LocalTxs& m_localTX;

// VFALCO TODO Rename these to look pretty
enum LCState
Expand Down Expand Up @@ -1918,11 +1928,12 @@ LedgerConsensus::~LedgerConsensus ()
{
}

boost::shared_ptr <LedgerConsensus> LedgerConsensus::New (clock_type& clock,
boost::shared_ptr <LedgerConsensus> LedgerConsensus::New (
clock_type& clock, LocalTxs& localtx,
LedgerHash const &prevLCLHash, Ledger::ref previousLedger, std::uint32_t closeTime)
{
return boost::make_shared <LedgerConsensusImp> (
clock, prevLCLHash, previousLedger,closeTime);
clock, localtx, prevLCLHash, previousLedger,closeTime);
}

} // ripple
3 changes: 2 additions & 1 deletion src/ripple_app/consensus/LedgerConsensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class LedgerConsensus
public:
typedef beast::abstract_clock <std::chrono::seconds> clock_type;

static boost::shared_ptr <LedgerConsensus> New (clock_type& clock,
static boost::shared_ptr <LedgerConsensus> New (
clock_type& clock, LocalTxs& localtx,
LedgerHash const & prevLCLHash, Ledger::ref previousLedger,
std::uint32_t closeTime);

Expand Down
13 changes: 12 additions & 1 deletion src/ripple_app/ledger/LedgerMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,16 @@ class LedgerMasterImp
{
}

std::uint32_t getCurrentLedgerIndex ()
LedgerIndex getCurrentLedgerIndex ()
{
return mCurrentLedger.get ()->getLedgerSeq ();
}

LedgerIndex getValidLedgerIndex ()
{
return mValidLedgerSeq;
}

int getPublishedLedgerAge ()
{
std::uint32_t pubClose = mPubLedgerClose.load();
Expand Down Expand Up @@ -170,6 +175,7 @@ class LedgerMasterImp
mValidLedger.set (l);
mValidLedgerClose = l->getCloseTimeNC();
mValidLedgerSeq = l->getLedgerSeq();
getApp().getOPs().updateLocalTx (l);
}

void setPubLedger(Ledger::ref l)
Expand Down Expand Up @@ -299,6 +305,11 @@ class LedgerMasterImp

if (didApply)
++recovers;

// If a transaction is recovered but hasn't been relayed,
// it will become disputed in the consensus process, which
// will cause it to be relayed.

}
catch (...)
{
Expand Down
3 changes: 2 additions & 1 deletion src/ripple_app/ledger/LedgerMaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class LedgerMaster

virtual ~LedgerMaster () = 0;

virtual std::uint32_t getCurrentLedgerIndex () = 0;
virtual LedgerIndex getCurrentLedgerIndex () = 0;
virtual LedgerIndex getValidLedgerIndex () = 0;

virtual LockType& peekMutex () = 0;

Expand Down
1 change: 1 addition & 0 deletions src/ripple_app/ledger/SerializedValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void SerializedValidation::sign (uint256& signingHash, const RippleAddress& raPr
Blob signature;
raPriv.signNodePrivate (signingHash, signature);
setFieldVL (sfSignature, signature);
setFlag (vfFullyCanonicalSig);
}

uint256 SerializedValidation::getSigningHash () const
Expand Down
43 changes: 35 additions & 8 deletions src/ripple_app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class NetworkOPsImp
: NetworkOPs (parent)
, m_clock (clock)
, m_journal (journal)
, m_localTX (LocalTxs::New ())
, mMode (omDISCONNECTED)
, mNeedNetworkLedger (false)
, mProposing (false)
Expand Down Expand Up @@ -323,6 +324,19 @@ class NetworkOPsImp
void storeProposal (LedgerProposal::ref proposal, const RippleAddress& peerPublic);
uint256 getConsensusLCL ();
void reportFeeChange ();

void updateLocalTx (Ledger::ref newValidLedger) override
{
m_localTX->sweep (newValidLedger);
}
void addLocalTx (Ledger::ref openLedger, SerializedTransaction::ref txn) override
{
m_localTX->push_back (openLedger->getLedgerSeq(), txn);
}
std::size_t getLocalTxCount () override
{
return m_localTX->size ();
}

//Helper function to generate SQL query to get transactions
std::string transactionsSQL (std::string selection, const RippleAddress& account,
Expand Down Expand Up @@ -435,6 +449,9 @@ class NetworkOPsImp
typedef std::lock_guard <LockType> ScopedLockType;

beast::Journal m_journal;

std::unique_ptr <LocalTxs> m_localTX;

LockType mLock;

OperatingMode mMode;
Expand Down Expand Up @@ -748,7 +765,7 @@ void NetworkOPsImp::submitTransaction (Job&, SerializedTransaction::pointer iTra
{
try
{
if (!isMemoOkay (*trans) || !trans->checkSign ())
if (!passesLocalChecks (*trans) || !trans->checkSign ())
{
m_journal.warning << "Submitted transaction has bad signature";
getApp().getHashRouter ().setFlag (suppress, SF_BAD);
Expand Down Expand Up @@ -945,13 +962,16 @@ Transaction::pointer NetworkOPsImp::processTransactionCb (
if (callback)
callback (trans, r);


if (r == tefFAILURE)
{
// VFALCO TODO All callers use a try block so this should be changed to
// a return value.
throw Fault (IO_ERROR);
}

bool addLocal = bLocal;

if (r == tesSUCCESS)
{
m_journal.info << "Transaction is now included in open ledger";
Expand All @@ -968,13 +988,15 @@ Transaction::pointer NetworkOPsImp::processTransactionCb (
}
else if (isTerRetry (r))
{
if (!bFailHard)
if (bFailHard)
addLocal = false;
else
{
// transaction should be held
m_journal.debug << "Transaction should be held: " << r;
trans->setStatus (HELD);
getApp().getMasterTransaction ().canonicalize (&trans);
m_ledgerMaster.addHeldTransaction (trans);
// transaction should be held
m_journal.debug << "Transaction should be held: " << r;
trans->setStatus (HELD);
getApp().getMasterTransaction ().canonicalize (&trans);
m_ledgerMaster.addHeldTransaction (trans);
}
}
else
Expand All @@ -983,6 +1005,9 @@ Transaction::pointer NetworkOPsImp::processTransactionCb (
trans->setStatus (INVALID);
}

if (addLocal)
addLocalTx (m_ledgerMaster.getCurrentLedger (), trans->getSTransaction ());

if (didApply || ((mMode != omFULL) && !bFailHard && bLocal))
{
std::set<Peer::ShortId> peers;
Expand Down Expand Up @@ -1435,7 +1460,7 @@ int NetworkOPsImp::beginConsensus (uint256 const& networkClosed, Ledger::pointer
assert (!mConsensus);
prevLedger->setImmutable ();

mConsensus = LedgerConsensus::New (m_clock,
mConsensus = LedgerConsensus::New (m_clock, *m_localTX,
networkClosed, prevLedger,
m_ledgerMaster.getCurrentLedger ()->getCloseTimeNC ());

Expand Down Expand Up @@ -1536,6 +1561,7 @@ void NetworkOPsImp::processTrustedProposal (LedgerProposal::pointer proposal,
}
}

// Must be called while holding the master lock
SHAMap::pointer NetworkOPsImp::getTXMap (uint256 const& hash)
{
std::map<uint256, std::pair<int, SHAMap::pointer> >::iterator it = mRecentPositions.find (hash);
Expand All @@ -1549,6 +1575,7 @@ SHAMap::pointer NetworkOPsImp::getTXMap (uint256 const& hash)
return mConsensus->getTransactionTree (hash, false);
}

// Must be called while holding the master lock
void NetworkOPsImp::takePosition (int seq, SHAMap::ref position)
{
mRecentPositions[position->getHash ()] = std::make_pair (seq, position);
Expand Down
4 changes: 4 additions & 0 deletions src/ripple_app/misc/NetworkOPs.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ class NetworkOPs

virtual void reportFeeChange () = 0;

virtual void updateLocalTx (Ledger::ref newValidLedger) = 0;
virtual void addLocalTx (Ledger::ref openLedger, SerializedTransaction::ref txn) = 0;
virtual std::size_t getLocalTxCount () = 0;

//Helper function to generate SQL query to get transactions
virtual std::string transactionsSQL (std::string selection,
const RippleAddress& account, std::int32_t minLedger, std::int32_t maxLedger,
Expand Down
Loading