Skip to content

feat(platform): keyword search system contract #2523

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

Merged
merged 49 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
516c7e0
feat: keyword search system contract
pauldelucia Apr 2, 2025
65a4b61
local network builds, deserialization of st fails
pauldelucia Apr 2, 2025
dc74e5a
fix
pauldelucia Apr 2, 2025
a636eee
fix: search contract base58 id
pauldelucia Apr 2, 2025
485df31
fix non unique document id
pauldelucia Apr 2, 2025
10ec7fd
add back byKeyword index
pauldelucia Apr 2, 2025
0ace4f9
enforce max keywords in document meta schema
pauldelucia Apr 2, 2025
cff2d75
remove token keywords from schema
pauldelucia Apr 2, 2025
206872f
validation is working
pauldelucia Apr 3, 2025
c9af4a6
validation works
pauldelucia Apr 3, 2025
a20035c
more validation
pauldelucia Apr 3, 2025
e5804c1
more tests
pauldelucia Apr 3, 2025
5778b4f
fix tests for extra storage cost for empty keywords
pauldelucia Apr 3, 2025
7f47870
fix error enum ordering
pauldelucia Apr 4, 2025
a9f9135
add test for search contract creation restriction
pauldelucia Apr 4, 2025
c9e9112
fix tests
pauldelucia Apr 4, 2025
cf84d78
fix tests
pauldelucia Apr 4, 2025
ec80ce1
fix
pauldelucia Apr 4, 2025
935f32b
generate test vectors and fix sdk test data yarn start
pauldelucia Apr 4, 2025
6e17051
feat: contract descriptions (#2533)
pauldelucia Apr 9, 2025
2a542a0
fix: create genesis state error
pauldelucia Apr 9, 2025
d994cef
fix: remove ascii requirement for contract keywords
pauldelucia Apr 10, 2025
043a719
update DataContractV1 description with description field
pauldelucia Apr 10, 2025
0382954
handle keywords and descriptions in contract update
pauldelucia Apr 10, 2025
ae56437
rename to v1
pauldelucia Apr 10, 2025
830d892
add validation for update
pauldelucia Apr 11, 2025
74522c0
add unit tests for validate_update
pauldelucia Apr 11, 2025
97d2889
fix: remove dist timestamp validation for contract updates
pauldelucia Apr 11, 2025
272ef8a
fix version
pauldelucia Apr 11, 2025
8547e49
remove unused imports
pauldelucia Apr 11, 2025
8d25e07
function descriptions
pauldelucia Apr 11, 2025
bc28170
rename to keyword search contract
pauldelucia Apr 11, 2025
e400323
fix rename
pauldelucia Apr 11, 2025
d3daebd
fmt and yarn install
pauldelucia Apr 11, 2025
7c644b3
add tests
pauldelucia Apr 11, 2025
4317713
optimize keyword update
pauldelucia Apr 11, 2025
ef6fd85
better
pauldelucia Apr 12, 2025
3c0c471
fix linting
pauldelucia Apr 12, 2025
22bdc0a
Merge branch 'v2.0-dev' into feat/token-search-contract
pauldelucia Apr 14, 2025
5df68e3
fix fee in test
pauldelucia Apr 14, 2025
599c9bf
Merge branch 'v2.0-dev' into feat/token-search-contract
pauldelucia Apr 15, 2025
334dc74
increase stack size
pauldelucia Apr 16, 2025
ff48d37
Merge branch 'v2.0-dev' into feat/token-search-contract
QuantumExplorer Apr 16, 2025
89259ac
fix(platform): sam's fixes for token search (#2551)
QuantumExplorer Apr 17, 2025
723829d
fmt
QuantumExplorer Apr 17, 2025
55d1b96
clippy
QuantumExplorer Apr 17, 2025
2cd268f
clean up;
QuantumExplorer Apr 17, 2025
4ecaafd
another fix
QuantumExplorer Apr 17, 2025
e7f52fe
fixed revision
QuantumExplorer Apr 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests-rs-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ jobs:
uses: ./.github/actions/librocksdb

- name: Run tests
run: cargo test --package=${{ inputs.package }} --all-features --locked
run: RUST_MIN_STACK=16777216 cargo test --package=${{ inputs.package }} --all-features --locked
env:
SCCACHE_S3_KEY_PREFIX: ${{ runner.os }}/sccache/${{ runner.arch }}/linux-gnu
ROCKSDB_STATIC: "/opt/rocksdb/usr/local/lib/librocksdb.a"
Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ members = [
"packages/rs-json-schema-compatibility-validator",
"packages/check-features",
"packages/wallet-utils-contract",
"packages/token-history-contract"
"packages/token-history-contract",
"packages/keyword-search-contract"
]

exclude = ["packages/wasm-sdk"] # This one is experimental and not ready for use
Expand Down
109 changes: 57 additions & 52 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,25 @@ FROM node:20-alpine${ALPINE_VERSION} AS deps-base
# Install some dependencies
#
RUN apk add --no-cache \
alpine-sdk \
bash \
binutils \
ca-certificates \
clang-static clang-dev \
cmake \
curl \
git \
libc-dev \
linux-headers \
llvm-static llvm-dev \
openssl-dev \
snappy-static snappy-dev \
perl \
python3 \
unzip \
wget \
xz \
zeromq-dev
alpine-sdk \
bash \
binutils \
ca-certificates \
clang-static clang-dev \
cmake \
curl \
git \
libc-dev \
linux-headers \
llvm-static llvm-dev \
openssl-dev \
snappy-static snappy-dev \
perl \
python3 \
unzip \
wget \
xz \
zeromq-dev

# Configure snappy, dependency of librocksdb-sys
RUN <<EOS
Expand All @@ -109,10 +109,10 @@ WORKDIR /platform
COPY rust-toolchain.toml .
RUN TOOLCHAIN_VERSION="$(grep channel rust-toolchain.toml | awk '{print $3}' | tr -d '"')" && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
--profile minimal \
-y \
--default-toolchain "${TOOLCHAIN_VERSION}" \
--target wasm32-unknown-unknown
--profile minimal \
-y \
--default-toolchain "${TOOLCHAIN_VERSION}" \
--target wasm32-unknown-unknown

ONBUILD ENV HOME=/root
ONBUILD ENV CARGO_HOME=$HOME/.cargo
Expand Down Expand Up @@ -145,7 +145,7 @@ EOS
ARG PROTOC_VERSION=27.3
RUN if [[ "$TARGETARCH" == "arm64" ]] ; then export PROTOC_ARCH=aarch_64; else export PROTOC_ARCH=x86_64; fi; \
curl -Ls https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${PROTOC_ARCH}.zip \
-o /tmp/protoc.zip && \
-o /tmp/protoc.zip && \
unzip -qd /opt/protoc /tmp/protoc.zip && \
rm /tmp/protoc.zip && \
ln -s /opt/protoc/bin/protoc /usr/bin/
Expand Down Expand Up @@ -180,9 +180,9 @@ ARG SCCHACHE_VERSION=0.8.2
# Install sccache for caching
RUN if [[ "$TARGETARCH" == "arm64" ]] ; then export SCC_ARCH=aarch64; else export SCC_ARCH=x86_64; fi; \
curl -Ls \
https://github.com/mozilla/sccache/releases/download/v$SCCHACHE_VERSION/sccache-v$SCCHACHE_VERSION-${SCC_ARCH}-unknown-linux-musl.tar.gz | \
tar -C /tmp -xz && \
mv /tmp/sccache-*/sccache /usr/bin/
https://github.com/mozilla/sccache/releases/download/v$SCCHACHE_VERSION/sccache-v$SCCHACHE_VERSION-${SCC_ARCH}-unknown-linux-musl.tar.gz | \
tar -C /tmp -xz && \
mv /tmp/sccache-*/sccache /usr/bin/

#
# Configure sccache
Expand Down Expand Up @@ -327,11 +327,11 @@ RUN --mount=type=secret,id=AWS \
set -ex; \
source /root/env; \
if [ "$TARGETARCH" = "amd64" ]; then \
CARGO_BINSTALL_ARCH="x86_64-unknown-linux-musl"; \
CARGO_BINSTALL_ARCH="x86_64-unknown-linux-musl"; \
elif [ "$TARGETARCH" = "arm64" ]; then \
CARGO_BINSTALL_ARCH="aarch64-unknown-linux-musl"; \
CARGO_BINSTALL_ARCH="aarch64-unknown-linux-musl"; \
else \
echo "Unsupported architecture: $TARGETARCH"; exit 1; \
echo "Unsupported architecture: $TARGETARCH"; exit 1; \
fi; \
# Construct download URL
DOWNLOAD_URL="https://github.com/cargo-bins/cargo-binstall/releases/download/v${BINSTALL_VERSION}/cargo-binstall-${CARGO_BINSTALL_ARCH}.tgz"; \
Expand Down Expand Up @@ -380,6 +380,7 @@ COPY --parents \
packages/dpns-contract \
packages/wallet-utils-contract \
packages/token-history-contract \
packages/keyword-search-contract \
packages/data-contracts \
packages/strategy-tests \
packages/simple-signer \
Expand Down Expand Up @@ -421,19 +422,19 @@ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOM
set -ex; \
source /root/env && \
if [[ "${CARGO_BUILD_PROFILE}" == "release" ]] ; then \
mv .cargo/config-release.toml .cargo/config.toml; \
mv .cargo/config-release.toml .cargo/config.toml; \
else \
export FEATURES_FLAG="--features=console,grovedbg"; \
export FEATURES_FLAG="--features=console,grovedbg"; \
fi && \
if [ "${SDK_TEST_DATA}" == "true" ]; then \
mv .cargo/config-test-sdk-data.toml .cargo/config.toml; \
mv .cargo/config-test-sdk-data.toml .cargo/config.toml; \
fi && \
cargo chef cook \
--recipe-path recipe.json \
--profile "$CARGO_BUILD_PROFILE" \
--package drive-abci \
${FEATURES_FLAG} \
--locked && \
--recipe-path recipe.json \
--profile "$CARGO_BUILD_PROFILE" \
--package drive-abci \
${FEATURES_FLAG} \
--locked && \
if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi

COPY --parents \
Expand All @@ -455,6 +456,7 @@ COPY --parents \
packages/dashpay-contract \
packages/wallet-utils-contract \
packages/token-history-contract \
packages/keyword-search-contract \
packages/withdrawals-contract \
packages/masternode-reward-shares-contract \
packages/feature-flags-contract \
Expand Down Expand Up @@ -483,22 +485,22 @@ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOM
set -ex; \
source /root/env && \
if [[ "${CARGO_BUILD_PROFILE}" == "release" ]] ; then \
mv .cargo/config-release.toml .cargo/config.toml; \
export OUT_DIRECTORY=release; \
mv .cargo/config-release.toml .cargo/config.toml; \
export OUT_DIRECTORY=release; \
else \
export FEATURES_FLAG="--features=console,grovedbg"; \
export OUT_DIRECTORY=debug; \
export FEATURES_FLAG="--features=console,grovedbg"; \
export OUT_DIRECTORY=debug; \
fi && \
if [ "${SDK_TEST_DATA}" == "true" ]; then \
mv .cargo/config-test-sdk-data.toml .cargo/config.toml; \
mv .cargo/config-test-sdk-data.toml .cargo/config.toml; \
fi && \
# Workaround: as we cache dapi-grpc, its build.rs is not rerun, so we need to touch it
echo "// $(date) " >> /platform/packages/dapi-grpc/build.rs && \
cargo build \
--profile "${CARGO_BUILD_PROFILE}" \
--package drive-abci \
${FEATURES_FLAG} \
--locked && \
--profile "${CARGO_BUILD_PROFILE}" \
--package drive-abci \
${FEATURES_FLAG} \
--locked && \
cp target/${OUT_DIRECTORY}/drive-abci /artifacts/ && \
if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi && \
# Remove /platform to reduce layer size
Expand All @@ -523,11 +525,11 @@ RUN --mount=type=cache,sharing=shared,id=cargo_registry_index,target=${CARGO_HOM
source /root/env && \
unset CFLAGS CXXFLAGS && \
cargo chef cook \
--recipe-path recipe.json \
--profile "$CARGO_BUILD_PROFILE" \
--package wasm-dpp \
--target wasm32-unknown-unknown \
--locked && \
--recipe-path recipe.json \
--profile "$CARGO_BUILD_PROFILE" \
--package wasm-dpp \
--target wasm32-unknown-unknown \
--locked && \
if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi


Expand All @@ -551,6 +553,7 @@ COPY --parents \
packages/withdrawals-contract \
packages/wallet-utils-contract \
packages/token-history-contract \
packages/keyword-search-contract \
packages/masternode-reward-shares-contract \
packages/feature-flags-contract \
packages/dpns-contract \
Expand Down Expand Up @@ -674,6 +677,7 @@ COPY --from=build-dashmate-helper /platform/packages/dapi-grpc packages/dapi-grp
COPY --from=build-dashmate-helper /platform/packages/dash-spv packages/dash-spv
COPY --from=build-dashmate-helper /platform/packages/wallet-utils-contract packages/wallet-utils-contract
COPY --from=build-dashmate-helper /platform/packages/token-history-contract packages/token-history-contract
COPY --from=build-dashmate-helper /platform/packages/keyword-search-contract packages/keyword-search-contract
COPY --from=build-dashmate-helper /platform/packages/withdrawals-contract packages/withdrawals-contract
COPY --from=build-dashmate-helper /platform/packages/masternode-reward-shares-contract packages/masternode-reward-shares-contract
COPY --from=build-dashmate-helper /platform/packages/feature-flags-contract packages/feature-flags-contract
Expand Down Expand Up @@ -750,6 +754,7 @@ COPY --from=build-dapi /platform/packages/dapi-grpc /platform/packages/dapi-grpc
COPY --from=build-dapi /platform/packages/js-grpc-common /platform/packages/js-grpc-common
COPY --from=build-dapi /platform/packages/wasm-dpp /platform/packages/wasm-dpp
COPY --from=build-dapi /platform/packages/token-history-contract /platform/packages/token-history-contract
COPY --from=build-dapi /platform/packages/keyword-search-contract /platform/packages/keyword-search-contract

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

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"packages/dash-spv",
"packages/wasm-dpp",
"packages/withdrawals-contract",
"packages/token-history-contract"
"packages/token-history-contract",
"packages/search-contract"
],
"resolutions": {
"elliptic": "6.5.7",
Expand Down
1 change: 1 addition & 0 deletions packages/data-contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ feature-flags-contract = { path = "../feature-flags-contract" }
platform-value = { path = "../rs-platform-value" }
wallet-utils-contract = { path = "../wallet-utils-contract" }
token-history-contract = { path = "../token-history-contract" }
keyword-search-contract = { path = "../keyword-search-contract" }
17 changes: 17 additions & 0 deletions packages/data-contracts/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,20 @@ impl From<token_history_contract::Error> for Error {
}
}
}

