Skip to content

Commit 3107a39

Browse files
feat(platform): keyword search system contract (#2523)
Co-authored-by: Quantum Explorer <[email protected]>
1 parent 88a57ab commit 3107a39

File tree

134 files changed

+4592
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+4592
-241
lines changed

.github/workflows/tests-rs-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ jobs:
195195
uses: ./.github/actions/librocksdb
196196

197197
- name: Run tests
198-
run: cargo test --package=${{ inputs.package }} --all-features --locked
198+
run: RUST_MIN_STACK=16777216 cargo test --package=${{ inputs.package }} --all-features --locked
199199
env:
200200
SCCACHE_S3_KEY_PREFIX: ${{ runner.os }}/sccache/${{ runner.arch }}/linux-gnu
201201
ROCKSDB_STATIC: "/opt/rocksdb/usr/local/lib/librocksdb.a"

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ members = [
2929
"packages/rs-json-schema-compatibility-validator",
3030
"packages/check-features",
3131
"packages/wallet-utils-contract",
32-
"packages/token-history-contract"
32+
"packages/token-history-contract",
33+
"packages/keyword-search-contract"
3334
]
3435

3536
exclude = ["packages/wasm-sdk"] # This one is experimental and not ready for use

Dockerfile

Lines changed: 57 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,25 @@ FROM node:20-alpine${ALPINE_VERSION} AS deps-base
6868
# Install some dependencies
6969
#
7070
RUN apk add --no-cache \
71-
alpine-sdk \
72-
bash \
73-
binutils \
74-
ca-certificates \
75-
clang-static clang-dev \
76-
cmake \
77-
curl \
78-
git \
79-
libc-dev \
80-
linux-headers \
81-
llvm-static llvm-dev \
82-
openssl-dev \
83-
snappy-static snappy-dev \
84-
perl \
85-
python3 \
86-
unzip \
87-
wget \
88-
xz \
89-
zeromq-dev
71+
alpine-sdk \
72+
bash \
73+
binutils \
74+
ca-certificates \
75+
clang-static clang-dev \
76+
cmake \
77+
curl \
78+
git \
79+
libc-dev \
80+
linux-headers \
81+
llvm-static llvm-dev \
82+
openssl-dev \
83+
snappy-static snappy-dev \
84+
perl \
85+
python3 \
86+
unzip \
87+
wget \
88+
xz \
89+
zeromq-dev
9090

9191
# Configure snappy, dependency of librocksdb-sys
9292
RUN <<EOS
@@ -109,10 +109,10 @@ WORKDIR /platform
109109
COPY rust-toolchain.toml .
110110
RUN TOOLCHAIN_VERSION="$(grep channel rust-toolchain.toml | awk '{print $3}' | tr -d '"')" && \
111111
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
112-
--profile minimal \
113-
-y \
114-
--default-toolchain "${TOOLCHAIN_VERSION}" \
115-
--target wasm32-unknown-unknown
112+
--profile minimal \
113+
-y \
114+
--default-toolchain "${TOOLCHAIN_VERSION}" \
115+
--target wasm32-unknown-unknown
116116
117117
ONBUILD ENV HOME=/root
118118
ONBUILD ENV CARGO_HOME=$HOME/.cargo
@@ -145,7 +145,7 @@ EOS
145145
ARG PROTOC_VERSION=27.3
146146
RUN if [[ "$TARGETARCH" == "arm64" ]] ; then export PROTOC_ARCH=aarch_64; else export PROTOC_ARCH=x86_64; fi; \
147147
curl -Ls https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${PROTOC_ARCH}.zip \
148-
-o /tmp/protoc.zip && \
148+
-o /tmp/protoc.zip && \
149149
unzip -qd /opt/protoc /tmp/protoc.zip && \
150150
rm /tmp/protoc.zip && \
151151
ln -s /opt/protoc/bin/protoc /usr/bin/
@@ -180,9 +180,9 @@ ARG SCCHACHE_VERSION=0.8.2
180180
# Install sccache for caching
181181
RUN if [[ "$TARGETARCH" == "arm64" ]] ; then export SCC_ARCH=aarch64; else export SCC_ARCH=x86_64; fi; \
182182
curl -Ls \
183-
https://github.com/mozilla/sccache/releases/download/v$SCCHACHE_VERSION/sccache-v$SCCHACHE_VERSION-${SCC_ARCH}-unknown-linux-musl.tar.gz | \
184-
tar -C /tmp -xz && \
185-
mv /tmp/sccache-*/sccache /usr/bin/
183+
https://github.com/mozilla/sccache/releases/download/v$SCCHACHE_VERSION/sccache-v$SCCHACHE_VERSION-${SCC_ARCH}-unknown-linux-musl.tar.gz | \
184+
tar -C /tmp -xz && \
185+
mv /tmp/sccache-*/sccache /usr/bin/
186186

187187
#
188188
# Configure sccache
@@ -327,11 +327,11 @@ RUN --mount=type=secret,id=AWS \
327327
set -ex; \
328328
source /root/env; \
329329
if [ "$TARGETARCH" = "amd64" ]; then \
330-
CARGO_BINSTALL_ARCH="x86_64-unknown-linux-musl"; \
330+
CARGO_BINSTALL_ARCH="x86_64-unknown-linux-musl"; \
331331
elif [ "$TARGETARCH" = "arm64" ]; then \
332-
CARGO_BINSTALL_ARCH="aarch64-unknown-linux-musl"; \
332+
CARGO_BINSTALL_ARCH="aarch64-unknown-linux-musl"; \
333333
else \
334-
echo "Unsupported architecture: $TARGETARCH"; exit 1; \
334+
echo "Unsupported architecture: $TARGETARCH"; exit 1; \
335335
fi; \
336336
# Construct download URL
337337
DOWNLOAD_URL="https://github.com/cargo-bins/cargo-binstall/releases/download/v${BINSTALL_VERSION}/cargo-binstall-${CARGO_BINSTALL_ARCH}.tgz"; \
@@ -380,6 +380,7 @@ COPY --parents \
380380
packages/dpns-contract \
381381
packages/wallet-utils-contract \
382382
packages/token-history-contract \
383+
packages/keyword-search-contract \
383384
packages/data-contracts \
384385
packages/strategy-tests \
385386
packages/simple-signer \
@@ -421,19 +422,19 @@ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOM
421422
set -ex; \
422423
source /root/env && \
423424
if [[ "${CARGO_BUILD_PROFILE}" == "release" ]] ; then \
424-
mv .cargo/config-release.toml .cargo/config.toml; \
425+
mv .cargo/config-release.toml .cargo/config.toml; \
425426
else \
426-
export FEATURES_FLAG="--features=console,grovedbg"; \
427+
export FEATURES_FLAG="--features=console,grovedbg"; \
427428
fi && \
428429
if [ "${SDK_TEST_DATA}" == "true" ]; then \
429-
mv .cargo/config-test-sdk-data.toml .cargo/config.toml; \
430+
mv .cargo/config-test-sdk-data.toml .cargo/config.toml; \
430431
fi && \
431432
cargo chef cook \
432-
--recipe-path recipe.json \
433-
--profile "$CARGO_BUILD_PROFILE" \
434-
--package drive-abci \
435-
${FEATURES_FLAG} \
436-
--locked && \
433+
--recipe-path recipe.json \
434+
--profile "$CARGO_BUILD_PROFILE" \
435+
--package drive-abci \
436+
${FEATURES_FLAG} \
437+
--locked && \
437438
if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi
438439

439440
COPY --parents \
@@ -455,6 +456,7 @@ COPY --parents \
455456
packages/dashpay-contract \
456457
packages/wallet-utils-contract \
457458
packages/token-history-contract \
459+
packages/keyword-search-contract \
458460
packages/withdrawals-contract \
459461
packages/masternode-reward-shares-contract \
460462
packages/feature-flags-contract \
@@ -483,22 +485,22 @@ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOM
483485
set -ex; \
484486
source /root/env && \
485487
if [[ "${CARGO_BUILD_PROFILE}" == "release" ]] ; then \
486-
mv .cargo/config-release.toml .cargo/config.toml; \
487-
export OUT_DIRECTORY=release; \
488+
mv .cargo/config-release.toml .cargo/config.toml; \
489+
export OUT_DIRECTORY=release; \
488490
else \
489-
export FEATURES_FLAG="--features=console,grovedbg"; \
490-
export OUT_DIRECTORY=debug; \
491+
export FEATURES_FLAG="--features=console,grovedbg"; \
492+
export OUT_DIRECTORY=debug; \
491493
fi && \
492494
if [ "${SDK_TEST_DATA}" == "true" ]; then \
493-
mv .cargo/config-test-sdk-data.toml .cargo/config.toml; \
495+
mv .cargo/config-test-sdk-data.toml .cargo/config.toml; \
494496
fi && \
495497
# Workaround: as we cache dapi-grpc, its build.rs is not rerun, so we need to touch it
496498
echo "// $(date) " >> /platform/packages/dapi-grpc/build.rs && \
497499
cargo build \
498-
--profile "${CARGO_BUILD_PROFILE}" \
499-
--package drive-abci \
500-
${FEATURES_FLAG} \
501-
--locked && \
500+
--profile "${CARGO_BUILD_PROFILE}" \
501+
--package drive-abci \
502+
${FEATURES_FLAG} \
503+
--locked && \
502504
cp target/${OUT_DIRECTORY}/drive-abci /artifacts/ && \
503505
if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi && \
504506
# Remove /platform to reduce layer size
@@ -523,11 +525,11 @@ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOM
523525
source /root/env && \
524526
unset CFLAGS CXXFLAGS && \
525527
cargo chef cook \
526-
--recipe-path recipe.json \
527-
--profile "$CARGO_BUILD_PROFILE" \
528-
--package wasm-dpp \
529-
--target wasm32-unknown-unknown \
530-
--locked && \
528+
--recipe-path recipe.json \
529+
--profile "$CARGO_BUILD_PROFILE" \
530+
--package wasm-dpp \
531+
--target wasm32-unknown-unknown \
532+
--locked && \
531533
if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi
532534

533535

@@ -551,6 +553,7 @@ COPY --parents \
551553
packages/withdrawals-contract \
552554
packages/wallet-utils-contract \
553555
packages/token-history-contract \
556+
packages/keyword-search-contract \
554557
packages/masternode-reward-shares-contract \
555558
packages/feature-flags-contract \
556559
packages/dpns-contract \
@@ -674,6 +677,7 @@ COPY --from=build-dashmate-helper /platform/packages/dapi-grpc packages/dapi-grp
674677
COPY --from=build-dashmate-helper /platform/packages/dash-spv packages/dash-spv
675678
COPY --from=build-dashmate-helper /platform/packages/wallet-utils-contract packages/wallet-utils-contract
676679
COPY --from=build-dashmate-helper /platform/packages/token-history-contract packages/token-history-contract
680+
COPY --from=build-dashmate-helper /platform/packages/keyword-search-contract packages/keyword-search-contract
677681
COPY --from=build-dashmate-helper /platform/packages/withdrawals-contract packages/withdrawals-contract
678682
COPY --from=build-dashmate-helper /platform/packages/masternode-reward-shares-contract packages/masternode-reward-shares-contract
679683
COPY --from=build-dashmate-helper /platform/packages/feature-flags-contract packages/feature-flags-contract
@@ -750,6 +754,7 @@ COPY --from=build-dapi /platform/packages/dapi-grpc /platform/packages/dapi-grpc
750754
COPY --from=build-dapi /platform/packages/js-grpc-common /platform/packages/js-grpc-common
751755
COPY --from=build-dapi /platform/packages/wasm-dpp /platform/packages/wasm-dpp
752756
COPY --from=build-dapi /platform/packages/token-history-contract /platform/packages/token-history-contract
757+
COPY --from=build-dapi /platform/packages/keyword-search-contract /platform/packages/keyword-search-contract
753758

754759
RUN cp /platform/packages/dapi/.env.example /platform/packages/dapi/.env
755760

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"packages/dash-spv",
6868
"packages/wasm-dpp",
6969
"packages/withdrawals-contract",
70-
"packages/token-history-contract"
70+
"packages/token-history-contract",
71+
"packages/search-contract"
7172
],
7273
"resolutions": {
7374
"elliptic": "6.5.7",

packages/data-contracts/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ feature-flags-contract = { path = "../feature-flags-contract" }
1818
platform-value = { path = "../rs-platform-value" }
1919
wallet-utils-contract = { path = "../wallet-utils-contract" }
2020
token-history-contract = { path = "../token-history-contract" }
21+
keyword-search-contract = { path = "../keyword-search-contract" }

packages/data-contracts/src/error.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,20 @@ impl From<token_history_contract::Error> for Error {
136136
}
137137
}
138138
}
139+
140+
impl From<keyword_search_contract::Error> for Error {
141+
fn from(e: keyword_search_contract::Error) -> Self {
142+
match e {
143+
keyword_search_contract::Error::UnknownVersionMismatch {
144+
method,
145+
known_versions,
146+
received,
147+
} => Error::UnknownVersionMismatch {
148+
method,
149+
known_versions,
150+
received,
151+
},
152+
keyword_search_contract::Error::InvalidSchemaJson(e) => Error::InvalidSchemaJson(e),
153+
}
154+
}
155+
}

