Skip to content

Commit

Permalink
Merge pull request #9737 from hicommonwealth/release/v1.7.2-x
Browse files Browse the repository at this point in the history
Release/v1.7.2 x
  • Loading branch information
ilijabojanovic authored Oct 31, 2024
2 parents 91d0477 + 0a77791 commit e9a485a
Show file tree
Hide file tree
Showing 2,636 changed files with 17,513 additions and 143,907 deletions.
119 changes: 35 additions & 84 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ jobs:
run: cd packages/commonwealth && ./scripts/detect-broken-ts-expect-error.sh

# These tests run quickly, so run them in a separate job
commonwealth-unit-integration:
name: Commonwealth Unit And Integration Tests
commonwealth-integration-test:
name: Commonwealth Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
Expand Down Expand Up @@ -336,38 +336,13 @@ jobs:
- name: Build
run: pnpm -r build

- name: Run unit tests
run: pnpm -r test -- --allowOnly=false

- name: Change permissions of coverage files
run: |
chmod -R 755 ./libs/adapters/coverage/lcov.info
chmod -R 755 ./libs/core/coverage/lcov.info
chmod -R 755 ./libs/model/coverage/lcov.info
chmod -R 755 ./libs/sitemaps/coverage/lcov.info
chmod -R 755 ./packages/commonwealth/coverage/lcov.info
- name: Coveralls parallel
uses: coverallsapp/github-action@v2
with:
flag-name: unit-test-coverage
parallel: true
files: libs/adapters/coverage/lcov.info libs/core/coverage/lcov.info libs/model/coverage/lcov.info libs/sitemaps/coverage/lcov.info packages/commonwealth/coverage/lcov.info

- name: Run integration tests
run: pnpm -F commonwealth test-integration --allowOnly=false

- name: Coveralls parallel
uses: coverallsapp/github-action@v2
with:
flag-name: integration-test-coverage
parallel: true
files: ./packages/commonwealth/coverage/lcov.info

commonwealth-evm-tests:
name: EVM Devnet Tests
commonwealth-unit-tests:
name: Commonwealth Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 20
strategy:
matrix:
node: [ 20 ]
Expand All @@ -392,30 +367,42 @@ jobs:
image: redis:latest
ports:
- 6379:6379
rabbitmq:
image: rabbitmq:3.11-management
ports:
- 5672:5672
- 15672:15672

steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Run unit tests
run: pnpm -r test -- --allowOnly=false

- name: Run EVM Devnet tests
run: pnpm -F commonwealth test-devnet:evm --allowOnly=false
- name: Change permissions of coverage files
run: |
chmod -R 755 ./libs/adapters/coverage/lcov.info
chmod -R 755 ./libs/core/coverage/lcov.info
chmod -R 755 ./libs/model/coverage/lcov.info
chmod -R 755 ./libs/sitemaps/coverage/lcov.info
chmod -R 755 ./packages/commonwealth/coverage/lcov.info
- name: Coveralls parallel
uses: coverallsapp/github-action@v2
with:
flag-name: evm-devnet-test-coverage
flag-name: unit-test-coverage
parallel: true
files: packages/commonwealth/coverage/lcov.info
files: libs/adapters/coverage/lcov.info libs/core/coverage/lcov.info libs/model/coverage/lcov.info libs/sitemaps/coverage/lcov.info packages/commonwealth/coverage/lcov.info


# These tests run slowly, so run them in a separate job
commonwealth-cosmos-tests:
name: Cosmos Devnet Tests
commonwealth-evm-tests:
name: EVM Devnet Tests
runs-on: ubuntu-latest
timeout-minutes: 25
timeout-minutes: 10
strategy:
matrix:
node: [ 20 ]
Expand All @@ -436,69 +423,34 @@ jobs:
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
cosmos_test_app:
image: mhagel1/csdk-v1
ports:
- 5051:5051
cosmos_beta_test_app:
image: mhagel1/csdk-beta
ports:
- 5050:5050
evmos_test_app:
image: mhagel1/evmos-dev
ports:
- 5052:5052
redis:
image: redis:latest
ports:
- 6379:6379

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}

## Cosmos Section:
# We only run Cosmos devnet tests if any files in the following folders changes
- name: Get changed Cosmos devnet-related files
id: changed-files-specific
uses: tj-actions/changed-files@v35
with:
files: |
packages/commonwealth/test/devnet/cosmos/**/*
packages/commonwealth/server/cosmos-gov-notifications/**/*
packages/commonwealth/test/integration/cosmosGovNotifGenerator.spec.ts
packages/commonwealth/server/util/cosmosProxy.ts
packages/commonwealth/client/scripts/controllers/chain/cosmos/gov/**/*
packages/commonwealth/test/util/cosmos-chain-testing/**/*
libs/chains/src/cosmos-ts/**/*
- name: Run following steps if any file(s) in the Cosmos folders change
if: steps.changed-files-specific.outputs.all_changed_files
run: |
echo "One or more Cosmos Devnet-related files has changed."
echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run Cosmos Devnet tests
if: steps.changed-files-specific.outputs.any_changed == 'true'
run: |
pnpm -F commonwealth start &
(pnpm -F commonwealth wait-server && pnpm -F commonwealth test-devnet:cosmos --allowOnly=false)
- name: Run EVM Devnet tests
run: pnpm -F commonwealth test-devnet:evm --allowOnly=false

