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

feat: cache / expire uAgent almanac resolutions #198

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

bryanchriswhite
Copy link

@bryanchriswhite bryanchriswhite commented Dec 1, 2022

Changes

  • extract types-cosmos package from subquery-node image for modification
  • add yarn link instructions to README (existing installations MUST catch-up on these steps to continue building)
  • add yarn link steps to CI
  • add types-cosmos package to subquery-node image
  • mount types-cosmos and node-cosmos packages for local development (i.e. changes reflected on container restart)
  • extend types-cosmos Store to include selectRaw member for use in resolution expiration optimization
  • refactor / reorganize contract "structure" pieces

Code Review Checklist (to be filled out by reviewer)

  • Description accurately reflects what changes are being made.
  • Either the PR references an issue (via the "Development" combobox) or the description explains the need for the changes.
  • The PR appropriately sized. (:sweat_smile::see_no_evil:)
  • New code has enough tests.
  • New code has enough documentation to answer "how do I use it?" and "what does it do?".
  • Existing documentation is up-to-date, if impacted.

@bryanchriswhite bryanchriswhite linked an issue Dec 1, 2022 that may be closed by this pull request
@bryanchriswhite bryanchriswhite changed the title chore: cache / expire uAgent almanac resolutions feat: cache / expire uAgent almanac resolutions Dec 1, 2022
@bryanchriswhite bryanchriswhite self-assigned this Dec 5, 2022
@bryanchriswhite bryanchriswhite force-pushed the chore/u-agent-almanac branch 6 times, most recently from 25b5859 to c1d3ff4 Compare December 13, 2022 14:16
Base automatically changed from chore/u-agent-almanac to main December 19, 2022 16:34
@bryanchriswhite bryanchriswhite marked this pull request as ready for review December 22, 2022 16:54
@@ -4,7 +4,7 @@ import {createHash} from "crypto";
import {Attribute} from "@cosmjs/stargate/build/logs";
import {LegacyBridgeSwapStructure} from "./wasm/contracts/bridge";
import {CW20Structure} from "./wasm/contracts/cw20";
import {Structure} from "./wasm/contracts/types";
import {BaseStructure} from "./wasm/contracts/base";
Copy link
Author

Choose a reason for hiding this comment

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

This should've been in d7c166f, my bad.

@@ -31,7 +31,7 @@ export async function checkBalancesAccount(address: string, chainId: string) {
}

export function getJaccardResult(payload: object): Interface {
let prediction = Structure, prediction_coefficient = 0.5; // prediction coefficient can be set as a minimum threshold for the certainty of an output
let prediction = BaseStructure, prediction_coefficient = 0.5; // prediction coefficient can be set as a minimum threshold for the certainty of an output
Copy link
Author

Choose a reason for hiding this comment

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

same ^

@@ -29,7 +33,8 @@ export async function checkBalancesAccount(address: string, chainId: string) {
export function getJaccardResult(payload: object): Interface {
let prediction = Structure, prediction_coefficient = 0.5; // prediction coefficient can be set as a minimum threshold for the certainty of an output
let diff = 0, match = 0, coefficient = 0; // where coefficient of 1 is a perfect property key match, 2 is a perfect match of property and type
const structs = [CW20Structure, LegacyBridgeSwapStructure];
// TODO: refactor
Copy link
Author

Choose a reason for hiding this comment

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

I think it would be more maintainable if we redesigned this a little bit. Perhaps we can add a contract structure registry which this function iterates over (as opposed to a hard-coded list of known structures). Each structure would import the registry and register itself. I suspect that the index (i.e. src/mappings/wasm/contracts) would have to be required (import value ignored) just so that they are included in the build tree (and their registration calls get run, subsequently). Effort may need to be taken to avoid circular dependencies when building and bootstrapping the registry. I think so long as the contract structure index isn't in the same module as the registry we should be good. I would imagine a good place for this import would be in the src/mappings/mappingHandler.ts file instead.

@@ -116,60 +121,6 @@ export async function trackUnprocessed(error: Error, primitives: Primitives): Pr
}
}

class Structure {
Copy link
Author

Choose a reason for hiding this comment

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

This was supposed to be in d7c166f

@@ -2,6 +2,10 @@ import {CosmosBlock, CosmosEvent, CosmosMessage, CosmosTransaction} from "@subql
import {Account, Interface, UnprocessedEntity} from "../types";
import {createHash} from "crypto";
import {Attribute} from "@cosmjs/stargate/build/logs";
import {LegacyBridgeSwapStructure} from "./wasm/contracts/bridge";
import {CW20Structure} from "./wasm/contracts/cw20";
import {Structure} from "./wasm/contracts/types";
Copy link
Author

Choose a reason for hiding this comment

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

Not sure if we actually need this import.

Comment on lines +5 to +6
import {LegacyBridgeSwapStructure} from "./wasm/contracts/bridge";
import {CW20Structure} from "./wasm/contracts/cw20";
Copy link
Author

Choose a reason for hiding this comment

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

This was supposed to be in d7c166f

import {LegacyBridgeSwapStructure} from "./wasm/contracts/bridge";
import {CW20Structure} from "./wasm/contracts/cw20";
import {Structure} from "./wasm/contracts/types";
import {MicroAgentAlmanacStructure} from "./wasm/contracts/almanac";
Copy link
Author

Choose a reason for hiding this comment

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

This was supposed to be in d7c166f

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.

uAgent almanac tracking
1 participant