Skip to content

Commit

Permalink
Fix VM Nightly (#2213)
Browse files Browse the repository at this point in the history
* Change npm ci to npm i

* Add workflow dispatch trigger

* Switch remaning ci to i

* common: Fix common hardfork check
  • Loading branch information
acolytec3 authored Aug 23, 2022
1 parent ffe3402 commit 310b9fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/vm-nightly-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: VM Nightly
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:

env:
cwd: ${{github.workspace}}/packages/vm
Expand All @@ -26,7 +27,7 @@ jobs:
- run: rm package-lock.json
working-directory: ${{github.workspace}}

- run: npm ci
- run: npm i
working-directory: ${{github.workspace}}

- run: npm run test:API
Expand All @@ -49,7 +50,7 @@ jobs:
- run: rm package-lock.json
working-directory: ${{github.workspace}}

- run: npm ci
- run: npm i
working-directory: ${{github.workspace}}

- run: npm run test:state:allForks
Expand All @@ -71,7 +72,7 @@ jobs:
- run: rm package-lock.json
working-directory: ${{github.workspace}}

- run: npm ci
- run: npm i
working-directory: ${{github.workspace}}

- run: npm run test:blockchain:allForks
Expand All @@ -94,7 +95,7 @@ jobs:
- run: rm package-lock.json
working-directory: ${{github.workspace}}

- run: npm ci
- run: npm i
working-directory: ${{github.workspace}}

- run: npm run test:state:slow
8 changes: 4 additions & 4 deletions packages/common/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export class Common extends EventEmitter {
let previousHF
for (const hf of this.hardforks()) {
// Skip comparison for not applied HFs
if (hf.block === null) {
if (typeof hf.block !== 'number') {
if (td !== undefined && td !== null && hf.ttd !== undefined && hf.ttd !== null) {
if (td >= BigInt(hf.ttd)) {
return hf.name
Expand Down Expand Up @@ -611,7 +611,7 @@ export class Common extends EventEmitter {
// a block greater than the current hfBlock set the accumulator,
// pass on the accumulator as the final result from this time on
const nextHfBlock = this.hardforks().reduce((acc: bigint | null, hf: HardforkConfig) => {
const block = BigInt(hf.block === null ? 0 : hf.block)
const block = BigInt(typeof hf.block !== 'number' ? 0 : hf.block)
return block > hfBlock && acc === null ? block : acc
}, null)
return nextHfBlock
Expand Down Expand Up @@ -645,13 +645,13 @@ export class Common extends EventEmitter {

// Skip for chainstart (0), not applied HFs (null) and
// when already applied on same block number HFs
if (block !== 0 && block !== null && block !== prevBlock) {
if (typeof block === 'number' && block !== 0 && block !== prevBlock) {
const hfBlockBuffer = Buffer.from(block.toString(16).padStart(16, '0'), 'hex')
hfBuffer = Buffer.concat([hfBuffer, hfBlockBuffer])
}

if (hf.name === hardfork) break
if (block !== null) {
if (typeof block === 'number') {
prevBlock = block
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export interface GenesisBlockConfig {

export interface HardforkConfig {
name: Hardfork | string
block: number | null
block?: number | null
ttd?: bigint | string
forkHash?: string | null
}
Expand Down

0 comments on commit 310b9fa

Please sign in to comment.