Skip to content

Commit

Permalink
Merge pull request #4247 from sisuresh/upgrade-key
Browse files Browse the repository at this point in the history
Define custom cereal override for ConfigUpgradeSetKey and use it

Reviewed-by: dmkozh
  • Loading branch information
latobarita authored Apr 11, 2024
2 parents 962b109 + f3ffbbe commit 2725b15
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/herder/Upgrades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "util/Logging.h"
#include "util/ProtocolVersion.h"
#include "util/Timer.h"
#include "util/XDRCereal.h"
#include "util/types.h"
#include "xdrpp/printer.h"
#include <Tracy.hpp>
Expand All @@ -33,7 +34,6 @@
#include <fmt/format.h>
#include <optional>
#include <regex>
#include <xdrpp/cereal.h>
#include <xdrpp/marshal.h>

namespace cereal
Expand Down Expand Up @@ -393,7 +393,7 @@ Upgrades::toString(LedgerUpgrade const& upgrade)
case LEDGER_UPGRADE_CONFIG:
return fmt::format(
FMT_STRING("{}"),
xdr::xdr_to_string(upgrade.newConfig(), "configupgradesetkey"));
xdr_to_string(upgrade.newConfig(), "configupgradesetkey"));
case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE:
return fmt::format(FMT_STRING("maxsorobantxsetsize={:d}"),
upgrade.newMaxSorobanTxSetSize());
Expand Down Expand Up @@ -436,8 +436,8 @@ Upgrades::toString() const
{
maybePrintUpgradeTime();
r << fmt::format(FMT_STRING(", {}"),
xdr::xdr_to_string(*mParams.mConfigUpgradeSetKey,
"configupgradesetkey"));
xdr_to_string(*mParams.mConfigUpgradeSetKey,
"configupgradesetkey"));
}
return r.str();
}
Expand Down
2 changes: 1 addition & 1 deletion src/herder/test/UpgradesTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3058,7 +3058,7 @@ TEST_CASE("upgrades serialization roundtrip", "[upgrades]")
"configupgradeset" : {
"updatedEntry" : [
{
"configSettingID" : 0,
"configSettingID" : "CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES",
"contractMaxSizeBytes" : 32768
}
]
Expand Down
17 changes: 17 additions & 0 deletions src/util/XDRCereal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ cereal_override(cereal::JSONOutputArchive& ar, const stellar::SCAddress& addr,
}
}

void
cereal_override(cereal::JSONOutputArchive& ar,
const stellar::ConfigUpgradeSetKey& key, const char* field)
{
ar.setNextName(field);
ar.startNode();

xdr::archive(ar,
stellar::strKey::toStrKey(stellar::strKey::STRKEY_CONTRACT,
key.contractID)
.value,
"contractID");
xdr::archive(ar, key.contentHash, "contentHash");

ar.finishNode();
}

void
cereal_override(cereal::JSONOutputArchive& ar,
const stellar::MuxedAccount& muxedAccount, const char* field)
Expand Down
4 changes: 4 additions & 0 deletions src/util/XDRCereal.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ void cereal_override(cereal::JSONOutputArchive& ar, const stellar::PublicKey& s,
void cereal_override(cereal::JSONOutputArchive& ar,
const stellar::SCAddress& addr, const char* field);

void cereal_override(cereal::JSONOutputArchive& ar,
const stellar::ConfigUpgradeSetKey& key,
const char* field);

void cereal_override(cereal::JSONOutputArchive& ar,
const stellar::MuxedAccount& muxedAccount,
const char* field);
Expand Down

0 comments on commit 2725b15

Please sign in to comment.