Skip to content

Commit

Permalink
Merge pull request #241 from tonlabs/0.47.0-rc
Browse files Browse the repository at this point in the history
0.47.0 rc
  • Loading branch information
d3p authored Mar 1, 2022
2 parents 3e9967b + 16f667f commit 8db3d57
Show file tree
Hide file tree
Showing 20 changed files with 745 additions and 257 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to this project will be documented in this file.

## [0.47.0] - 2022-02-28

### New

- Support `X-Evernode-Expected-Account-Boc-Version` header.
`1` (default) means old version, `2` – new.

- Support `boc1` field in accounts collection. `boc` field contains new `2` version,
`boc` contains downgraded to `1` version.

- `account.init_code_hash` – account 's initial code hash (when it was deployed).

## [0.46.0] - 2022-02-17

### New
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ton-q-server",
"version": "0.46.0",
"version": "0.47.0",
"description": "TON Q Server – realtime queries over TON blockchain.",
"main": "index.js",
"repository": "[email protected]:tonlabs/ton-q-server.git",
Expand Down
8 changes: 8 additions & 0 deletions res/type-defs-generated.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,8 @@ type ZerostateAccounts {
"""
due_payment(format: BigIntFormat): String
"account 's initial code hash (when it was deployed)"
init_code_hash: String
"""
Contains either the unixtime of the most recent storage payment
Expand Down Expand Up @@ -973,6 +975,8 @@ type Account {
"""
due_payment(format: BigIntFormat): String
"account 's initial code hash (when it was deployed)"
init_code_hash: String
"""
Contains either the unixtime of the most recent storage payment
Expand Down Expand Up @@ -2211,6 +2215,8 @@ input ZerostateAccountsFilter {
"""
due_payment: StringFilter
"account 's initial code hash (when it was deployed)"
init_code_hash: StringFilter
"""
Contains either the unixtime of the most recent storage payment
Expand Down Expand Up @@ -2361,6 +2367,8 @@ input AccountFilter {
"""
due_payment: StringFilter
"account 's initial code hash (when it was deployed)"
init_code_hash: StringFilter
"""
Contains either the unixtime of the most recent storage payment
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let server: TONQServer | null = null;

beforeAll(async () => {
let serverAddress = process.env.Q_DATA_MUT ?? "http://localhost:8901";

// prepare db
const db = new Database(serverAddress);
try {
Expand All @@ -48,7 +48,7 @@ beforeAll(async () => {
serverAddress = url.toString();

const config = resolveConfig(
{},
{},
{
blockchain: {
blocks: {
Expand Down Expand Up @@ -113,7 +113,7 @@ test("master_seq_no_range", async () => {
}`,
});
expect(queryResult2.data.blockchain.master_seq_no_range).toMatchObject({ start: 8898619, end: 8898622 });

// is limited by reliable boundary
const queryResult3 = await client.query({
query: gql`{
Expand Down Expand Up @@ -336,7 +336,7 @@ test("account_transactions", async () => {
throw new Error("server is null");
}
const client = createTestClient({ useWebSockets: true });

// filter by account_addresses
const queryResult = await client.query({
query: gql`{
Expand Down Expand Up @@ -706,7 +706,7 @@ test("workchain_transactions", async () => {
throw new Error("server is null");
}
const client = createTestClient({ useWebSockets: true });

await testTransactionsPagination(client, "workchain_transactions");

// filter by account_addresses
Expand Down
107 changes: 80 additions & 27 deletions src/__tests__/gen-ql-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import { grantedAccess } from "../server/auth";
import { FilterOrConversion } from "../server/config";
import { QCollectionQuery } from "../server/data/collection-query";
import { overrideAccountBoc } from "../server/graphql/account-boc";

type Blocks = {
blocks: {
Expand All @@ -28,7 +29,8 @@ type Blocks = {
}[]
};
test("remove nulls", async () => {
const data = await testServerQuery<Blocks>("query { blocks { id master { min_shard_gen_utime } } }");
const data = await testServerQuery<Blocks>(
"query { blocks { id master { min_shard_gen_utime } } }");
expect(data.blocks.length).toBeGreaterThan(0);

let block = (await testServerQuery<Blocks>(`
Expand Down Expand Up @@ -108,17 +110,20 @@ test("OR conversions", () => {
const data = createLocalArangoTestData(new QLogs());
const withOr = normalized(
QCollectionQuery.create(
{ expectedAccountBocVersion: 1 },
data.messages.name,
data.messages.docType,
{
filter: {
src: { eq: "1" },
OR: { dst: { eq: "1" } },
},
orderBy: [{
path: "created_at",
direction: "ASC",
}],
orderBy: [
{
path: "created_at",
direction: "ASC",
},
],
},
selectionInfo("src dst"),
grantedAccess,
Expand All @@ -140,17 +145,20 @@ test("OR conversions", () => {

const withSubQueries = normalized(
QCollectionQuery.create(
{ expectedAccountBocVersion: 1 },
data.messages.name,
data.messages.docType,
{
filter: {
src: { eq: "1" },
OR: { dst: { eq: "1" } },
},
orderBy: [{
path: "created_at",
direction: "ASC",
}],
orderBy: [
{
path: "created_at",
direction: "ASC",
},
],
},
selectionInfo("src dst"),
grantedAccess,
Expand Down Expand Up @@ -186,17 +194,20 @@ test("messages_complement are used for shardingDegree > 0", () => {
const data = createLocalArangoTestData(new QLogs());
const withOr = normalized(
QCollectionQuery.create(
{ expectedAccountBocVersion: 1 },
data.messages.name,
data.messages.docType,
{
filter: {
src: { eq: "8:3ffe3593e6098203fd3c061278417770287213bfadd22f448ece73ad0a567d5d" },
OR: { dst: { eq: "-1:3ffe3593e6098203fd3c061278417770287213bfadd22f448ece73ad0a567d5d" } },
},
orderBy: [{
path: "created_at",
direction: "ASC",
}],
orderBy: [
{
path: "created_at",
direction: "ASC",
},
],
},
selectionInfo("src dst"),
grantedAccess,
Expand Down Expand Up @@ -228,17 +239,20 @@ test("messages_complement are used for shardingDegree > 0", () => {

const withSubQueries = normalized(
QCollectionQuery.create(
{ expectedAccountBocVersion: 1 },
data.messages.name,
data.messages.docType,
{
filter: {
src: { eq: "8:3ffe3593e6098203fd3c061278417770287213bfadd22f448ece73ad0a567d5d" },
OR: { dst: { eq: "-1:3ffe3593e6098203fd3c061278417770287213bfadd22f448ece73ad0a567d5d" } },
},
orderBy: [{
path: "created_at",
direction: "ASC",
}],
orderBy: [
{
path: "created_at",
direction: "ASC",
},
],
},
selectionInfo("src dst"),
grantedAccess,
Expand Down Expand Up @@ -289,10 +303,12 @@ test("reduced RETURN", () => {
const transactions = data.transactions;
const messages = data.messages;

expect(queryText(blocks, "seq_no", [{
path: "gen_utime",
direction: "ASC",
}])).toEqual(
expect(queryText(blocks, "seq_no", [
{
path: "gen_utime",
direction: "ASC",
},
])).toEqual(
normalized(`
FOR doc IN blocks SORT doc.gen_utime LIMIT 50 RETURN {
_key: doc._key,
Expand Down Expand Up @@ -375,10 +391,18 @@ function selection(name: string, selections: SelectionNode[]): FieldNode {
}

test("Include join precondition fields", () => {
const e = Message.returnExpressions("doc", selection("message", [
selection("dst_transaction", [selection("id", [])]),
]));
expect(e[0].expression).toEqual("( doc.message && { _key: doc.message._key, msg_type: doc.message.msg_type, dst: doc.message.dst } )");
const e = Message.returnExpressions(
{
expectedAccountBocVersion: 1,
},
"doc",
selection("message", [
selection("dst_transaction", [selection("id", [])]),
]),
);
expect(e[0].expression)
.toEqual(
"( doc.message && { _key: doc.message._key, msg_type: doc.message.msg_type, dst: doc.message.dst } )");
});


Expand Down Expand Up @@ -421,7 +445,8 @@ test("Generate AQL", () => {
},
});
expect(ql)
.toEqual("((doc.gen_utime >= @v1) AND (doc.gen_utime <= @v2)) AND ((@v3 IN doc.signatures[*].node_id) OR (@v4 IN doc.signatures[*].node_id))");
.toEqual(
"((doc.gen_utime >= @v1) AND (doc.gen_utime <= @v2)) AND ((@v3 IN doc.signatures[*].node_id) OR (@v4 IN doc.signatures[*].node_id))");
expect(params.values.v1).toEqual(1);
expect(params.values.v2).toEqual(2);
expect(params.values.v3).toEqual("3");
Expand Down Expand Up @@ -486,9 +511,37 @@ test("Generate AQL", () => {
dst: { eq: "1" },
},
});
expect(ql).toEqual("((doc.src == @v1) AND (doc.dst == @v2)) OR ((doc.src == @v3) AND (doc.dst == @v4))");
expect(ql)
.toEqual(
"((doc.src == @v1) AND (doc.dst == @v2)) OR ((doc.src == @v3) AND (doc.dst == @v4))");
expect(params.values.v1).toEqual("1");
expect(params.values.v2).toEqual("2");
expect(params.values.v3).toEqual("2");
expect(params.values.v4).toEqual("1");
});

test("Account BOC versioning", () => {
overrideAccountBoc();
const e2 = Account.returnExpressions(
{
expectedAccountBocVersion: 2,
},
"doc",
selection("account", [selection("boc", [])]),
);
expect(e2[0].expression)
.toEqual(
"( doc.account && { boc: doc.account.boc } )");
const e1 = Account.returnExpressions(
{
expectedAccountBocVersion: 1,
},
"doc",
selection("account", [selection("boc", [])]),
);
expect(e1[0].expression)
.toEqual(
"( doc.account && { boc: doc.account.boc1 || doc.account.boc } )");
});


Loading

0 comments on commit 8db3d57

Please sign in to comment.