Skip to content

Commit

Permalink
Merge branch 'v1.4-dev' into feat/withdrawalLimits
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer authored Sep 29, 2024
2 parents 385b78f + 8b847ea commit f5c07d2
Show file tree
Hide file tree
Showing 53 changed files with 1,319 additions and 143 deletions.
59 changes: 59 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Use the official VS Code base image for dev containers
FROM mcr.microsoft.com/devcontainers/base:ubuntu

# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libssl-dev \
pkg-config \
clang \
cmake \
llvm \
curl \
gnupg \
lsb-release \
software-properties-common \
unzip

# Switch to clang
RUN rm /usr/bin/cc && ln -s /usr/bin/clang /usr/bin/cc

# Install protoc - protobuf compiler
# The one shipped with Alpine does not work
ARG TARGETARCH
ARG PROTOC_VERSION=25.2
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 && \
unzip -qd /opt/protoc /tmp/protoc.zip && \
rm /tmp/protoc.zip && \
ln -s /opt/protoc/bin/protoc /usr/bin/

# Install protoc v25.2+
RUN curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v25.2/protoc-25.2-linux-x86_64.zip \
&& unzip protoc-25.2-linux-x86_64.zip -d /usr/local \
&& rm protoc-25.2-linux-x86_64.zip

# Switch to vscode user
USER vscode

ENV CARGO_HOME=/home/vscode/.cargo
ENV PATH=$CARGO_HOME/bin:$PATH

# TODO: It doesn't sharing PATH between stages, so we need "source $HOME/.cargo/env" everywhere
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
# Install wasm-bindgen-cli in the same profile as other components, to sacrifice some performance & disk space to gain
# better build caching
RUN if [[ -z "${SCCACHE_MEMCACHED}" ]] ; then unset SCCACHE_MEMCACHED ; fi ; \
RUSTFLAGS="-C target-feature=-crt-static" \
# Meanwhile if you want to update wasm-bindgen you also need to update version in:
# - packages/wasm-dpp/Cargo.toml
# - packages/wasm-dpp/scripts/build-wasm.sh
cargo install [email protected] --locked
73 changes: 73 additions & 0 deletions .devcontainer/devcontainer-build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"name": "Dash Platform Dev Container",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"arcanis.vscode-zipfs",
"chrmarti.regex",
"davidanson.vscode-markdownlint",
"ms-vscode.cmake-tools",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"vadimcn.vscode-lldb",
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"zhangyue.rust-mod-generator",
"ms-azuretools.vscode-docker"
]
}
},
"remoteUser": "vscode",
"mounts": [
{
"source": "devcontainer-platform-cargo-registry-index-${devcontainerId}",
"target": "/home/vscode/.cargo/registry",
"type": "volume"
},
{
"source": "devcontainer-platform-cargo-registry-cache-${devcontainerId}",
"target": "/home/vscode/.cargo/registry/cache",
"type": "volume"
},
{
"source": "devcontainer-platform-cargo-git-db-${devcontainerId}",
"target": "/home/vscode/.cargo/git/db",
"type": "volume"
},
{
"source": "devcontainer-platform-target-${devcontainerId}",
"target": "${containerWorkspaceFolder}/target",
"type": "volume"
}
],
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": "true"
},
"ghcr.io/devcontainers/features/git:1": {
"version": "latest",
"ppa": "false"
},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/node:1": {
"version": 20,
"installYarnUsingApt": false
},
"ghcr.io/eitsupi/devcontainer-features/jq-likes:2": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/schlich/devcontainer-features/starship:0": {},
},
"postCreateCommand": {
"git-safe": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"cargo-permissions": "sudo chown -R vscode:vscode /home/vscode/.cargo ${containerWorkspaceFolder}/target"
}
}
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Dash Platform Dev Container",
"image": "ghcr.io/dashpay/platform/devcontainer:0.1.0"
}
58 changes: 58 additions & 0 deletions .github/workflows/prebuild-devcontainers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Prebuild Dev Containers

on:
push:
paths:
- '.devcontainer/**'
- '.github/workflows/prebuild-devcontainers.yml'
- rust-toolchain.toml
- Dockerfile
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and push devcontainer
runs-on: ["self-hosted", "linux", "x64", "ubuntu-platform"]
timeout-minutes: 60
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Node.JS
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install skopeo
run: |
sudo apt-get update
sudo apt-get install -y skopeo
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
with:
use: true

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: dashpay
password: ${{ secrets.GHCR_TOKEN }}

