Skip to content

Commit

Permalink
Kill ChainEntityMeta (#4025)
Browse files Browse the repository at this point in the history
* remove ChainEntityMeta model + routes + messageProcessor

* client side entity meta removal + remaining server references

* chain-events + common-common entity meta removal

* remove entity meta migration CW

* fix types

* remove queued column from ChainEntities CE side

* revert migration create bare-bones ChainEntityMeta table

* Remove threadTitle.

* trigger CI again

* update compound getVotes so it doesn't run out of tokens for tests

* update ganache version to latest

* trigger CI

* trigger CI

* merge master fixes

* remove entity_meta from threads model on client

* remove entity_meta from backend get_bulk_threads

---------

Co-authored-by: Jake Naviasky <jake@commonwealth.im>
Co-authored-by: Muon Shot <120686579+CowMuon@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 14, 2023
1 parent 7c9b93b commit 659d0d6
Show file tree
Hide file tree
Showing 40 changed files with 163 additions and 641 deletions.
2 changes: 1 addition & 1 deletion packages/chain-events/chain-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"web3": "^1.8.2"
},
"optionalDependencies": {
"ganache": "^7.7.6"
"ganache": "^7.9.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,52 @@ export class compoundGovernor implements IGovernor {
let txReceipt;
if (currBalance.lt(tokensNeeded)) {
try {
const binanceWalletAddress =
'0xF977814e90dA44bFA03b6295A0616a897441aceC';
const binanceWalletTokensAvailable = provider.utils.toBN(
await compToken.methods.balanceOf(binanceWalletAddress).call()
);
txReceipt = await compToken.methods
.transfer(accounts, tokensNeeded)
.transfer(accounts, binanceWalletTokensAvailable)
.send({
from: '0xF977814e90dA44bFA03b6295A0616a897441aceC',
gasLimit: 100000,
});
} catch {
txReceipt = await compToken.methods
.transfer(accounts, tokensNeeded)
.send({
from: '0xfA9b5f7fDc8AB34AAf3099889475d47febF830D7',
from: binanceWalletAddress,
gasLimit: 100000,
});
} catch (e) {
console.error('Failed to transfer tokens from binance wallet', e);
}

const newBalance = provider.utils.toBN(
await compToken.methods.balanceOf(accounts).call()
);

if (newBalance.lt(tokensNeeded)) {
try {
const fundWalletAddress =
'0xfA9b5f7fDc8AB34AAf3099889475d47febF830D7';
const fundWalletTokensAvailable = provider.utils.toBN(
await compToken.methods.balanceOf(fundWalletAddress).call()
);
txReceipt = await compToken.methods
.transfer(accounts, fundWalletTokensAvailable)
.send({
from: fundWalletAddress,
gasLimit: 100000,
});
} catch (e) {
console.log('Failed to transfer tokens from fund wallet', e);
}
}
}

const newBalance = provider.utils.toBN(
await compToken.methods.balanceOf(accounts).call()
);
if (newBalance.lt(tokensNeeded)) {
console.error('Not enough tokens in binance and fund wallet');
return;
}

try {
txReceipt = await compToken.methods
.delegate(accounts)
Expand Down
24 changes: 20 additions & 4 deletions packages/chain-events/chain-testing/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@
dependencies:
node-gyp-build "4.4.0"

"@trufflesuite/uws-js-unofficial@20.10.0-unofficial.2":
version "20.10.0-unofficial.2"
resolved "https://registry.yarnpkg.com/@trufflesuite/uws-js-unofficial/-/uws-js-unofficial-20.10.0-unofficial.2.tgz#7ed613ce3260cd5d1773a4d5787a2a106acd1a91"
integrity sha512-oQQlnS3oNeGsgS4K3KCSSavJgSb0W9D5ktZs4FacX9VbM7b+NlhjH96d6/G4fMrz+bc5MXRyco419on0X0dvRA==
dependencies:
ws "8.2.3"
optionalDependencies:
bufferutil "4.0.5"
utf-8-validate "5.0.7"

"@tsconfig/node10@^1.0.7":
version "1.0.9"
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2"
Expand Down Expand Up @@ -1283,12 +1293,13 @@ function-bind@^1.1.1:
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==

ganache@^7.7.6:
version "7.7.7"
resolved "https://registry.yarnpkg.com/ganache/-/ganache-7.7.7.tgz#19939a86799f0bcb7df02e88082944466394b913"
integrity sha512-kZUuOcgDQBtbxzs4iB3chg1iAc28s2ffdOdzyTTzo4vr9sb843w4PbWd5v1hsIqtcNjurcpLaW8XRp/cw2u++g==
ganache@^7.9.0:
version "7.9.0"
resolved "https://registry.yarnpkg.com/ganache/-/ganache-7.9.0.tgz#561deceb376b1c4e8998ac8e5a842574507d3295"
integrity sha512-KdsTZaAKqDXTNDMKnLzg0ngX8wnZKyVGm7HD03GIyUMVRuXI83s0CUEaGIDWRUWTQP7BE8sDh7QtbW+NoX4zrQ==
dependencies:
"@trufflesuite/bigint-buffer" "1.1.10"
"@trufflesuite/uws-js-unofficial" "20.10.0-unofficial.2"
"@types/bn.js" "^5.1.0"
"@types/lru-cache" "5.1.1"
"@types/seedrandom" "3.0.1"
Expand Down Expand Up @@ -2830,6 +2841,11 @@ wrappy@1:
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==

ws@8.2.3:
version "8.2.3"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.2.3.tgz#63a56456db1b04367d0b721a0b80cae6d8becbba"
integrity sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==

ws@^3.0.0:
version "3.3.3"
resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
*/

import { addPrefix, factory } from 'common-common/src/logging';
import type { RmqEntityCUD } from 'common-common/src/rabbitmq/types';
import {
AbstractRabbitMQController,
RascalPublications,
} from 'common-common/src/rabbitmq/types';
import { AbstractRabbitMQController } from 'common-common/src/rabbitmq/types';

import type { DB } from '../../database/database';

Expand Down Expand Up @@ -83,24 +79,6 @@ export default class extends IEventHandler {
completed,
});

const publishData: RmqEntityCUD.RmqMsgType = {
ce_id: dbEntity.id,
chain_id: dbEntity.chain,
author,
entity_type_id: type_id,
cud: 'create',
};

await this._rmqController.safePublish(
publishData,
dbEntity.id,
RascalPublications.ChainEntityCUDMain,
{
sequelize: this._models.sequelize,
model: this._models.ChainEntity,
}
);

if (dbEvent.entity_id !== dbEntity.id) {
dbEvent.entity_id = dbEntity.id;
await dbEvent.save();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn('ChainEntities', 'queued');
},

down: async (queryInterface, Sequelize) => {
await queryInterface.addColumn('ChainEntities', 'queued', {
type: Sequelize.STRING,
defaultValue: 0,
allowNull: false,
});
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export type ChainEntityAttributes = {
chain: string;
type: string;
type_id: string;
queued: number;
author?: string;
completed?: boolean;
created_at?: Date;
Expand Down Expand Up @@ -46,7 +45,6 @@ export default (
author: { type: dataTypes.STRING, allowNull: true },
created_at: { type: dataTypes.DATE, allowNull: false },
updated_at: { type: dataTypes.DATE, allowNull: false },
queued: { type: dataTypes.SMALLINT, allowNull: false, defaultValue: 0 },
},
{
tableName: 'ChainEntities',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,6 @@ describe('Integration tests for Aave', () => {
expect(relatedEntity.id, 'Incorrect entity id').to.equal(
propCreatedEvent.entity_id
);

expect(
rmq.queuedMessages[RascalSubscriptions.ChainEntityCUDMain].length
).to.equal(1);
expect(
rmq.queuedMessages[RascalSubscriptions.ChainEntityCUDMain][0]
).to.deep.equal({
author: relatedEntity.author,
ce_id: relatedEntity.id,
chain_id,
entity_type_id: relatedEntity.type_id,
cud: 'create',
});
});

it('Should process vote cast events', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,19 +243,6 @@ describe('Integration tests for Compound Bravo', () => {
expect(relatedEntity.id, 'Incorrect entity id').to.equal(
propCreatedEvent.entity_id
);

expect(
rmq.queuedMessages[RascalSubscriptions.ChainEntityCUDMain].length
).to.equal(1);
expect(
rmq.queuedMessages[RascalSubscriptions.ChainEntityCUDMain][0]
).to.deep.equal({
author: relatedEntity.author,
ce_id: relatedEntity.id,
chain_id,
entity_type_id: relatedEntity.type_id,
cud: 'create',
});
});

it('Should process vote cast events', async () => {
Expand Down
21 changes: 0 additions & 21 deletions packages/common-common/src/rabbitmq/configuration/rascalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@ export function getAllRascalConfigs(
arguments: queueOptions,
},
},
[RascalQueues.ChainEntityCUDMain]: {
...queueConfig,
options: {
arguments: queueOptions,
},
},
[RascalQueues.ChainEventNotificationsCUDMain]: {
...queueConfig,
options: {
Expand Down Expand Up @@ -162,12 +156,6 @@ export function getAllRascalConfigs(
destinationType: 'queue',
bindingKey: RascalRoutingKeys.ChainEvents,
},
[RascalBindings.ChainEntityCUDMain]: {
source: RascalExchanges.CUD,
destination: RascalQueues.ChainEntityCUDMain,
destinationType: 'queue',
bindingKey: RascalRoutingKeys.ChainEntityCUD,
},
[RascalBindings.ChainEventNotificationsCUD]: {
source: RascalExchanges.CUD,
destination: RascalQueues.ChainEventNotificationsCUDMain,
Expand Down Expand Up @@ -200,11 +188,6 @@ export function getAllRascalConfigs(
routingKey: RascalRoutingKeys.ChainEvents,
...publicationConfig,
},
[RascalPublications.ChainEntityCUDMain]: {
exchange: RascalExchanges.CUD,
routingKey: RascalRoutingKeys.ChainEntityCUD,
...publicationConfig,
},
[RascalPublications.ChainEventNotificationsCUDMain]: {
exchange: RascalExchanges.CUD,
routingKey: RascalRoutingKeys.ChainEventNotificationsCUD,
Expand Down Expand Up @@ -232,10 +215,6 @@ export function getAllRascalConfigs(
queue: RascalQueues.ChainEvents,
...subscriptionConfig,
},
[RascalSubscriptions.ChainEntityCUDMain]: {
queue: RascalQueues.ChainEntityCUDMain,
...subscriptionConfig,
},
[RascalSubscriptions.ChainEventNotificationsCUDMain]: {
queue: RascalQueues.ChainEventNotificationsCUDMain,
...subscriptionConfig,
Expand Down
8 changes: 0 additions & 8 deletions packages/common-common/src/rabbitmq/rabbitMQConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,24 @@ export function getRabbitMQConfig(
RascalExchanges.Discobot,
]);
copyConfigs(allQueues, vhostConfig.queues, [
RascalQueues.ChainEntityCUDMain,
RascalQueues.ChainEventNotificationsCUDMain,
RascalQueues.ChainEventNotifications,
RascalQueues.SnapshotListener,
RascalQueues.DiscordListener,
]);
copyConfigs(allBindings, vhostConfig.bindings, [
RascalBindings.ChainEntityCUDMain,
RascalBindings.ChainEventNotificationsCUD,
RascalBindings.ChainEventNotifications,
RascalBindings.SnapshotListener,
RascalBindings.DiscordListener,
]);
copyConfigs(allPublications, vhostConfig.publications, [
RascalPublications.ChainEntityCUDMain,
RascalPublications.ChainEventNotificationsCUDMain,
RascalPublications.ChainEventNotifications,
RascalPublications.SnapshotListener,
RascalPublications.DiscordListener,
]);
copyConfigs(allSubscriptions, vhostConfig.subscriptions, [
RascalSubscriptions.ChainEntityCUDMain,
RascalSubscriptions.ChainEventNotificationsCUDMain,
RascalSubscriptions.ChainEventNotifications,
RascalSubscriptions.SnapshotListener,
Expand All @@ -105,22 +101,18 @@ export function getRabbitMQConfig(
]);
copyConfigs(allQueues, vhostConfig.queues, [
RascalQueues.ChainEvents,
RascalQueues.ChainEntityCUDMain,
RascalQueues.ChainEventNotificationsCUDMain,
]);
copyConfigs(allBindings, vhostConfig.bindings, [
RascalBindings.ChainEvents,
RascalBindings.ChainEntityCUDMain,
RascalBindings.ChainEventNotificationsCUD,
]);
copyConfigs(allPublications, vhostConfig.publications, [
RascalPublications.ChainEvents,
RascalPublications.ChainEntityCUDMain,
RascalPublications.ChainEventNotificationsCUDMain,
]);
copyConfigs(allSubscriptions, vhostConfig.subscriptions, [
RascalSubscriptions.ChainEvents,
RascalSubscriptions.ChainEntityCUDMain,
RascalSubscriptions.ChainEventNotificationsCUDMain,
]);
} else if (service === RascalConfigServices.SnapshotService) {
Expand Down
43 changes: 0 additions & 43 deletions packages/common-common/src/rabbitmq/types/chainEntityCUD.ts

This file was deleted.

Loading

0 comments on commit 659d0d6

Please sign in to comment.