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/skaled 1583 patch architecture plus 17.2 #1868

Merged
merged 62 commits into from
Apr 17, 2024

Conversation

dimalit
Copy link
Contributor

@dimalit dimalit commented Apr 10, 2024

fixes #1583

Description

  1. "Forks" are now activated by block timestamp, rather than number.
  2. There are DEFINE_XXX_PATCH macros for defining patches.
  3. Timestamps for patches are automatically read from config.
  4. Existing patches use these macros.

Tests

Tests for patches:

  • ContractStorageLimitPatch: storage_limit_reverted
  • ContractStorageZeroValuePatch: tested manually, used in test storage_limit_predeployed
  • RevertableFSPatch: FilestorageCacheSuite)
  • StorageDestructionPatch: tested manually with JsonRpcSuite/simple_contract
  • POWCheckPatch: powTxnGasLimit
  • PushZeroPatch: LegacyVMSuite/InstructionSuite
  • SkipInvalidTransactionsPatch: SkaleHostSuite
  • PrecompiledConfigPatch: PrecompiledTests/getConfigVariable
  • CorrectForkInPowPatch: simplePoWTransaction
  • VerifyDaSigsPatch - need to check manually!

Performance Impact

There can be significant performance impact, as patch activations are evaluated at each block or sometimes even every transaction. Quick testing with stability tests (skale-ci-intergration_tests) showed no significant difference between 3.19.0-develop-latest and 3.19.0-develop.3

Details about changes in code

  1. A lot of functions that needed only blockNumber parameter now need also committedBlockTimestamp.
  2. Removed 'Frontier' fork (it was never used), as well as 'SkaleNNNForkBlock`s for same reson.
  3. EVMSchedule can now be constructed from several patches, and not only taken from pre-defined list as before (ChainOperationParams::evmSchedule)
  4. Some functionality moved from SealEngine to ChainOperationParams, and SealEngine is now unneeded in some places, where ChainOperationParams suffice - for simplification of architecture. Also it's planned to cut out SealEngine completely.
  5. PushZeroPatch uses boolean field in EVMSchedule, and generates new EVMSchedule similar to 'fork blocks'
  6. In libethereum/SchainPatch.h there are new macros for creation of patches.
  7. Almost all old patches now use these macros (see SchainPatch.h)
  8. Latest block timestamp is updated every block for all patches at once - in SchainPatch class.

@dimalit dimalit linked an issue Apr 11, 2024 that may be closed by this pull request
@dimalit dimalit marked this pull request as ready for review April 11, 2024 10:53
kladkogex
kladkogex previously approved these changes Apr 11, 2024
olehnikolaiev
olehnikolaiev previously approved these changes Apr 15, 2024
@@ -91,12 +91,13 @@ std::pair< bool, ExecutionResult > ClientBase::estimateGasStep( int64_t _gas, Bl
t.forceSender( _from );
t.forceChainId( chainId() );
t.ignoreExternalGas();
EnvInfo const env( _latestBlock.info(), bc().lastBlockHashes(), 0, _gas );
EnvInfo const env( _pendingBlock.info(), bc().lastBlockHashes(),
_pendingBlock.previousInfo().timestamp(), 0, _gas );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mb _pendingBlock.previousInfo().timestamp() -> _latestBlock.info().timestamp() would be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same

Comment on lines 120 to 124
int64_t lowerBound = CorrectForkInPowPatch::isEnabledInWorkingBlock() ?
Transaction::baseGasRequired( !_dest, &_data,
bc().sealEngine()->chainParams().makeEvmSchedule(
bc().info().timestamp(), bc().number() ) ) :
Transaction::baseGasRequired( !_dest, &_data, EVMSchedule() );
Copy link
Collaborator

Choose a reason for hiding this comment

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

if/else would be more readable here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Comment on lines 448 to 450
static_cast< const Interface& >( m_client )
.blockInfo( LatestBlock )
.timestamp(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This call could be retrieved and executed before loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👌

@@ -653,7 +654,8 @@ void SkaleHost::createBlock( const ConsensusExtFace::transactions_vector& _appro
// TODO clear occasionally this cache?!
if ( m_m_transaction_cache.find( sha.asArray() ) != m_m_transaction_cache.cend() ) {
Transaction t = m_m_transaction_cache.at( sha.asArray() );
t.checkOutExternalGas( m_client.chainParams(), m_client.number(), true );
t.checkOutExternalGas( m_client.chainParams(),
m_client.blockInfo( LatestBlock ).timestamp(), m_client.number(), true );
Copy link
Collaborator

Choose a reason for hiding this comment

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

m_client.blockInfo( LatestBlock ).timestamp() can be executed before loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@dimalit dimalit linked an issue Apr 16, 2024 that may be closed by this pull request
Copy link
Collaborator

@kladkogex kladkogex left a comment

Choose a reason for hiding this comment

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

Please remove exclamation marks and dead code

@kladkogex kladkogex self-requested a review April 17, 2024 12:23
@dimalit dimalit merged commit 913844f into v3.19.0 Apr 17, 2024
7 checks passed
@dimalit dimalit deleted the enhancement/SKALED-1583-patch-architecture-plus-17.2 branch April 17, 2024 14:45
@github-actions github-actions bot locked and limited conversation to collaborators Apr 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eth_call ignores patches Patch timestamp architecture
4 participants