diff --git a/.gitmodules b/.gitmodules index a42ebf3cc6..dbbb68fccd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -184,7 +184,7 @@ path = vendor/nim-ssz-serialization url = https://github.com/status-im/nim-ssz-serialization.git ignore = untracked - branch = master + branch = feat/eip-7495 [submodule "vendor/nim-websock"] path = vendor/nim-websock url = https://github.com/status-im/nim-websock.git diff --git a/AllTests-mainnet.md b/AllTests-mainnet.md index ebdb530e54..4747b7f2e4 100644 --- a/AllTests-mainnet.md +++ b/AllTests-mainnet.md @@ -431,20 +431,22 @@ OK: 2/2 Fail: 0/2 Skip: 0/2 OK: 253/253 Fail: 0/253 Skip: 0/253 ## EF - SSZ generic types ```diff - Testing basic_vector inputs - invalid Skip -+ Testing basic_vector inputs - valid OK -+ Testing bitlist inputs - invalid OK -+ Testing bitlist inputs - valid OK - Testing bitvector inputs - invalid Skip -+ Testing bitvector inputs - valid OK -+ Testing boolean inputs - invalid OK -+ Testing boolean inputs - valid OK -+ Testing containers inputs - invalid - skipping BitsStruct OK -+ Testing containers inputs - valid - skipping BitsStruct OK -+ Testing uints inputs - invalid OK -+ Testing uints inputs - valid OK -``` -OK: 10/12 Fail: 0/12 Skip: 2/12 + Testing basic_vector inputs - invalid Skip ++ Testing basic_vector inputs - valid OK ++ Testing bitlist inputs - invalid OK ++ Testing bitlist inputs - valid OK + Testing bitvector inputs - invalid Skip ++ Testing bitvector inputs - valid OK ++ Testing boolean inputs - invalid OK ++ Testing boolean inputs - valid OK ++ Testing containers inputs - invalid - skipping BitsStruct OK ++ Testing containers inputs - valid - skipping BitsStruct OK ++ Testing profiles inputs - valid OK ++ Testing stablecontainers inputs - valid OK ++ Testing uints inputs - invalid OK ++ Testing uints inputs - valid OK +``` +OK: 12/14 Fail: 0/14 Skip: 2/14 ## EIP-4881 ```diff + deposit_cases OK @@ -1030,4 +1032,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2 OK: 9/9 Fail: 0/9 Skip: 0/9 ---TOTAL--- -OK: 687/692 Fail: 0/692 Skip: 5/692 +OK: 689/694 Fail: 0/694 Skip: 5/694 diff --git a/tests/consensus_spec/test_fixture_ssz_generic_types.nim b/tests/consensus_spec/test_fixture_ssz_generic_types.nim index 57c47fa856..2aa9e10d92 100644 --- a/tests/consensus_spec/test_fixture_ssz_generic_types.nim +++ b/tests/consensus_spec/test_fixture_ssz_generic_types.nim @@ -80,6 +80,132 @@ type D: BitList[6] E: BitArray[8] + # https://github.com/wemeetagain/consensus-specs/blob/eip-7495/tests/generators/ssz_generic/ssz_stablecontainer.py + SingleFieldTestStableStruct {.sszStableContainer: 4.} = object + A: Opt[byte] + + SmallTestStableStruct {.sszStableContainer: 4.} = object + A: Opt[uint16] + B: Opt[uint16] + + FixedTestStableStruct {.sszStableContainer: 4.} = object + A: Opt[uint8] + B: Opt[uint64] + C: Opt[uint32] + + VarTestStableStruct {.sszStableContainer: 4.} = object + A: Opt[uint16] + B: Opt[List[uint16, 1024]] + C: Opt[uint8] + + ComplexTestStableStruct {.sszStableContainer: 8.} = object + A: Opt[uint16] + B: Opt[List[uint16, 128]] + C: Opt[uint8] + D: Opt[List[byte, 256]] + E: Opt[VarTestStableStruct] + F: Opt[array[4, FixedTestStableStruct]] + G: Opt[array[2, VarTestStableStruct]] + + BitsStableStruct {.sszStableContainer: 8.} = object + A: Opt[BitList[5]] + B: Opt[BitArray[2]] + C: Opt[BitArray[1]] + D: Opt[BitList[6]] + E: Opt[BitArray[8]] + + # https://github.com/wemeetagain/consensus-specs/blob/eip-7495/tests/generators/ssz_generic/ssz_profile.py + SingleFieldTestProfile {.sszProfile: SingleFieldTestStableStruct.} = object + A: byte + + SmallTestProfile1 {.sszProfile: SmallTestStableStruct.} = object + A: uint16 + B: uint16 + + SmallTestProfile2 {.sszProfile: SmallTestStableStruct.} = object + A: uint16 + + SmallTestProfile3 {.sszProfile: SmallTestStableStruct.} = object + B: uint16 + + FixedTestProfile1 {.sszProfile: FixedTestStableStruct.} = object + A: uint8 + B: uint64 + C: uint32 + + FixedTestProfile2 {.sszProfile: FixedTestStableStruct.} = object + A: uint8 + B: uint64 + + FixedTestProfile3 {.sszProfile: FixedTestStableStruct.} = object + A: uint8 + C: uint32 + + FixedTestProfile4 {.sszProfile: FixedTestStableStruct.} = object + C: uint32 + + VarTestProfile1 {.sszProfile: VarTestStableStruct.} = object + A: uint16 + B: List[uint16, 1024] + C: uint8 + + VarTestProfile2 {.sszProfile: VarTestStableStruct.} = object + B: List[uint16, 1024] + C: uint8 + + VarTestProfile3 {.sszProfile: VarTestStableStruct.} = object + B: List[uint16, 1024] + + ComplexTestProfile1 {.sszProfile: ComplexTestStableStruct.} = object + A: uint16 + B: List[uint16, 128] + C: uint8 + D: List[byte, 256] + E: VarTestStableStruct + F: array[4, FixedTestStableStruct] + G: array[2, VarTestStableStruct] + + ComplexTestProfile2 {.sszProfile: ComplexTestStableStruct.} = object + A: uint16 + B: List[uint16, 128] + C: uint8 + D: List[byte, 256] + E: VarTestStableStruct + + ComplexTestProfile3 {.sszProfile: ComplexTestStableStruct.} = object + A: uint16 + C: uint8 + E: VarTestStableStruct + G: array[2, VarTestStableStruct] + + ComplexTestProfile4 {.sszProfile: ComplexTestStableStruct.} = object + B: List[uint16, 128] + D: List[byte, 256] + F: array[4, FixedTestStableStruct] + + ComplexTestProfile5 {.sszProfile: ComplexTestStableStruct.} = object + E: VarTestStableStruct + F: array[4, FixedTestStableStruct] + G: array[2, VarTestStableStruct] + + BitsProfile1 {.sszProfile: BitsStableStruct.} = object + A: BitList[5] + B: BitArray[2] + C: BitArray[1] + D: BitList[6] + E: BitArray[8] + + BitsProfile2 {.sszProfile: BitsStableStruct.} = object + A: BitList[5] + B: BitArray[2] + C: BitArray[1] + D: BitList[6] + + BitsProfile3 {.sszProfile: BitsStableStruct.} = object + A: BitList[5] + D: BitList[6] + E: BitArray[8] + # Type specific checks # ------------------------------------------------------------------------ @@ -285,6 +411,71 @@ proc sszCheck( of "BitsStruct": checkBasic(BitsStruct, dir, expectedHash) else: raise newException(ValueError, "unknown container in test: " & sszSubType) + of "profiles": + var name: string + let wasMatched = scanf(sszSubType, "$+_", name) + doAssert wasMatched + case name + of "BitsProfile1": + checkBasic(BitsProfile1, dir, expectedHash) + of "BitsProfile2": + checkBasic(BitsProfile2, dir, expectedHash) + of "BitsProfile3": + checkBasic(BitsProfile3, dir, expectedHash) + of "ComplexTestProfile1": + checkBasic(ComplexTestProfile1, dir, expectedHash) + of "ComplexTestProfile2": + checkBasic(ComplexTestProfile2, dir, expectedHash) + of "ComplexTestProfile3": + checkBasic(ComplexTestProfile3, dir, expectedHash) + of "ComplexTestProfile4": + checkBasic(ComplexTestProfile4, dir, expectedHash) + of "ComplexTestProfile5": + checkBasic(ComplexTestProfile5, dir, expectedHash) + of "FixedTestProfile1": + checkBasic(FixedTestProfile1, dir, expectedHash) + of "FixedTestProfile2": + checkBasic(FixedTestProfile2, dir, expectedHash) + of "FixedTestProfile3": + checkBasic(FixedTestProfile3, dir, expectedHash) + of "FixedTestProfile4": + checkBasic(FixedTestProfile4, dir, expectedHash) + of "SingleFieldTestProfile": + checkBasic(SingleFieldTestProfile, dir, expectedHash) + of "SmallTestProfile1": + checkBasic(SmallTestProfile1, dir, expectedHash) + of "SmallTestProfile2": + checkBasic(SmallTestProfile2, dir, expectedHash) + of "SmallTestProfile3": + checkBasic(SmallTestProfile3, dir, expectedHash) + of "VarTestProfile1": + checkBasic(VarTestProfile1, dir, expectedHash) + of "VarTestProfile2": + checkBasic(VarTestProfile2, dir, expectedHash) + of "VarTestProfile3": + checkBasic(VarTestProfile3, dir, expectedHash) + else: + raise newException(ValueError, "unknown profile in test: " & sszSubType) + of "stablecontainers": + var name: string + let wasMatched = scanf(sszSubType, "$+_", name) + doAssert wasMatched + case name + of "BitsStableStruct": + checkBasic(BitsStableStruct, dir, expectedHash) + of "ComplexTestStableStruct": + checkBasic(ComplexTestStableStruct, dir, expectedHash) + of "FixedTestStableStruct": + checkBasic(FixedTestStableStruct, dir, expectedHash) + of "SingleFieldTestStableStruct": + checkBasic(SingleFieldTestStableStruct, dir, expectedHash) + of "SmallTestStableStruct": + checkBasic(SmallTestStableStruct, dir, expectedHash) + of "VarTestStableStruct": + checkBasic(VarTestStableStruct, dir, expectedHash) + else: + raise newException(ValueError, + "unknown stablecontainer in test: " & sszSubType) else: raise newException(ValueError, "unknown ssz type in test: " & sszType) @@ -306,26 +497,27 @@ suite "EF - SSZ generic types": of "containers": skipped = " - skipping BitsStruct" - test &"Testing {sszType:12} inputs - valid" & skipped: + test &"Testing {sszType:16} inputs - valid" & skipped: let path = SSZDir/sszType/"valid" for pathKind, sszSubType in walkDir( path, relative = true, checkDir = true): if pathKind != pcDir: continue sszCheck(path, sszType, sszSubType) - test &"Testing {sszType:12} inputs - invalid" & skipped: - let path = SSZDir/sszType/"invalid" - for pathKind, sszSubType in walkDir( - path, relative = true, checkDir = true): - if pathKind != pcDir: continue - try: - sszCheck(path, sszType, sszSubType) - except SszError, UnconsumedInput: - discard - except TestSizeError as err: - echo err.msg - skip() - except: - checkpoint getStackTrace(getCurrentException()) - checkpoint getCurrentExceptionMsg() - check false + template invalidPath: untyped = SSZDir/sszType/"invalid" + if os_ops.dirExists(invalidPath): + test &"Testing {sszType:16} inputs - invalid" & skipped: + for pathKind, sszSubType in walkDir( + invalidPath, relative = true, checkDir = true): + if pathKind != pcDir: continue + try: + sszCheck(invalidPath, sszType, sszSubType) + except SszError, UnconsumedInput: + discard + except TestSizeError as err: + echo err.msg + skip() + except: + checkpoint getStackTrace(getCurrentException()) + checkpoint getCurrentExceptionMsg() + check false diff --git a/vendor/nim-ssz-serialization b/vendor/nim-ssz-serialization index 248f2bdca2..695d1c9dbe 160000 --- a/vendor/nim-ssz-serialization +++ b/vendor/nim-ssz-serialization @@ -1 +1 @@ -Subproject commit 248f2bdca2d65ff920920c72b764d0622d522596 +Subproject commit 695d1c9dbec4fa0f746a15df259a19fed49e075e