- name: Build and push Platform devcontainer
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/dashpay/platform/devcontainer
imageTag: 0.1.0
platform: linux/amd64,linux/arm64
configFile: .devcontainer/devcontainer-build.json
push: always
cacheFrom: ghcr.io/dashpay/platform/devcontainer
Binary file removed .yarn/cache/fsevents-patch-19706e7e35-10.zip
Binary file not shown.
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
## [1.4.0-dev.1](https://github.com/dashpay/platform/compare/v1.3.0...v1.4.0-dev.1) (2024-09-27)


### ⚠ BREAKING CHANGES

* **sdk:** change default network to mainnet (#2161)
* **dashmate:** confirm a node reset (#2160)
* **platform:** withdrawals polishing and fixes for mainnet (#2166)
* **platform:** do not switch to oldest quorums in validator set update (#2167)

### Features

* **dashmate:** confirm a node reset ([#2160](https://github.com/dashpay/platform/issues/2160))
* **platform:** do not switch to oldest quorums in validator set update ([#2167](https://github.com/dashpay/platform/issues/2167))
* **platform:** get current quorum info ([#2168](https://github.com/dashpay/platform/issues/2168))
* **platform:** withdrawals polishing and fixes for mainnet ([#2166](https://github.com/dashpay/platform/issues/2166))
* **sdk:** change default network to mainnet ([#2161](https://github.com/dashpay/platform/issues/2161))


### Bug Fixes

* **dapi:** getStatus cache invalidation ([#2155](https://github.com/dashpay/platform/issues/2155))
* **dapi:** invalid mainnet seed ports ([#2173](https://github.com/dashpay/platform/issues/2173))
* **dashmate:** cannot read properties of undefined (reading 'expires') ([#2164](https://github.com/dashpay/platform/issues/2164))
* **dashmate:** colors[updated] is not a function ([#2157](https://github.com/dashpay/platform/issues/2157))
* **dashmate:** doctor fails collecting to big logs ([#2158](https://github.com/dashpay/platform/issues/2158))
* **dashmate:** port marks as closed if ipv6 is not disabled ([#2162](https://github.com/dashpay/platform/issues/2162))
* **dashmate:** remove confusing short flag name ([#2165](https://github.com/dashpay/platform/issues/2165))


### Continuous integration

* build dashmate package on macos14


### Documentation

* **dashmate:** document logging configuration ([#2156](https://github.com/dashpay/platform/issues/2156))


### Tests

* **dashmate:** e2e tests failing due to DKG interval check ([#2171](https://github.com/dashpay/platform/issues/2171))


### Miscellaneous Chores

* **dashmate:** do not call mint on masternodes ([#2172](https://github.com/dashpay/platform/issues/2172))
* **platform:** protocol version 4 creation ([#2153](https://github.com/dashpay/platform/issues/2153))


## [1.3.0](https://github.com/dashpay/platform/compare/v1.2.0...v1.3.0) (2024-09-19)

### Features
Expand Down
9 changes: 7 additions & 2 deletions packages/dapi-grpc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
// Derive features for versioned messages
//
// "GetConsensusParamsRequest" is excluded as this message does not support proofs
const VERSIONED_REQUESTS: [&str; 29] = [
const VERSIONED_REQUESTS: [&str; 30] = [
"GetDataContractHistoryRequest",
"GetDataContractRequest",
"GetDataContractsRequest",
Expand Down Expand Up @@ -77,9 +77,13 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
"GetTotalCreditsInPlatformRequest",
"GetEvonodesProposedEpochBlocksByIdsRequest",
"GetEvonodesProposedEpochBlocksByRangeRequest",
"GetStatusRequest",
];

// "GetConsensusParamsResponse" is excluded as this message does not support proofs
// The following responses are excluded as they don't support proofs:
// - "GetConsensusParamsResponse"
// - "GetStatusResponse"
//
// "GetEvonodesProposedEpochBlocksResponse" is used for 2 Requests
const VERSIONED_RESPONSES: [&str; 29] = [
"GetDataContractHistoryResponse",
Expand Down Expand Up @@ -213,6 +217,7 @@ impl MappingConfig {
///
/// * `protobuf_file` - Path to the protobuf file to use as input.
/// * `out_dir` - Output directory where subdirectories for generated files will be created.
///
/// Depending on the features, either `client`, `server` or `client_server` subdirectory
/// will be created inside `out_dir`.
fn new(protobuf_file: PathBuf, out_dir: PathBuf) -> Self {
Expand Down
36 changes: 25 additions & 11 deletions packages/dapi/lib/externalApis/tenderdash/BlockchainListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ class BlockchainListener extends EventEmitter {
*/
constructor(tenderdashWsClient) {
super();

this.wsClient = tenderdashWsClient;

this.processLogger = logger.child({
process: 'BlockchainListener',
});
}

/**
Expand All @@ -30,14 +35,7 @@ class BlockchainListener extends EventEmitter {
* Subscribe to blocks and transaction results
*/
start() {
const processLogger = logger.child({
process: 'BlockchainListener',
});

processLogger.info('Subscribed to state transition results');

// Emit transaction results
this.wsClient.subscribe(TX_QUERY);
this.wsClient.on(TX_QUERY, (message) => {
const [hashString] = (message.events || []).map((event) => {
const hashAttribute = event.attributes.find((attribute) => attribute.key === 'hash');
Expand All @@ -53,15 +51,31 @@ class BlockchainListener extends EventEmitter {
return;
}

processLogger.trace(`received transaction result for ${hashString}`);
this.processLogger.trace(`Received transaction result for ${hashString}`);

this.emit(BlockchainListener.getTransactionEventName(hashString), message);
});

// TODO: It's not using
// Emit blocks and contained transactions
// this.wsClient.subscribe(NEW_BLOCK_QUERY);
// this.wsClient.on(NEW_BLOCK_QUERY, (message) => this.emit(EVENTS.NEW_BLOCK, message));
this.wsClient.on(NEW_BLOCK_QUERY, (message) => {
this.processLogger.trace('Received new platform block');

this.emit(EVENTS.NEW_BLOCK, message);
});

this.wsClient.on('connect', () => {
this.#subscribe();
});

if (this.wsClient.isConnected) {
this.#subscribe();
}
}

#subscribe() {
this.wsClient.subscribe(TX_QUERY);
this.wsClient.subscribe(NEW_BLOCK_QUERY);
this.processLogger.debug('Subscribed to platform blockchain events');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
} = require('@dashevo/dapi-grpc');

const BlockchainListener = require('../../../externalApis/tenderdash/BlockchainListener');
const logger = require('../../../logger');

/**
* @param {BlockchainListener} blockchainListener
Expand All @@ -17,12 +18,23 @@ const BlockchainListener = require('../../../externalApis/tenderdash/BlockchainL
* @return {getStatusHandler}
*/
function getStatusHandlerFactory(blockchainListener, driveClient, tenderdashRpcClient) {
// Clean cache when new platform block committed
let cachedResponse = null;
let cleanCacheTimeout = null;

blockchainListener.on(BlockchainListener.EVENTS.NEW_BLOCK, () => {
function cleanCache() {
cachedResponse = null;
});

// cancel scheduled cache cleanup
if (cleanCacheTimeout !== null) {
clearTimeout(cleanCacheTimeout);
cleanCacheTimeout = null;
}

logger.trace({ endpoint: 'getStatus' }, 'cleanup cache');
}

// Clean cache when new platform block committed
blockchainListener.on(BlockchainListener.EVENTS.NEW_BLOCK, cleanCache);

// DAPI Software version
const packageJsonPath = path.resolve(__dirname, '..', '..', '..', '..', 'package.json');
Expand Down Expand Up @@ -210,6 +222,15 @@ function getStatusHandlerFactory(blockchainListener, driveClient, tenderdashRpcC
cachedResponse = new GetStatusResponse();
cachedResponse.setV0(v0);

// Cancel any existing scheduled cache cleanup
if (cleanCacheTimeout !== null) {
clearTimeout(cleanCacheTimeout);
cleanCacheTimeout = null;
}

// Clean cache in 3 minutes
cleanCacheTimeout = setTimeout(cleanCache, 3 * 60 * 1000);

return cachedResponse;
}

Expand Down
Loading

0 comments on commit f5c07d2

Please sign in to comment.