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

[FUN-877] make persisting allowlist compatible with older contract #11907

Merged

Conversation

agparadiso
Copy link
Contributor

Description

This MR complements this previous mr making the persistence of
allowlist backwards compatible with older Tos contracts.

In order to keep an updated list of allowed addresses we need to take into account the blocked addresses. Given on older contracts we don't have a method to fetch these, on each iteration, if we are fetching all the allowed addresses, we purge first all the addresses.

Copy link
Contributor

I see that you haven't updated any CHANGELOG files. Would it make sense to do so?

@agparadiso agparadiso force-pushed the feature/FUN-877_persist_data_fetched_from_contracts_improv branch from 95c0f6f to 98744a8 Compare January 26, 2024 14:14
@@ -219,6 +219,17 @@ func (a *onchainAllowlist) updateFromContractV1(ctx context.Context, blockNum *b
if err != nil {
return errors.Wrap(err, "error calling GetAllAllowedSenders")
}

err = a.orm.PurgeAllowedSenders()
Copy link
Contributor

@justinkaseman justinkaseman Feb 2, 2024

Choose a reason for hiding this comment

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

This step to purge the DB will happen on every sync of the stored allow list right?

What is the performance impact of deleting all and re-adding? Because on the new version of the ToS contract this full purge is not needed.

Can we put the full purge behind vs. only deleting blocked users behind a feature flag? How about using the contract's typeAndVersion instead of a job spec change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this will only happen for the old ToS contracts that will GetAllAllowedSenders.

I like your idea of checking the contract typeAndVersion instead of a job spec change. Also the naming of the feature flag does not make sense now because its storing anyways. thanks will change that

Copy link
Contributor

@justinkaseman justinkaseman left a comment

Choose a reason for hiding this comment

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

Now that this is backwards compatible, can the feature flag in the job spec be removed?

https://github.com/smartcontractkit/chainlink/pull/11648/files#r1462693285

@agparadiso agparadiso force-pushed the feature/FUN-877_persist_data_fetched_from_contracts_improv branch from 0d35bc4 to c8b3eda Compare February 16, 2024 15:59
@agparadiso agparadiso requested a review from a team as a code owner February 16, 2024 15:59
@agparadiso agparadiso force-pushed the feature/FUN-877_persist_data_fetched_from_contracts_improv branch from c8b3eda to 7272a23 Compare February 16, 2024 16:00
@agparadiso agparadiso force-pushed the feature/FUN-877_persist_data_fetched_from_contracts_improv branch from 7272a23 to e120b5f Compare February 16, 2024 16:01
return errors.Wrap(err, "failed to extract version")
}

if version < strings.ReplaceAll(tosContractMinBatchProcessingVersion, ".", "") {
Copy link
Contributor

Choose a reason for hiding this comment

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

I just want to make sure that this string comparision is a safe way to determine version compatability.
Is this actually resiliant in all edge cases? Maybe we should extract this into a helper function such that we can properly unit test it? That would give me more confidence that there are no edge cases that could break this logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure I can extract it and create some unit tests for it 👍🏼

}

var errInvalidVersion = "failed to extract version: version not found in string: invalid_version"
tcs := []tc{
Copy link
Contributor

Choose a reason for hiding this comment

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

What about these test cases?

version1: "v10.1.1",
version2: "v1.11.0",

IIUC, the current logic would say that 1011 < 1110, which is incorrect.
I wonder if there is some existing method somewhere on the internet for dealing with semantic versioning checks like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

➕ thanks for spotting that, I've changed it to use semver

@agparadiso agparadiso force-pushed the feature/FUN-877_persist_data_fetched_from_contracts_improv branch from f4d90f0 to 7ca8b0d Compare February 22, 2024 10:10
@agparadiso agparadiso requested a review from KuphJr February 22, 2024 15:08
@agparadiso agparadiso added this pull request to the merge queue Feb 22, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 22, 2024
@agparadiso agparadiso added this pull request to the merge queue Feb 22, 2024
Merged via the queue into develop with commit 85cc590 Feb 22, 2024
97 checks passed
@agparadiso agparadiso deleted the feature/FUN-877_persist_data_fetched_from_contracts_improv branch February 22, 2024 18:48
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.

3 participants