Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/2004 add patch timestamp debug api #2077

Open
wants to merge 9 commits into
base: v4.0.0
Choose a base branch
from

Conversation

PropzSaladaz
Copy link

@PropzSaladaz PropzSaladaz commented Jan 15, 2025

Description

  • Added new RPC debug function that returns all patchTimestamps
  • Only callable when debug API is enabled

Example call:

curl -X POST --data '{"jsonrpc":"2.0","method":"debug_getPatchTimestamps","params":null,"id":1205}' <http_endpoint>

Example response:

{"id":1205,"jsonrpc":"2.0","result":{"contractStoragePatchTimestamp":1681732800,"contractStorageZeroValuePatchTimestamp":1681128000,"correctForkInPowPatchTimestamp":1710331200,"eIP1559TransactionsPatchTimestamp":1721818800,"externalGasPatchTimestamp":1727712000,"fastConsensusPatchTimestamp":1721822400,"flexibleDeploymentPatchTimestamp":1721826000,"powCheckPatchTimestamp":1702296000,"precompiledConfigPatchTimestamp":1710331200,"pushZeroPatchTimestamp":1710331200,"revertableFSPatchTimestamp":1681473600,"selfdestructStorageLimitPatchTimestamp":0,"skipInvalidTransactionsPatchTimestamp":1702382400,"storageDestructionPatchTimestamp":1702393200,"verifyBlsSyncPatchTimestamp":1721829600,"verifyDaSigsPatchTimestamp":1681300800}}

Tests

  • debugGetPatchTimestamps
    • Compares the output of RPC call to the timestamps defined in the config file.

Fixes #2004

@DmytroNazarenko DmytroNazarenko added this to the SKALE 4.0 milestone Jan 16, 2025
@olehnikolaiev olehnikolaiev linked an issue Jan 22, 2025 that may be closed by this pull request
Comment on lines +29 to +30
else if ( _patchName == "SelfdestructStorageLimitPatch" )
return SchainPatchEnum::SelfdestructStorageLimitPatch;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this patch?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was missing in the original code. We had the SchainPatchEnum::SelfdestructStorageLimitPatch enum variant defined, but not the convertion from its string value to the enum variant in this function (which converts a string to the corresponding SchainPatchEnum variant. So I added the missing conversion.

Comment on lines 2798 to 2810
std::vector< int > patchTimestamps;

// Set custom config file & create timestamps for each patch
size_t numPatches = static_cast< size_t >( SchainPatchEnum::PatchesCount );
for (size_t patch = 0; patch < numPatches ; patch++ ) {
SchainPatchEnum patchEnum = static_cast< SchainPatchEnum >( patch );
int ts = patch + 1000; // just to offset from the default values (0, 1)
patchTimestamps.push_back(ts);

std::string patchName = getPatchNameForEnum(patchEnum) + "Timestamp";
patchName[0] = tolower( patchName[0] );
configJson["skaleConfig"]["sChain"][patchName] = ts;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use time_t type instead of int, as patchTimestamps are time_t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add debug API to check PatchTimestamp activation
3 participants