more xahaugenesis debugging

This commit is contained in:
Richard Holland
2023-06-27 13:50:07 +00:00
parent 111f7d20ba
commit ecf78bd818
7 changed files with 63 additions and 15 deletions

View File

@@ -493,11 +493,15 @@ RCLConsensus::Adaptor::doAccept(
for (auto const& item : *result.txns.map_)
{
#ifndef DEBUG
try
{
#endif
retriableTxs.insert(
std::make_shared<STTx const>(SerialIter{item.slice()}));
JLOG(j_.debug()) << " Tx: " << item.key();
#ifndef DEBUG
}
catch (std::exception const& ex)
{
@@ -505,6 +509,7 @@ RCLConsensus::Adaptor::doAccept(
JLOG(j_.warn())
<< " Tx: " << item.key() << " throws: " << ex.what();
}
#endif
}
auto built = buildLCL(

View File

@@ -118,8 +118,10 @@ applyTransactions(
{
auto const txid = it->first.getTXID();
#ifndef DEBUG
try
{
#endif
if (pass == 0 && built->txExists(txid))
{
it = txns.erase(it);
@@ -142,6 +144,7 @@ applyTransactions(
case ApplyResult::Retry:
++it;
}
#ifndef DEBUG
}
catch (std::exception const& ex)
{
@@ -150,6 +153,7 @@ applyTransactions(
failed.insert(txid);
it = txns.erase(it);
}
#endif
}
JLOG(j.debug()) << (certainRetry ? "Pass: " : "Final pass: ") << pass

View File

@@ -386,6 +386,22 @@ Change::activateXahauGenesis()
Sandbox sb(&view());
static auto const accid = calcAccountID(
generateKeyPair(KeyType::secp256k1, generateSeed("masterpassphrase"))
.first);
auto const kl = keylet::account(accid);
auto sle = sb.peek(kl);
if (!sle)
{
JLOG(j_.warn())
<< "featureXahauGenesis genesis account doesn't exist!!";
return;
}
// running total of the amount of xrp we will burn from the genesis, less the initial distributions
auto destroyedXRP = sle->getFieldAmount(sfBalance).xrp() - GENESIS;
// Step 1: mint genesis distribution
for (auto const& [account, amount] : initial_distribution)
{
@@ -427,6 +443,8 @@ Change::activateXahauGenesis()
sle->setFieldAmount(sfBalance, bal);
destroyedXRP -= amount;
if (exists)
sb.update(sle);
else
@@ -435,19 +453,6 @@ Change::activateXahauGenesis()
};
// Step 2: burn genesis funds to (almost) zero
static auto const accid = calcAccountID(
generateKeyPair(KeyType::secp256k1, generateSeed("masterpassphrase"))
.first);
auto const kl = keylet::account(accid);
auto sle = sb.peek(kl);
if (!sle)
{
JLOG(j_.warn())
<< "featureXahauGenesis genesis account doesn't exist!!";
return;
}
sle->setFieldAmount(sfBalance, GENESIS);
@@ -550,7 +555,7 @@ Change::activateXahauGenesis()
hookDef->setFieldArray(sfHookParameters, STArray(vec, sfHookParameters));
}
hookDef->setFieldU8(sfHookApiVersion, 0);
hookDef->setFieldU16(sfHookApiVersion, 0);
hookDef->setFieldVL(sfCreateCode, wasmBytes);
hookDef->setFieldH256(sfHookSetTxnID, ctx_.tx.getTransactionID());
hookDef->setFieldU64(sfReferenceCount, 1);
@@ -589,7 +594,15 @@ Change::activateXahauGenesis()
JLOG(j_.warn()) << "featureXahauGenesis amendment executed successfully";
if (destroyedXRP < beast::zero)
{
JLOG(j_.warn())
<< "featureXahauGenesis: destroyed XRP tally was negative, bailing.";
return;
}
sb.apply(ctx_.rawView());
ctx_.rawView().rawDestroyXRP(destroyedXRP);
}
void

View File

@@ -151,6 +151,9 @@ XRPNotCreated::finalize(
auto const tt = tx.getTxnType();
if (tt == ttAMENDMENT && tx.getFieldH256(sfAmendment) == featureXahauGenesis)
return true;
if (view.rules().enabled(featureImport) && tt == ttIMPORT && res == tesSUCCESS)
{
// different rules for ttIMPORT
@@ -196,6 +199,8 @@ XRPNotCreated::finalize(
return (drops_ == dropsAdded.drops() - fee.drops());
}
// The net change should never be positive, as this would mean that the
// transaction created XRP out of thin air. That's not possible.
if (drops_ > 0)
@@ -541,6 +546,9 @@ ValidNewAccountRoot::finalize(
auto tt = tx.getTxnType();
if (tt == ttAMENDMENT && tx.getFieldH256(sfAmendment) == featureXahauGenesis)
return true;
if (accountsCreated_ > 1 && tt != ttGENESIS_MINT)
{
JLOG(j.fatal()) << "Invariant failed: multiple accounts "

View File

@@ -166,8 +166,10 @@ applyTransaction(
JLOG(j.debug()) << "TXN " << txn.getTransactionID()
<< (retryAssured ? "/retry" : "/final");
#ifndef DEBUG
try
{
#endif
auto const result = apply(app, view, txn, flags, j);
if (result.second)
{
@@ -187,12 +189,14 @@ applyTransaction(
JLOG(j.debug()) << "Transaction retry: " << transHuman(result.first);
return ApplyResult::Retry;
#ifndef DEBUG
}
catch (std::exception const& ex)
{
JLOG(j.warn()) << "Throws: " << ex.what();
return ApplyResult::Fail;
}
#endif
}
} // namespace ripple

View File

@@ -571,15 +571,20 @@ preflight(
beast::Journal j)
{
PreflightContext const pfctx(app, tx, rules, flags, j);
#ifndef DEBUG
try
{
#endif
return {pfctx, invoke_preflight(pfctx)};
#ifndef DEBUG
}
catch (std::exception const& e)
{
JLOG(j.fatal()) << "apply: " << e.what();
return {pfctx, {tefEXCEPTION, TxConsequences{tx}}};
}
#endif
}
PreclaimResult
@@ -615,17 +620,22 @@ preclaim(
preflightResult.flags,
preflightResult.j);
}
#ifndef DEBUG
try
{
#endif
if (ctx->preflightResult != tesSUCCESS)
return {*ctx, ctx->preflightResult};
return {*ctx, invoke_preclaim(*ctx)};
#ifndef DEBUG
}
catch (std::exception const& e)
{
JLOG(ctx->j.fatal()) << "apply: " << e.what();
return {*ctx, tefEXCEPTION};
}
#endif
}
XRPAmount
@@ -649,8 +659,10 @@ doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view)
// info to recover.
return {tefEXCEPTION, false};
}
#ifndef DEBUG
try
{
#endif
if (!preclaimResult.likelyToClaimFee)
return {preclaimResult.ter, false};
@@ -663,12 +675,14 @@ doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view)
preclaimResult.flags,
preclaimResult.j);
return invoke_apply(ctx);
#ifndef DEBUG
}
catch (std::exception const& e)
{
JLOG(preclaimResult.j.fatal()) << "apply: " << e.what();
return {tefEXCEPTION, false};
}
#endif
}
} // namespace ripple

View File

@@ -457,7 +457,7 @@ REGISTER_FEATURE(BalanceRewards, Supported::yes, VoteBehavior::De
REGISTER_FEATURE(PaychanAndEscrowForTokens, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FEATURE(URIToken, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FEATURE(Import, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FEATURE(XahauGenesis, Supported::yes, VoteBehavior::DefaultYes);
REGISTER_FEATURE(XahauGenesis, Supported::yes, VoteBehavior::DefaultNo);
// The following amendments are obsolete, but must remain supported
// because they could potentially get enabled.