Skip to content

Commit

Permalink
Correct contract version for protocol contracts for block V13+
Browse files Browse the repository at this point in the history
The contract version for V13+ is 3 and the legacy handler is not supposed
to be used.
  • Loading branch information
jamescowens committed Dec 16, 2024
1 parent 6c47db9 commit e2f925b
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2432,14 +2432,32 @@ UniValue addkey(const UniValue& params, bool fHelp)
break;
}
case GRC::ContractType::PROTOCOL:
// There will be no legacy payload contracts past version 2. This will need to be changed before the
// block v13 mandatory (which also means contract v3).
contract = GRC::MakeLegacyContract(
type.Value(),
action,
params[2].get_str(), // key
params[3].get_str()); // value
{
if (block_v13_enabled) {
GRC::ProtocolEntryStatus status = GRC::ProtocolEntryStatus::UNKNOWN;

if (action == GRC::ContractAction::ADD) {
status = GRC::ProtocolEntryStatus::ACTIVE;
} else if (action == GRC::ContractAction::REMOVE) {
status = GRC::ProtocolEntryStatus::DELETED;
}

contract = GRC::MakeContract<GRC::ProtocolEntryPayload>(
contract_version,
action,
uint32_t {2}, // Contract payload version number
params[2].get_str(), // key
params[3].get_str(), // value
status);
} else {
contract = GRC::MakeLegacyContract(
type.Value(),
action,
params[2].get_str(), // key
params[3].get_str()); // value
}
break;
}
case GRC::ContractType::SIDESTAKE:
{
if (block_v13_enabled) {
Expand Down

0 comments on commit e2f925b

Please sign in to comment.