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

rm unused code #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

rm unused code #96

wants to merge 1 commit into from

Conversation

tersec
Copy link
Contributor

@tersec tersec commented Sep 30, 2024

To start with, it doesn't work right now:

import ssz_serialization
echo SSZ.supports(uint64)   # is false

in Nim 2.0.8 prints false, for example.

status-im/nimbus-eth2#6573 (comment) has more context -- essentially compiles( ... declval ...) behaves a bit oddly at times.

Nothing either in nim-ssz-serialization or nimbus-eth2 uses it, either.

If people truly want this functionality, it can be reintroduced and reviewed as new code in a separate PR, but it's more important to remove the broken dependent on questionable assumptions which vary depending on all three of (NimMajor, NimMinor, NimPatch).

@tersec
Copy link
Contributor Author

tersec commented Sep 30, 2024

Ah, it is used, by the test suite (which apparently doesn't catch this, or runs in other ways) via nim-serialization:

NimScript] exec: nim c  --styleCheck:usages --styleCheck:error --verbosity:0 --hints:off --skipParentCfg --skipUserCfg --outdir:build '--nimcache:build/nimcache/$projectName'  --mm:refc --threads:on -d:PREFER_BLST_SHA256=false -d:PREFER_HASHTREE_SHA256=false --mm:refc -r tests/test_all
/Users/runner/work/nim-ssz-serialization/nim-ssz-serialization/tests/test_ssz_roundtrip.nim(14, 1) template/generic instantiation of `executeRoundtripTests` from here
/Users/runner/.nimble/pkgs2/serialization-0.2.2-7d65be9aa3c3249957ee779435e7093367ad719d/serialization/testing/generic_suite.nim(197, 8) template/generic instantiation of `suite` from here
/Users/runner/.nimble/pkgs2/serialization-0.2.2-7d65be9aa3c3249957ee779435e7093367ad719d/serialization/testing/generic_suite.nim(198, 5) template/generic instantiation of `test` from here
/Users/runner/.nimble/pkgs2/unittest2-0.2.2-6ac7f7ea74df812a25be5d6d36a59d23789eb508/unittest2.nim(1127, 24) template/generic instantiation of `failingOnExceptions` from here
/Users/runner/.nimble/pkgs2/unittest2-0.2.2-6ac7f7ea74df812a25be5d6d36a59d23789eb508/unittest2.nim(1131, 26) template/generic instantiation of `failingOnExceptions` from here
/Users/runner/.nimble/pkgs2/serialization-0.2.2-7d65be9aa3c3249957ee779435e7093367ad719d/serialization/testing/generic_suite.nim(205, 7) template/generic instantiation of `intTests` from here
/Users/runner/.nimble/pkgs2/serialization-0.2.2-7d65be9aa3c3249957ee779435e7093367ad719d/serialization/testing/generic_suite.nim(200, 9) template/generic instantiation of `roundtrip` from here
/Users/runner/.nimble/pkgs2/serialization-0.2.2-7d65be9aa3c3249957ee779435e7093367ad719d/serialization/testing/generic_suite.nim(194, 18) Error: type mismatch
Expression: supports(Format, typeof(low(int8)))
  [1] Format: typedesc[SSZ]
  [2] typeof(low(int8)): typedesc[int8]

Expected one of (first mismatch at [position]):
[1] template supports(_: type Json; T: type): bool

@tersec tersec closed this Sep 30, 2024
@tersec tersec deleted the nnt branch September 30, 2024 01:13
@tersec tersec restored the nnt branch September 30, 2024 04:26
@tersec tersec reopened this Sep 30, 2024
@tersec
Copy link
Contributor Author

tersec commented Sep 30, 2024

Well, it doesn't actually work anyway, because when this error hits, that supports(Format, type(val)) is returning false, so it's never executing these checks:

diff --git a/serialization/testing/generic_suite.nim b/serialization/testing/generic_suite.nim
index 5f6df0a..3206f64 100644
--- a/serialization/testing/generic_suite.nim
+++ b/serialization/testing/generic_suite.nim
@@ -192,6 +192,7 @@ proc executeRoundtripTests*(Format: type) =
     # If this doesn't work reliably, it will fail too silently.
     # We need to report the number of checks passed.
     when supports(Format, type(val)):
+      static: doAssert false
       roundtripChecks(Format, val)
 
   suite(name(Format) & " generic roundtrip tests"):
SSZ generic roundtrip tests ....... (0.00s)
[Summary] 7 tests run (0.00s): 7 OK, 0 FAILED, 0 SKIPPED

so it silently looks like it works, but doesn't, because of this failing supports

For nim-json-serialization, it does work, in a manner of speaking:

template supports*(_: type Json, T: type): bool =
  # The JSON format should support every type
  true

But it's also a no-op of a call.

And that appears to be 100% of the codebase usage of this particular mixin. One broken, one vacuous.

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.

1 participant