ergoplatform / ergo

Ergo protocol description & reference client implementation
https://ergoplatform.org/
Creative Commons Zero v1.0 Universal
504 stars 170 forks source link

Refine and Document `ErgoGenerators.extensionKvGen()` #2118

Closed stenolog closed 9 months ago

stenolog commented 9 months ago

The sporadic failure of test ErgoStateContextSpec (issue #2114) uncovered problems with ErgoGenerators.extensionKvGen()

Relevant Code

Tasks

kushti commented 9 months ago

There is no problem with generator , for keyspace starting with 0 byte, length of values should be of 4 bytes, otherwise, tests with fail on extension section parsing due to

def parseExtension(h: Height, extension: Extension): Try[Parameters] = Try {
    val paramsTable = extension.fields.flatMap { case (k, v) =>
      require(k.length == 2, s"Wrong key during parameters parsing in extension: $extension")
      if (k(0) == Extension.SystemParametersPrefix && k(1) != SoftForkDisablingRules) {
        require(v.length == 4, s"Wrong value during parameters parsing in extension: $extension")

and there's need to document (in EIP) key spaces and rules for them, not generator