Skip to content

Commit

Permalink
[FOLD] Simplify configuration:
Browse files Browse the repository at this point in the history
* Make [amendments] do what it's documented as doing
* Remote [unveto_amendments]
  • Loading branch information
ximinez committed Jul 30, 2020
1 parent 365b9de commit a083be1
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 117 deletions.
10 changes: 3 additions & 7 deletions src/ripple/app/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ ApplicationImp::setup()
for (auto const& name : amendments)
{
auto const f = getRegisteredFeature(name);
BOOST_ASSERT(f);
// BOOST_ASSERT(f);
if (f)
hashes.push_back(to_string(*f) + " " + name);
}
Expand All @@ -1355,22 +1355,18 @@ ApplicationImp::setup()
Section const supportedAmendments = buildAmendmentList(
Section("Supported Amendments"), detail::supportedAmendments());

Section const enabledAmendments = config_->section(SECTION_AMENDMENTS);

Section const downVotedAmendments = buildAmendmentList(
config_->section(SECTION_VETO_AMENDMENTS),
detail::downVotedAmendments());

// Up votes override down votes!
Section const upVotedAmendments =
config_->section(SECTION_UNVETO_AMENDMENTS);
Section const upVotedAmendments = config_->section(SECTION_AMENDMENTS);

m_amendmentTable = make_AmendmentTable(
config().AMENDMENT_MAJORITY_TIME,
supportedAmendments,
enabledAmendments,
downVotedAmendments,
upVotedAmendments,
downVotedAmendments,
logs_->journal("Amendments"));
}

Expand Down
5 changes: 3 additions & 2 deletions src/ripple/app/misc/AmendmentTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class AmendmentTable
isEnabled(uint256 const& amendment) const = 0;
virtual bool
isSupported(uint256 const& amendment) const = 0;
virtual bool
isVetoed(uint256 const& amendment) const = 0;

/**
* @brief returns true if one or more amendments on the network
Expand Down Expand Up @@ -167,9 +169,8 @@ std::unique_ptr<AmendmentTable>
make_AmendmentTable(
std::chrono::seconds majorityTime,
Section const& supported,
Section const& enabled,
Section const& desired,
Section const& vetoed,
Section const& unvetoed,
beast::Journal journal);

} // namespace ripple
Expand Down
40 changes: 15 additions & 25 deletions src/ripple/app/misc/impl/AmendmentTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,8 @@ class AmendmentTableImpl final : public AmendmentTable
AmendmentTableImpl(
std::chrono::seconds majorityTime,
Section const& supported,
Section const& enabled,
Section const& desired,
Section const& vetoed,
Section const& unvetoed,
beast::Journal journal);

uint256
Expand All @@ -263,6 +262,8 @@ class AmendmentTableImpl final : public AmendmentTable
isEnabled(uint256 const& amendment) const override;
bool
isSupported(uint256 const& amendment) const override;
virtual bool
isVetoed(uint256 const& amendment) const override;

bool
hasUnsupportedEnabled() const override;
Expand Down Expand Up @@ -304,9 +305,8 @@ class AmendmentTableImpl final : public AmendmentTable
AmendmentTableImpl::AmendmentTableImpl(
std::chrono::seconds majorityTime,
Section const& supported,
Section const& enabled,
Section const& desired,
Section const& vetoed,
Section const& unvetoed,
beast::Journal journal)
: lastUpdateSeq_(0)
, majorityTime_(majorityTime)
Expand All @@ -331,23 +331,6 @@ AmendmentTableImpl::AmendmentTableImpl(
}
}

for (auto const& a : parseSection(enabled))
{
if (auto s = add(a.first, sl))
{
JLOG(j_.debug()) << "Amendment " << a.first << " (" << a.second
<< ") is enabled.";

if (!a.second.empty())
s->name = a.second;
else
s->name = featureToName(a.first);

s->supported = true;
s->enabled = true;
}
}

for (auto const& a : parseSection(vetoed))
{
// Unknown amendments are effectively vetoed already
Expand All @@ -365,7 +348,7 @@ AmendmentTableImpl::AmendmentTableImpl(
}
}

for (auto const& a : parseSection(unvetoed))
for (auto const& a : parseSection(desired))
{
// Overrides and removes the veto that may have been set above (by code
// or config, though it wouldn't make much sense to put both in the
Expand Down Expand Up @@ -493,6 +476,14 @@ AmendmentTableImpl::isSupported(uint256 const& amendment) const
return s && s->supported;
}

bool
AmendmentTableImpl::isVetoed(uint256 const& amendment) const
{
std::lock_guard sl(mutex_);
auto s = get(amendment, sl);
return s && s->vetoed;
}

bool
AmendmentTableImpl::hasUnsupportedEnabled() const
{
Expand Down Expand Up @@ -726,13 +717,12 @@ std::unique_ptr<AmendmentTable>
make_AmendmentTable(
std::chrono::seconds majorityTime,
Section const& supported,
Section const& enabled,
Section const& desired,
Section const& vetoed,
Section const& unvetoed,
beast::Journal journal)
{
return std::make_unique<AmendmentTableImpl>(
majorityTime, supported, enabled, vetoed, unvetoed, journal);
majorityTime, supported, desired, vetoed, journal);
}

} // namespace ripple
1 change: 0 additions & 1 deletion src/ripple/core/ConfigSections.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ struct ConfigSection
#define SECTION_SSL_VERIFY "ssl_verify"
#define SECTION_SSL_VERIFY_FILE "ssl_verify_file"
#define SECTION_SSL_VERIFY_DIR "ssl_verify_dir"
#define SECTION_UNVETO_AMENDMENTS "unveto_amendments"
#define SECTION_VALIDATORS_FILE "validators_file"
#define SECTION_VALIDATION_SEED "validation_seed"
#define SECTION_WEBSOCKET_PING_FREQ "websocket_ping_frequency"
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/protocol/impl/Feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ detail::downVotedAmendments()
// but never vote for the amendment themselves. Additionally, some tests
// will fail if an entry in this list is not in supportedAmendments.
//
// Note that this list can be overridden by the `[unveto_amendments]` config
// Note that this list can be overridden by the `[amendments]` config
// stanza.
//
// For example, if amendment FOO is first complete and released in 2.1, but
Expand All @@ -170,7 +170,7 @@ detail::downVotedAmendments()
// To enable automatically voting for the amendment, simply remove it from
// this list. There should never be a need to comment entries out aside from
// testing.
static std::vector<std::string> const vetoed{};
static std::vector<std::string> const vetoed{"CryptoConditionsSuite"};
return vetoed;
}

Expand Down
Loading

0 comments on commit a083be1

Please sign in to comment.