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

Prod Release 03/11/24 #601

Merged
merged 11 commits into from
Mar 11, 2024
Merged

Prod Release 03/11/24 #601

merged 11 commits into from
Mar 11, 2024

Conversation

darunrs
Copy link
Collaborator

@darunrs darunrs commented Mar 8, 2024

morgsmccauley and others added 11 commits February 26, 2024 09:24
Removes:
- Coordinator V1
- SQS Runner
- Relevant GH actions
added the * filter for contracts.
A valid contract is defined as 

```
function validateContractId(accountId) {
  accountId = accountId.trim();
  
  const isLengthValid = accountId.length >= 2 && accountId.length <= 64;
  if (!isLengthValid) return false; 

  //test if the string starts with a '*.' and remove it if it does
  const isWildCard = WILD_CARD_REGEX.test(accountId);
  isWildCard ? accountId = accountId.slice(2) : null;

  //test if rest of string is valid accounting for/not isWildCard
  const isRegexValid = CONTRACT_NAME_REGEX.test(accountId);
  return isRegexValid;
}

note: early termination for performance
```

The function take in account all **invalid** contract names on
[nomicon](https://nomicon.io/DataStructures/Account)
Please view test for more details.

Regex Broken down Below:

CONTRACT_NAME_REGEX:


`/^(([a-z\d]+[-_])*[a-z\d]+(\.([a-z\d]+[-_])*[a-z\d]+)*\.([a-z\d]+)|([a-z\d]+))$/`

1. **^**: Asserts the start of the string.

2. **(**: Begins a capturing group.
3. **([a-z\d]+[-_])***: Matches a sequence of lowercase letters or
digits, possibly followed by hyphens or underscores. The sequence may
repeat zero or more times.
4. **[a-z\d]+**: Matches a sequence of one or more lowercase letters or
digits.
5. **(\.([a-z\d]+[-_])*[a-z\d]+)***: Allows for zero or more occurrences
of a dot . followed by another sequence.
6. **\.([a-z\d]+)**: Matches a dot followed by a sequence of lowercase
letters or digits.
7. **|**: OR operator.
8. **([a-z\d]+)**: Matches a standalone sequence of lowercase letters or
digits.
9. **)$**: Asserts the end of the string.
WILD_CARD_REGEX:

`/\*\./`
1. **\***: Matches a literal asterisk.
2. **\.**: Matches a literal dot.


EDIT: Added more test please review
Added jest to support function testing.

It seems there's a problem getting Babel and the VM to work smoothly
together. I'm going to dig deeper into it. Right now, I'm adjusting the
test file to recreate the functions instead of using the usual
require/import method, which seems to cause trouble with the VM code. It
does mean there's some duplicated code in the testing files, but the
test work.
Some indexers such as eduohe.near/access_keys potentially exceeds the
timeout of the VM while running. This may be due to latency of DB calls,
which is the heaviest parts of the code. We are planning to drive down
the latency of these calls, but this is a stopgap to allow indexers to
continue running in the mean time.
Looks like the middleware file was pushed on a dev branch and was
ignored when testing for CORS options.
Fix: removed-  frontend/src/pages/middleware.js
out CORS is created from nextjs looking at next.config.js which is a
sibling of package.json
Currently, Runner fetches DB credentials every invocation of runFunction
because provisioning of the user's DB occurs in Runner. As such, we
couldn't be sure if we could fetch credentials for the user's DB from
Hasura or not. The fetch is slow and increases the latency of any
indexers which leverage context.db.

I updated the code to cache the credentials locally after the first
successful fetch. This allows all future requests to succeed as these
credentials will never change after they are set. The changes were aimed
to be minimal as we intend to migrate provisioning out of Runner. In
fact, the changes aid in the effort as the credentials fetch is done
through the Provisioner class rather than separately in DmlHandler.
Fixed the reload button, added unmounting of the grid. 
IMO - we really don't need a library(gridjs) for a logging table with
simple functions as this is the only area we use it as well.
Happy to create an ticket to migrate for a todo in the future.

Otherwise demo here:

https://www.loom.com/share/c35ca732212e48f2ab11d17238f39812
There is no way to add someone as Owner without a migration. 

I've updated the add_user function to accept a role as a parameter,
allowing addition of Owners without migration.
Runner logs excessively, both to the machine, and to postgres. Most of
these logs are not necessary or contain too much information.

The plan is to reduce logs the following ways.

1. Only output failure log for first failure (Instead of every 10
seconds)
2. Stop outputting "Running function on X block" logs to GCP
3. Stop outputting "Success: Ran function on X block" logs to GCP
4. Remove DB logs for hasura calls
5. Remove context.db logging

To support 1, Runner needs a way to know when a failure was the first.
So, it needs to remember the state of the Runner locally. This is a good
opportunity to introduce a refactor to stop setting of Runner status
every loop. We can instead only write when the status changes.

In addition, there is some overlap with this epic. So, to orient these
changes towards our intentions there, I will also introduce a
rudimentary log level into Runner. This value will be INFO by default,
and the extra logs will be at the DEBUG level. This ensures these logs
are automatically skipped while also adding some backbone for expected
future implementation.
Block Streamer was not updating last published block in redis due to a
bug.
Redis memory usage is pegged at 100% due to Block Streamer backfilling *
contract filter indexers.

In addition, Redis implementation of Coordinator and Block Streamer have
diverged. Coordinator is also not able to make successful calls to
Redis. While not a targeted fix, the hope is that merging the
implementation fixes the issue as Block Streamer is able to make calls
to Redis.

Before release, some manual intervention is necessary in dev and prod to
update versions of indexers to the current, to prevent unwanted behavior
from coordinator. I will do dev first, release the change, and then do
prod before a prod release.
@darunrs
Copy link
Collaborator Author

darunrs commented Mar 8, 2024

Requires manual update to ensure versions are correctly set in prod prior to release.

There's a lot of changes in this and since there were a large quantity of bugs present and then fixed in this chunk of code, some care is needed to ensure prod remains in a stable state.

@darunrs darunrs marked this pull request as ready for review March 8, 2024 23:57
@darunrs darunrs requested a review from a team as a code owner March 8, 2024 23:57
@darunrs
Copy link
Collaborator Author

darunrs commented Mar 11, 2024

Versions have been set in prod. We are good to go for prod release. I haven't noticed any odd behavior either.

@darunrs darunrs changed the title Prod Release 03/11/23 Prod Release 03/11/24 Mar 11, 2024
@darunrs darunrs merged commit f029423 into stable Mar 11, 2024
27 checks passed
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