- name: Coveralls parallel
if: steps.changed-files-specific.outputs.all_changed_files
uses: coverallsapp/github-action@v2
with:
flag-name: cosmos-devnet-test-coverage
flag-name: evm-devnet-test-coverage
parallel: true
files: packages/commonwealth/coverage/lcov.info

report-coverage:
name: Upload Test Coverage Report
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [ commonwealth-cosmos-tests, commonwealth-evm-tests, commonwealth-unit-integration, e2e-tests-serial, e2e-tests-Parallel, e2e-tests-Mature ]
needs: [ commonwealth-evm-tests, commonwealth-unit-tests ]
if: always()
strategy:
matrix:
Expand All @@ -508,5 +460,4 @@ jobs:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: "cosmos-devnet-test-coverage"
parallel-finished: true
4 changes: 2 additions & 2 deletions common_knowledge/Caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ _"There are only two hard things in Computer Science: cache invalidation and nam
- Choosing a right TTL could be very important, as app data is highly transactional

- **Caching Namespace:**
- Global - eg. /api/viewGlobalActivity
- User Specific - eg. /api/viewUserActivity or /api/status
- Global - eg. /api/internal/trpc/feed.GetGlobalActivity
- User Specific - eg. /api/internal/trpc/feed.GetUserActivity or /api/status

- **Hybrid Request Handler** -> Fetch followed by tracking of user activity
eg. get chain data & record current chain selected by user - these kind of request handler can only utilize sequelize result caching
Expand Down
71 changes: 71 additions & 0 deletions common_knowledge/Farcaster-Contests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Farcaster Local Development

Tags: #cw

## Create a Farcaster account

First, sign up for a Farcaster account. Warpcast is a Farcaster client that allows you to create an account. It works on mobile and browser.

- Sign up at https://warpcast.com/

## Setup ngrok

ngrok is a reverse proxy that allows you to create a publicly accessible URL that sends traffic to your local machine, in order to test webhooks locally.

- Log into https://dashboard.ngrok.com (create free personal account)
- Go to `Domains` -> `New Domain` to generate a free static domain
- Use this command to run ngrok:
- `ngrok http --url=YOUR_NGROK_DOMAIN 8080`
- ⭐️ Save as shell alias or local bash script since you’ll need to run this later and often

## Setup Neynar webhook

Neynar is a 3rd party API used for creating Farcaster webhooks and fetching data from the Farcaster network.

- Log into https://dev.neynar.com (should be added to Dillon’s team)
- Create new webhook for the CastCreated event (each dev must have their own webhook)
- Name: `Cast Created (YOUR_NAME)`
- TargetURL: `https://YOUR_NGROK_DOMAIN/api/integration/farcaster/CastCreated`
- Set filter: `cast.created` -> `embeds` -> `contests`

## Set local env vars

Add these env vars to your .env file. Fill in the API key (ask a dev) and your own ngrok domain:

```
FLAG_FARCASTER_CONTEST=true
NEYNAR_API_KEY=
NEYNAR_REPLY_WEBHOOK_URL=https://YOUR_NGROK_DOMAIN/api/integration/farcaster/ReplyCastCreated
FARCASTER_ACTION_URL=https://YOUR_NGROK_DOMAIN/api/integration/farcaster/CastUpvoteAction
```

The `ALLOWED_EVENTS` env var contains a comma-seperated list of outbox events. Add these to the list:

`FarcasterCastCreated,FarcasterReplyCastCreated,FarcasterVoteCreated`

## Run local services

Run services required for testing contests:

- Chain listener: `pnpm start-evm-ce`
- Message relayer: `pnpm start-message-relayer`
- Consumer: `pnpm start-consumer`
- App: `pnpm start`

Also ensure that ngrok is running. Don't copy-paste the command from the ngrok website– use the aforementioned script.

## Add the Upvote cast action

Farcaster allows users to add a custom “action” to their account, which can be used on any cast. An action can be added to your account through a special URL.
- Add your FARCASTER_ACTION_URL (from .env) to the end of this warpcast URL: `https://warpcast.com/~/add-cast-action?actionType=post&name=Upvote+Content&icon=thumbsup&postUrl=FARCASTER_ACTION_URL`
- Paste URL into browser, you’ll see the Warpcast page, then click `Add Action`

## How to test the Farcaster/Contests integration
- For testing, you can use any contest that has an associated Topic.
- First, post a farcaster contest URL on Warpcast. It has this format: `https://YOUR_DOMAIN/api/integration/farcaster/contests/CONTEST_ADDRESS/contestCard`
- Fill in your ngrok domain and contest address
- Upon posting, it should trigger the `CastCreated` webhook and associate the Cast (message) with the contest. It’ll also create a new programatic webhook for `CastReplyCreated`.
- Then, add a reply message to the contest cast.
- This should trigger the `CastReplyCreated` webhook, which will create onchain content.
- Finally, perform the custom Upvote action on your reply message (icon with 4 squares).
- This should trigger the `CastUpvoteAction` webhook, which ultimately creates an onchain vote.
2 changes: 1 addition & 1 deletion common_knowledge/Performance-Benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ _See also full [Datadog](./Datadog.md) entry._