impl From<keyword_search_contract::Error> for Error {
fn from(e: keyword_search_contract::Error) -> Self {
match e {
keyword_search_contract::Error::UnknownVersionMismatch {
method,
known_versions,
received,
} => Error::UnknownVersionMismatch {
method,
known_versions,
received,
},
keyword_search_contract::Error::InvalidSchemaJson(e) => Error::InvalidSchemaJson(e),
}
}
}
14 changes: 13 additions & 1 deletion packages/data-contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::error::Error;
pub use dashpay_contract;
pub use dpns_contract;
pub use feature_flags_contract;
pub use keyword_search_contract;
pub use masternode_reward_shares_contract;
use platform_value::Identifier;
use platform_version::version::PlatformVersion;
Expand All @@ -23,6 +24,7 @@ pub enum SystemDataContract {
Dashpay = 4,
WalletUtils = 5,
TokenHistory = 6,
KeywordSearch = 7,
}

pub struct DataContractSource {
Expand All @@ -43,6 +45,7 @@ impl SystemDataContract {
SystemDataContract::Dashpay => dashpay_contract::ID_BYTES,
SystemDataContract::WalletUtils => wallet_utils_contract::ID_BYTES,
SystemDataContract::TokenHistory => token_history_contract::ID_BYTES,
SystemDataContract::KeywordSearch => keyword_search_contract::ID_BYTES,
};
Identifier::new(bytes)
}
Expand Down Expand Up @@ -98,10 +101,19 @@ impl SystemDataContract {
SystemDataContract::TokenHistory => DataContractSource {
id_bytes: token_history_contract::ID_BYTES,
owner_id_bytes: token_history_contract::OWNER_ID_BYTES,
version: platform_version.system_data_contracts.wallet as u32,
version: platform_version.system_data_contracts.token_history as u32,
definitions: token_history_contract::load_definitions(platform_version)?,
document_schemas: token_history_contract::load_documents_schemas(platform_version)?,
},
SystemDataContract::KeywordSearch => DataContractSource {
id_bytes: keyword_search_contract::ID_BYTES,
owner_id_bytes: keyword_search_contract::OWNER_ID_BYTES,
version: platform_version.system_data_contracts.keyword_search as u32,
definitions: keyword_search_contract::load_definitions(platform_version)?,
document_schemas: keyword_search_contract::load_documents_schemas(
platform_version,
)?,
},
};

Ok(data)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "search-contract"
description = "Search data contract schema and tools. Search contract is using to find other contracts and tokens"
name = "keyword-search-contract"
description = "Search data contract schema and tools. Keyword Search contract is used to find other contracts and tokens"
version = "2.0.0-dev.1"
edition = "2021"
rust-version.workspace = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
ownerId: '11111111111111111111111111111111',
contractId: '8v8CoKCDdBcQu1Y7GDNJjR7a5vkMmgpXycJURkaUhfU9',
contractId: '7CSFGeF4WNzgDmx94zwvHkYaG3Dx4XEe5LFsFgJswLbm',
};
Loading