mirror of
https://github.com/Xahau/xahaud.git
synced 2026-01-13 11:15:16 +00:00
Compare commits
2 Commits
fix-workfl
...
fixXahauGe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac93b24c91 | ||
|
|
a8d7b2619e |
15
.github/actions/xahau-ga-dependencies/action.yml
vendored
15
.github/actions/xahau-ga-dependencies/action.yml
vendored
@@ -134,17 +134,10 @@ runs:
|
||||
- name: Export custom recipes
|
||||
shell: bash
|
||||
run: |
|
||||
# Export snappy if not already exported
|
||||
conan list snappy/1.1.10@xahaud/stable 2>/dev/null | (grep -q "not found" && exit 1 || exit 0) || \
|
||||
conan export external/snappy --version 1.1.10 --user xahaud --channel stable
|
||||
|
||||
# Export soci if not already exported
|
||||
conan list soci/4.0.3@xahaud/stable 2>/dev/null | (grep -q "not found" && exit 1 || exit 0) || \
|
||||
conan export external/soci --version 4.0.3 --user xahaud --channel stable
|
||||
|
||||
# Export wasmedge if not already exported
|
||||
conan list wasmedge/0.11.2@xahaud/stable 2>/dev/null | (grep -q "not found" && exit 1 || exit 0) || \
|
||||
conan export external/wasmedge --version 0.11.2 --user xahaud --channel stable
|
||||
conan export external/snappy --version 1.1.10 --user xahaud --channel stable
|
||||
conan export external/soci --version 4.0.3 --user xahaud --channel stable
|
||||
conan export external/wasmedge --version 0.11.2 --user xahaud --channel stable
|
||||
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
env:
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <ripple/app/misc/AmendmentTable.h>
|
||||
#include <ripple/app/misc/NetworkOPs.h>
|
||||
#include <ripple/app/tx/impl/Change.h>
|
||||
#include <ripple/app/tx/impl/SetHook.h>
|
||||
#include <ripple/app/tx/impl/SetSignerList.h>
|
||||
#include <ripple/app/tx/impl/XahauGenesis.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
@@ -583,10 +584,6 @@ Change::activateXahauGenesis()
|
||||
SetSignerList::removeFromLedger(ctx_.app, sb, accid, j_);
|
||||
|
||||
// Step 4: install genesis hooks
|
||||
sle->setFieldU32(
|
||||
sfOwnerCount, sle->getFieldU32(sfOwnerCount) + genesis_hooks.size());
|
||||
sb.update(sle);
|
||||
|
||||
if (sb.exists(keylet::hook(accid)))
|
||||
{
|
||||
JLOG(j_.warn()) << "featureXahauGenesis genesis account already has "
|
||||
@@ -597,6 +594,7 @@ Change::activateXahauGenesis()
|
||||
{
|
||||
ripple::STArray hooks{sfHooks, static_cast<int>(genesis_hooks.size())};
|
||||
int hookCount = 0;
|
||||
uint32_t hookReserve = 0;
|
||||
|
||||
for (auto const& [hookOn, wasmBytes, params] : genesis_hooks)
|
||||
{
|
||||
@@ -702,8 +700,14 @@ Change::activateXahauGenesis()
|
||||
}
|
||||
|
||||
hooks.push_back(hookObj);
|
||||
|
||||
hookReserve += SetHook::computeHookReserve(hookObj);
|
||||
}
|
||||
|
||||
sle->setFieldU32(
|
||||
sfOwnerCount, sle->getFieldU32(sfOwnerCount) + hookReserve);
|
||||
sb.update(sle);
|
||||
|
||||
auto sle = std::make_shared<SLE>(keylet::hook(accid));
|
||||
sle->setFieldArray(sfHooks, hooks);
|
||||
sle->setAccountID(sfAccount, accid);
|
||||
@@ -744,6 +748,8 @@ Change::activateXahauGenesis()
|
||||
ripple::STArray hooks{sfHooks, 1};
|
||||
STObject hookObj{sfHook};
|
||||
hookObj.setFieldH256(sfHookHash, governHash);
|
||||
|
||||
uint32_t hookReserve = 0;
|
||||
// parameters
|
||||
{
|
||||
std::vector<STObject> vec;
|
||||
@@ -759,6 +765,7 @@ Change::activateXahauGenesis()
|
||||
sfHookParameters, STArray(vec, sfHookParameters));
|
||||
}
|
||||
|
||||
hookReserve += SetHook::computeHookReserve(hookObj);
|
||||
hooks.push_back(hookObj);
|
||||
|
||||
auto sle = std::make_shared<SLE>(hookKL);
|
||||
@@ -785,7 +792,8 @@ Change::activateXahauGenesis()
|
||||
|
||||
sle->setAccountID(sfRegularKey, noAccount());
|
||||
sle->setFieldU32(sfFlags, lsfDisableMaster);
|
||||
sle->setFieldU32(sfOwnerCount, sle->getFieldU32(sfOwnerCount) + 1);
|
||||
sle->setFieldU32(
|
||||
sfOwnerCount, sle->getFieldU32(sfOwnerCount) + hookReserve);
|
||||
sb.update(sle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1173,6 +1173,23 @@ updateHookParameters(
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SetHook::computeHookReserve(STObject const& hookObj)
|
||||
{
|
||||
if (!hookObj.isFieldPresent(sfHookHash))
|
||||
return 0;
|
||||
|
||||
int reserve{1};
|
||||
|
||||
if (hookObj.isFieldPresent(sfHookParameters))
|
||||
reserve += hookObj.getFieldArray(sfHookParameters).size();
|
||||
|
||||
if (hookObj.isFieldPresent(sfHookGrants))
|
||||
reserve += hookObj.getFieldArray(sfHookGrants).size();
|
||||
|
||||
return reserve;
|
||||
};
|
||||
|
||||
struct KeyletComparator
|
||||
{
|
||||
bool
|
||||
@@ -1837,28 +1854,14 @@ SetHook::setHook()
|
||||
int oldHookReserve = 0;
|
||||
int newHookReserve = 0;
|
||||
|
||||
auto const computeHookReserve = [](STObject const& hookObj) -> int {
|
||||
if (!hookObj.isFieldPresent(sfHookHash))
|
||||
return 0;
|
||||
|
||||
int reserve{1};
|
||||
|
||||
if (hookObj.isFieldPresent(sfHookParameters))
|
||||
reserve += hookObj.getFieldArray(sfHookParameters).size();
|
||||
|
||||
if (hookObj.isFieldPresent(sfHookGrants))
|
||||
reserve += hookObj.getFieldArray(sfHookGrants).size();
|
||||
|
||||
return reserve;
|
||||
};
|
||||
|
||||
for (int i = 0; i < hook::maxHookChainLength(); ++i)
|
||||
{
|
||||
if (oldHooks && i < oldHookCount)
|
||||
oldHookReserve += computeHookReserve(((*oldHooks).get())[i]);
|
||||
oldHookReserve +=
|
||||
SetHook::computeHookReserve(((*oldHooks).get())[i]);
|
||||
|
||||
if (i < newHooks.size())
|
||||
newHookReserve += computeHookReserve(newHooks[i]);
|
||||
newHookReserve += SetHook::computeHookReserve(newHooks[i]);
|
||||
}
|
||||
|
||||
reserveDelta = newHookReserve - oldHookReserve;
|
||||
|
||||
@@ -91,6 +91,9 @@ public:
|
||||
static HookSetValidation
|
||||
validateHookSetEntry(SetHookCtx& ctx, STObject const& hookSetObj);
|
||||
|
||||
static uint32_t
|
||||
computeHookReserve(STObject const& hookObj);
|
||||
|
||||
private:
|
||||
TER
|
||||
setHook();
|
||||
|
||||
@@ -484,44 +484,61 @@ OverlayImpl::start()
|
||||
m_peerFinder->setConfig(config);
|
||||
m_peerFinder->start();
|
||||
|
||||
auto addIps = [&](std::vector<std::string> bootstrapIps) -> void {
|
||||
auto addIps = [this](std::vector<std::string> ips, bool fixed) {
|
||||
beast::Journal const& j = app_.journal("Overlay");
|
||||
for (auto& ip : bootstrapIps)
|
||||
for (auto& ip : ips)
|
||||
{
|
||||
std::size_t pos = ip.find('#');
|
||||
if (pos != std::string::npos)
|
||||
ip.erase(pos);
|
||||
|
||||
JLOG(j.trace()) << "Found boostrap IP: " << ip;
|
||||
JLOG(j.trace())
|
||||
<< "Found " << (fixed ? "fixed" : "bootstrap") << " IP: " << ip;
|
||||
}
|
||||
|
||||
m_resolver.resolve(
|
||||
bootstrapIps,
|
||||
[&](std::string const& name,
|
||||
ips,
|
||||
[this, fixed](
|
||||
std::string const& name,
|
||||
std::vector<beast::IP::Endpoint> const& addresses) {
|
||||
std::vector<std::string> ips;
|
||||
ips.reserve(addresses.size());
|
||||
beast::Journal const& j = app_.journal("Overlay");
|
||||
std::string const base("config: ");
|
||||
|
||||
std::vector<beast::IP::Endpoint> eps;
|
||||
eps.reserve(addresses.size());
|
||||
for (auto const& addr : addresses)
|
||||
{
|
||||
std::string addrStr = addr.port() == 0
|
||||
? to_string(addr.at_port(DEFAULT_PEER_PORT))
|
||||
: to_string(addr);
|
||||
JLOG(j.trace()) << "Parsed boostrap IP: " << addrStr;
|
||||
ips.push_back(addrStr);
|
||||
auto ep = addr.port() == 0 ? addr.at_port(DEFAULT_PEER_PORT)
|
||||
: addr;
|
||||
JLOG(j.trace())
|
||||
<< "Parsed " << (fixed ? "fixed" : "bootstrap")
|
||||
<< " IP: " << ep;
|
||||
eps.push_back(ep);
|
||||
}
|
||||
|
||||
std::string const base("config: ");
|
||||
if (!ips.empty())
|
||||
m_peerFinder->addFallbackStrings(base + name, ips);
|
||||
if (eps.empty())
|
||||
return;
|
||||
|
||||
if (fixed)
|
||||
{
|
||||
m_peerFinder->addFixedPeer(base + name, eps);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<std::string> strs;
|
||||
strs.reserve(eps.size());
|
||||
for (auto const& ep : eps)
|
||||
strs.push_back(to_string(ep));
|
||||
m_peerFinder->addFallbackStrings(base + name, strs);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (!app_.config().IPS.empty())
|
||||
addIps(app_.config().IPS);
|
||||
addIps(app_.config().IPS, false);
|
||||
|
||||
if (!app_.config().IPS_FIXED.empty())
|
||||
addIps(app_.config().IPS_FIXED);
|
||||
addIps(app_.config().IPS_FIXED, true);
|
||||
|
||||
auto const timer = std::make_shared<Timer>(*this);
|
||||
std::lock_guard lock(mutex_);
|
||||
|
||||
@@ -139,7 +139,9 @@ struct XahauGenesis_test : public beast::unit_test::suite
|
||||
false, // means the calling test already burned some of the genesis
|
||||
bool skipTests = false,
|
||||
bool const testFlag = false,
|
||||
bool const badNetID = false)
|
||||
bool const badNetID = false,
|
||||
uint32_t const expectedOwnerCount =
|
||||
10 /** testFlag ? 10 : 14 (default) */)
|
||||
{
|
||||
using namespace jtx;
|
||||
|
||||
@@ -247,7 +249,10 @@ struct XahauGenesis_test : public beast::unit_test::suite
|
||||
BEAST_EXPECT(
|
||||
genesisAccRoot->getFieldAmount(sfBalance) ==
|
||||
XahauGenesis::GenesisAmount);
|
||||
BEAST_EXPECT(genesisAccRoot->getFieldU32(sfOwnerCount) == 2);
|
||||
BEAST_EXPECT(
|
||||
genesisAccRoot->getFieldU32(sfOwnerCount) == !testFlag
|
||||
? expectedOwnerCount
|
||||
: 14);
|
||||
|
||||
// ensure the definitions are correctly set
|
||||
{
|
||||
@@ -583,7 +588,14 @@ struct XahauGenesis_test : public beast::unit_test::suite
|
||||
toBase58(t), membersStr);
|
||||
}
|
||||
|
||||
activate(__LINE__, env, true, false, true);
|
||||
activate(
|
||||
__LINE__,
|
||||
env,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
{},
|
||||
3 /* IRR,IRD,IMC */ + members.size() + tables.size());
|
||||
|
||||
env.close();
|
||||
env.close();
|
||||
@@ -2235,6 +2247,8 @@ struct XahauGenesis_test : public beast::unit_test::suite
|
||||
BEAST_EXPECT(!!hookLE);
|
||||
uint256 const ns = beast::zero;
|
||||
uint8_t mc = 0;
|
||||
uint8_t paramsCount = 0;
|
||||
|
||||
if (hookLE)
|
||||
{
|
||||
auto const hooksArray = hookLE->getFieldArray(sfHooks);
|
||||
@@ -2242,6 +2256,9 @@ struct XahauGenesis_test : public beast::unit_test::suite
|
||||
hooksArray.size() == 1 &&
|
||||
hooksArray[0].getFieldH256(sfHookHash) == governHookHash);
|
||||
|
||||
paramsCount =
|
||||
hooksArray[0].getFieldArray(sfHookParameters).size();
|
||||
|
||||
for (Account const* m : members)
|
||||
{
|
||||
auto const mVec = vecFromAcc(*m);
|
||||
@@ -2308,7 +2325,9 @@ struct XahauGenesis_test : public beast::unit_test::suite
|
||||
BEAST_EXPECT(!!root);
|
||||
if (root)
|
||||
{
|
||||
BEAST_EXPECT(root->getFieldU32(sfOwnerCount) == mc * 2 + 2);
|
||||
BEAST_EXPECT(
|
||||
root->getFieldU32(sfOwnerCount) ==
|
||||
mc * 2 + 2 + paramsCount);
|
||||
BEAST_EXPECT(root->getFieldU32(sfFlags) & lsfDisableMaster);
|
||||
BEAST_EXPECT(root->getAccountID(sfRegularKey) == noAccount());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user