Make slashing protection import more resilient (#2598)
## Issue Addressed
Closes #2419
## Proposed Changes
Address a long-standing issue with the import of slashing protection data where the import would fail due to the data appearing slashable w.r.t the existing database. Importing is now idempotent, and will have no issues importing data that has been handed back and forth between different validator clients, or different implementations.
The implementation works by updating the high and low watermarks if they need updating, and not attempting to check if the input is slashable w.r.t itself or the database. This is a strengthening of the minification that we started to do by default since #2380, and what Teku has been doing since the beginning.
## Additional Info
The only feature we lose by doing this is the ability to do non-minified imports of clock drifted messages (cf. Prysm on Medalla). In theory, with the previous implementation we could import all the messages in case of clock drift and be aware of the "gap" between the real present time and the messages signed in the far future. _However_ for attestations this is close to useless, as the source epoch will advance as soon as justification occurs, which will require us to make slashable attestations with respect to our bogus attestation(s). E.g. if I sign an attestation 100=>200 when the current epoch is 101, then I won't be able to vote in any epochs prior to 101 becoming justified because 101=>102, 101=>103, etc are all surrounded by 100=>200. Seeing as signing attestations gets blocked almost immediately in this case regardless of our import behaviour, there's no point trying to handle it. For blocks the situation is more hopeful due to the lack of surrounds, but losing block proposals from validators who by definition can't attest doesn't seem like an issue (the other block proposers can pick up the slack).
2021-10-13 01:49:51 +00:00
|
|
|
TESTS_TAG := v5.2.0
|
2020-10-02 01:42:27 +00:00
|
|
|
GENERATE_DIR := generated-tests
|
|
|
|
OUTPUT_DIR := interchange-tests
|
|
|
|
TARBALL := $(OUTPUT_DIR)-$(TESTS_TAG).tar.gz
|
|
|
|
ARCHIVE_URL := https://github.com/eth2-clients/slashing-protection-interchange-tests/tarball/$(TESTS_TAG)
|
|
|
|
|
2021-05-19 23:05:16 +00:00
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
ifeq (, $(shell where rm))
|
|
|
|
rmfile = if exist $(1) (del /F /Q $(1))
|
|
|
|
rmdir = if exist $(1) (rmdir /Q /S $(1))
|
|
|
|
else
|
|
|
|
rmfile = rm -f $(1)
|
|
|
|
rmdir = rm -rf $(1)
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
rmfile = rm -f $(1)
|
|
|
|
rmdir = rm -rf $(1)
|
|
|
|
endif
|
|
|
|
|
2020-10-02 01:42:27 +00:00
|
|
|
$(OUTPUT_DIR): $(TARBALL)
|
2021-05-19 23:05:16 +00:00
|
|
|
$(call rmdir,$@)
|
2020-10-02 01:42:27 +00:00
|
|
|
mkdir $@
|
|
|
|
tar --strip-components=1 -xzf $^ -C $@
|
|
|
|
|
|
|
|
$(TARBALL):
|
2020-12-03 22:07:12 +00:00
|
|
|
curl --fail -L -o $@ $(ARCHIVE_URL)
|
2020-10-02 01:42:27 +00:00
|
|
|
|
|
|
|
clean-test-files:
|
2021-05-19 23:05:16 +00:00
|
|
|
$(call rmdir,$(OUTPUT_DIR))
|
2020-10-02 01:42:27 +00:00
|
|
|
|
|
|
|
clean-archives:
|
2021-05-19 23:05:16 +00:00
|
|
|
$(call rmfile,$(TARBALL))
|
2020-10-02 01:42:27 +00:00
|
|
|
|
|
|
|
generate:
|
2021-05-19 23:05:16 +00:00
|
|
|
$(call rmdir,$(GENERATE_DIR))
|
2020-10-02 01:42:27 +00:00
|
|
|
cargo run --release --bin test_generator -- $(GENERATE_DIR)
|
|
|
|
|
|
|
|
clean: clean-test-files clean-archives
|
|
|
|
|
|
|
|
.PHONY: clean clean-archives clean-test-files generate
|
|
|
|
|