We've implemented two new performance dashboards to monitor and track improvements in latency and call volume over time.

These dashboards serve a key role in prioritizing improvements by highlighting high call volume and slow endpoints. They are instrumental in monitoring the effect of improvements over time, as shown by specific examples corresponding to PRs like `getAddressProfile` larger batches and performance enhancements in backend API calls such as `/viewUserActivity` and `/status`. Additionally, they can effectively detect abnormal spikes in latency and call volume through real-time metrics reported to Datadog.
These dashboards serve a key role in prioritizing improvements by highlighting high call volume and slow endpoints. They are instrumental in monitoring the effect of improvements over time, as shown by specific examples corresponding to PRs like `getAddressProfile` larger batches and performance enhancements in backend API calls such as `/feed.GetUserActivity` and `/status`. Additionally, they can effectively detect abnormal spikes in latency and call volume through real-time metrics reported to Datadog.

## Change Log

Expand Down
2 changes: 1 addition & 1 deletion libs/adapters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@aws-sdk/s3-request-presigner": "^3.577.0",
"@hicommonwealth/core": "workspace:*",
"@hicommonwealth/shared": "workspace:*",
"@knocklabs/node": "^0.6.10",
"@knocklabs/node": "^0.6.13",
"@trpc/server": "^10.45.1",
"amqplib": "^0.10.3",
"async-rwlock": "^1.1.1",
Expand Down
4 changes: 1 addition & 3 deletions libs/adapters/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,7 @@ export const config = configure(
})
.refine(
(data) => {
if (
!['local', 'CI', 'discobot', 'snapshot'].includes(target.APP_ENV)
) {
if (!['local', 'CI'].includes(target.APP_ENV)) {
return (
!!LOAD_TESTING_AUTH_TOKEN &&
data.AUTH_TOKEN !== DEFAULTS.LOAD_TESTING_AUTH_TOKEN
Expand Down
20 changes: 20 additions & 0 deletions libs/adapters/src/rabbitmq/configuration/rascalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ export function getAllRascalConfigs(
arguments: queueOptions,
},
},
[RascalQueues.FarcasterWorkerPolicy]: {
...queueConfig,
options: {
arguments: queueOptions,
},
},
};

const allBindings: Record<keyof OmittedRascalBindings, BindingConfig> = {
Expand Down Expand Up @@ -197,6 +203,16 @@ export function getAllRascalConfigs(
RascalRoutingKeys.ContestProjectionContestContentUpvoted,
],
},
[RascalBindings.FarcasterWorkerPolicy]: {
source: RascalExchanges.MessageRelayer,
destination: RascalQueues.FarcasterWorkerPolicy,
destinationType: 'queue',
bindingKeys: [
RascalRoutingKeys.FarcasterWorkerPolicyCastCreated,
RascalRoutingKeys.FarcasterWorkerPolicyReplyCastCreated,
RascalRoutingKeys.FarcasterWorkerPolicyVoteCreated,
],
},
};

const allPublications: Record<RascalPublications, PublicationConfig> = {
Expand All @@ -223,6 +239,10 @@ export function getAllRascalConfigs(
queue: RascalQueues.ContestProjection,
...subscriptionConfig,
},
[RascalSubscriptions.FarcasterWorkerPolicy]: {
queue: RascalQueues.FarcasterWorkerPolicy,
...subscriptionConfig,
},
[RascalSubscriptions.DiscordBotPolicy]: {
queue: RascalQueues.DiscordBotPolicy,
...subscriptionConfig,
Expand Down
3 changes: 3 additions & 0 deletions libs/adapters/src/rabbitmq/rabbitMQConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function getRabbitMQConfig(
RascalQueues.NotificationsSettings,
RascalQueues.ContestWorkerPolicy,
RascalQueues.ContestProjection,
RascalQueues.FarcasterWorkerPolicy,
RascalQueues.DiscordBotPolicy,
]);
copyConfigs(allBindings, vhostConfig.bindings, [
Expand All @@ -82,6 +83,7 @@ export function getRabbitMQConfig(
RascalBindings.NotificationsSettings,
RascalBindings.ContestWorkerPolicy,
RascalBindings.ContestProjection,
RascalBindings.FarcasterWorkerPolicy,
RascalBindings.DiscordBotPolicy,
]);
copyConfigs(allPublications, vhostConfig.publications, [
Expand All @@ -93,6 +95,7 @@ export function getRabbitMQConfig(
RascalSubscriptions.NotificationsSettings,
RascalSubscriptions.ContestWorkerPolicy,
RascalSubscriptions.ContestProjection,
RascalSubscriptions.FarcasterWorkerPolicy,
RascalSubscriptions.DiscordBotPolicy,
]);
}
Expand Down
Loading

0 comments on commit e9a485a

Please sign in to comment.