fix: consolidate session timing and simplify docker release workflow (#321)

## Summary

- Consolidates `SessionsPerEra` definition in common runtime (removes
duplicate definitions)
- Simplifies docker release workflow to always use full Docker builds
- Removes binary reuse path from release workflow

## Changes

### Runtime Configuration
- Remove duplicate `SessionsPerEra` definitions from individual runtimes
- Import `SessionsPerEra` from `datahaven_runtime_common::time` instead
- This fixes inconsistency where individual runtimes had
`prod_or_fast!(6, 1)` while common had `prod_or_fast!(6, 3)`

### Docker Release Workflow
- Remove binary reuse path - now always does full Docker build
- Remove `binary-hash` input from `workflow_call`
- Consolidate to single build step using `datahaven-build.Dockerfile`
- `docker-build-release` now runs in parallel on main branch (no
dependency on `build-operator`)

## Timing Configuration

### Production Runtime
| Parameter        | Value       | Duration   |
|------------------|-------------|------------|
| Session          | 600 blocks  | 1 hour     |
| Sessions per era | 6           | -          |
| Era              | 6 sessions  | 6 hours    |
| Bonding duration | 28 eras     | 7 days     |

### Fast Runtime (for testing)
| Parameter        | Value       | Duration   |
|------------------|-------------|------------|
| Session          | 10 blocks   | 1 minute   |
| Sessions per era | 1           | -          |
| Era              | 1 session   | 1 minute   |
| Bonding duration | 3 eras      | 3 minutes  |

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Degosserie 2025-11-26 10:25:24 +01:00 committed by GitHub
parent 92d3c42f79
commit 71b5e5185f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 16 additions and 57 deletions

View file

@ -51,12 +51,9 @@ jobs:
binary-hash: ${{ needs.build-operator.outputs.binary-hash }}
docker-build-release:
needs: [build-operator]
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/task-docker-release.yml
secrets: inherit
with:
binary-hash: ${{ needs.build-operator.outputs.binary-hash }}
moonwall-tests:
needs: [build-operator]

View file

@ -17,11 +17,6 @@ on:
type: boolean
default: false
workflow_call:
inputs:
binary-hash:
description: "The hash of the operator binary (for CI builds)"
required: true
type: string
outputs:
image-tag:
description: "The tag portion of the docker image (without registry)"
@ -48,21 +43,6 @@ jobs:
ref: ${{ github.event.inputs.branch || github.ref }}
- uses: ./.github/workflows/actions/cleanup-runner
if: github.event_name == 'workflow_dispatch'
# --- Conditional: Download binary for CI builds ---
- name: Download binary artifact (CI build)
if: github.event_name != 'workflow_dispatch'
uses: actions/download-artifact@v4
with:
name: datahaven-node-${{ inputs.binary-hash }}
path: ./build/
- name: Prepare binary (CI build)
if: github.event_name != 'workflow_dispatch'
run: |
chmod +x ./build/datahaven-node
ls -la ./build/
# --- Docker metadata ---
- name: Docker meta (dispatch)
@ -100,9 +80,8 @@ jobs:
echo "image-tag=$TAG_ONLY" >> $GITHUB_OUTPUT
echo "image-name=datahavenxyz/datahaven:$TAG_ONLY" >> $GITHUB_OUTPUT
# --- Conditional: Cargo cache for full builds ---
- name: Set up cargo cache (full build)
if: github.event_name == 'workflow_dispatch'
# --- Cargo cache for full builds ---
- name: Set up cargo cache
uses: actions/cache@v4
id: cache
with:
@ -115,8 +94,7 @@ jobs:
cache-mount-${{ hashFiles('./docker/datahaven-build.Dockerfile') }}
cache-mount-
- name: Inject cache into docker (full build)
if: github.event_name == 'workflow_dispatch'
- name: Inject cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-map: |
@ -126,9 +104,8 @@ jobs:
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
# --- Build and push: Full build (workflow_dispatch) ---
- name: Build and push Docker image (full build)
if: github.event_name == 'workflow_dispatch'
# --- Build and push Docker image ---
- name: Build and push Docker image
uses: ./.github/workflow-templates/publish-docker
with:
dockerfile: ./docker/datahaven-build.Dockerfile
@ -136,28 +113,13 @@ jobs:
registry: docker.io
registry_username: ${{ secrets.DOCKERHUB_USERNAME }}
registry_password: ${{ secrets.DOCKERHUB_TOKEN }}
image_tags: ${{ steps.meta-dispatch.outputs.tags }}
image_tags: ${{ steps.meta-dispatch.outputs.tags || steps.meta-ci.outputs.tags }}
image_title: "DataHaven Node - Release"
image_description: "Release build of DataHaven blockchain node"
cache_scope: datahaven-release-build
build_args: |
FAST_RUNTIME=${{ github.event.inputs.fast_runtime == 'true' && 'TRUE' || 'FALSE' }}
# --- Build and push: CI binary reuse (workflow_call) ---
- name: Build and push Docker image (CI binary)
if: github.event_name != 'workflow_dispatch'
uses: ./.github/workflow-templates/publish-docker
with:
dockerfile: ./operator/Dockerfile
context: .
registry: docker.io
registry_username: ${{ secrets.DOCKERHUB_USERNAME }}
registry_password: ${{ secrets.DOCKERHUB_TOKEN }}
image_tags: ${{ steps.meta-ci.outputs.tags }}
image_title: "DataHaven Node - Release"
image_description: "Release build of DataHaven operator node"
cache_scope: datahaven-release-ci
# --- Smoke tests ---
- name: Pull and test node --help
run: |

View file

@ -26,8 +26,11 @@ pub mod time {
const ONE_MINUTE: BlockNumber = MINUTES;
frame_support::parameter_types! {
/// Session/epoch duration:
/// - Production: 1 hour (600 blocks)
/// - Fast-runtime: 1 minute (10 blocks)
pub const EpochDurationInBlocks: BlockNumber = prod_or_fast!(ONE_HOUR, ONE_MINUTE);
pub const SessionsPerEra: SessionIndex = prod_or_fast!(6, 3);
pub const SessionsPerEra: SessionIndex = prod_or_fast!(6, 1);
}
// These time units are defined in number of blocks.

View file

@ -86,7 +86,7 @@ use datahaven_runtime_common::{
ReleaseDelayNone, RuntimeCallFilter, SafeModeDuration, SafeModeEnterDeposit,
SafeModeExtendDeposit, TxPauseWhitelistedCalls,
},
time::{EpochDurationInBlocks, DAYS, MILLISECS_PER_BLOCK},
time::{EpochDurationInBlocks, SessionsPerEra, DAYS, MILLISECS_PER_BLOCK},
};
use dhp_bridge::{EigenLayerMessageProcessor, NativeTokenTransferMessageProcessor};
use frame_support::{
@ -138,7 +138,7 @@ use sp_runtime::{
traits::{Convert, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys, UniqueSaturatedInto},
FixedPointNumber, Perbill, Perquintill,
};
use sp_staking::{EraIndex, SessionIndex};
use sp_staking::EraIndex;
use sp_std::{
convert::{From, Into},
prelude::*,
@ -164,7 +164,6 @@ const SS58_FORMAT: u16 = EVM_CHAIN_ID as u16;
parameter_types! {
pub const MaxAuthorities: u32 = 32;
pub const BondingDuration: EraIndex = polkadot_runtime_common::prod_or_fast!(28, 3);
pub const SessionsPerEra: SessionIndex = polkadot_runtime_common::prod_or_fast!(6, 1);
pub const AuthorRewardPoints: u32 = 20;
}

View file

@ -86,7 +86,7 @@ use datahaven_runtime_common::{
ReleaseDelayNone, RuntimeCallFilter, SafeModeDuration, SafeModeEnterDeposit,
SafeModeExtendDeposit, TxPauseWhitelistedCalls,
},
time::{EpochDurationInBlocks, DAYS, MILLISECS_PER_BLOCK},
time::{EpochDurationInBlocks, SessionsPerEra, DAYS, MILLISECS_PER_BLOCK},
};
use dhp_bridge::{EigenLayerMessageProcessor, NativeTokenTransferMessageProcessor};
use frame_support::{
@ -138,7 +138,7 @@ use sp_runtime::{
traits::{Convert, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys, UniqueSaturatedInto},
FixedPointNumber, Perbill, Perquintill,
};
use sp_staking::{EraIndex, SessionIndex};
use sp_staking::EraIndex;
use sp_std::{
convert::{From, Into},
prelude::*,
@ -164,7 +164,6 @@ const SS58_FORMAT: u16 = EVM_CHAIN_ID as u16;
parameter_types! {
pub const MaxAuthorities: u32 = 32;
pub const BondingDuration: EraIndex = polkadot_runtime_common::prod_or_fast!(28, 3);
pub const SessionsPerEra: SessionIndex = polkadot_runtime_common::prod_or_fast!(6, 1);
pub const AuthorRewardPoints: u32 = 20;
}

View file

@ -86,7 +86,7 @@ use datahaven_runtime_common::{
ReleaseDelayNone, RuntimeCallFilter, SafeModeDuration, SafeModeEnterDeposit,
SafeModeExtendDeposit, TxPauseWhitelistedCalls,
},
time::{EpochDurationInBlocks, DAYS, MILLISECS_PER_BLOCK},
time::{EpochDurationInBlocks, SessionsPerEra, DAYS, MILLISECS_PER_BLOCK},
};
use dhp_bridge::{EigenLayerMessageProcessor, NativeTokenTransferMessageProcessor};
use frame_support::{
@ -138,7 +138,7 @@ use sp_runtime::{
traits::{Convert, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys, UniqueSaturatedInto},
FixedPointNumber, Perbill, Perquintill,
};
use sp_staking::{EraIndex, SessionIndex};
use sp_staking::EraIndex;
use sp_std::{
convert::{From, Into},
prelude::*,
@ -164,7 +164,6 @@ const SS58_FORMAT: u16 = EVM_CHAIN_ID as u16;
parameter_types! {
pub const MaxAuthorities: u32 = 32;
pub const BondingDuration: EraIndex = polkadot_runtime_common::prod_or_fast!(28, 3);
pub const SessionsPerEra: SessionIndex = polkadot_runtime_common::prod_or_fast!(6, 1);
pub const AuthorRewardPoints: u32 = 20;
}