packages/data-contracts/src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::error::Error;
66
pub use dashpay_contract;
77
pub use dpns_contract;
88
pub use feature_flags_contract;
9+
pub use keyword_search_contract;
910
pub use masternode_reward_shares_contract;
1011
use platform_value::Identifier;
1112
use platform_version::version::PlatformVersion;
@@ -23,6 +24,7 @@ pub enum SystemDataContract {
2324
Dashpay = 4,
2425
WalletUtils = 5,
2526
TokenHistory = 6,
27+
KeywordSearch = 7,
2628
}
2729

2830
pub struct DataContractSource {
@@ -43,6 +45,7 @@ impl SystemDataContract {
4345
SystemDataContract::Dashpay => dashpay_contract::ID_BYTES,
4446
SystemDataContract::WalletUtils => wallet_utils_contract::ID_BYTES,
4547
SystemDataContract::TokenHistory => token_history_contract::ID_BYTES,
48+
SystemDataContract::KeywordSearch => keyword_search_contract::ID_BYTES,
4649
};
4750
Identifier::new(bytes)
4851
}
@@ -98,10 +101,19 @@ impl SystemDataContract {
98101
SystemDataContract::TokenHistory => DataContractSource {
99102
id_bytes: token_history_contract::ID_BYTES,
100103
owner_id_bytes: token_history_contract::OWNER_ID_BYTES,
101-
version: platform_version.system_data_contracts.wallet as u32,
104+
version: platform_version.system_data_contracts.token_history as u32,
102105
definitions: token_history_contract::load_definitions(platform_version)?,
103106
document_schemas: token_history_contract::load_documents_schemas(platform_version)?,
104107
},
108+
SystemDataContract::KeywordSearch => DataContractSource {
109+
id_bytes: keyword_search_contract::ID_BYTES,
110+
owner_id_bytes: keyword_search_contract::OWNER_ID_BYTES,
111+
version: platform_version.system_data_contracts.keyword_search as u32,
112+
definitions: keyword_search_contract::load_definitions(platform_version)?,
113+
document_schemas: keyword_search_contract::load_documents_schemas(
114+
platform_version,
115+
)?,
116+
},
105117
};
106118

107119
Ok(data)
File renamed without changes.

0 commit comments

Comments
 (0)