Skip to content

Commit

Permalink
chore: merge develop to evm (#578)
Browse files Browse the repository at this point in the history
* deps: clean dependendies and add check script (#450)

* Ignore eslint in scripts

* Use async calls

* Ignore tests

* Show testonly dependencies

* Calculate deps

* Add docs

* Implement methods on Package

* Cleanup

* Rename deps to imports

* Fix exceptions

* Pass method

* Go trough all packages

* Improve logs

* Rename file

* Remove old scripts

* Exit with 1 if failing

* Fix validator-set-vote-weighted

* Validator set static

* Fix validator

* Fix utils

* Fix transaction pool

* Fix test-framework

* Fix packages

* Add deps check

* style: resolve style guide violations

* Fix ci

* Fix api

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* feat(bootstrap): compare stored genesis block with config (#451)

* Check stored commit

* Empty commit

* refactor(processor): log verification errors (#452)

* Remove console logs

* Remove forger errors

* Remove UnexpectedError

* Remove extra exceptions

* Add ValidatorExceptions

* Handler throws errors

* Improve logs

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* chore: change banner format to jpeg (#453)

* Add banner jpeg

* Remove png version

* Update readme

* release: 0.0.1-alpha.8 (#454)

* release: 0.0.1-alpha.8

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* fix(validator-set-vote-weighted): active validators is subset of registered validators (#466)

* Mak method private

* Build validators

* Local variable

* Use for of loop

* Check active validators

* Fix tests

* fix(processor): `validatorVoteBalance` calculation (#467)

* Add pg:reset

* Decrease vote balance

* Include fee

* Remove unused line

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* chore: docker validator support (#468)

* release: 0.0.1-alpha.9 (#469)

* release: 0.0.1-alpha.9

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* chore: fix publish GitHub workflow (#470)

* Run on pull request

* No git checks

* set token

* Revert to original build conditions

---------

Co-authored-by: oXtxNt9U <[email protected]>

* refactor(transactions): move amount deduction into transaction handlers (#472)

* refactor transfer amount deduction

* cleanup

* update schema tests

* feat: add `env:paths:clear` commands (#473)

* Clear plugins & exports

* Clear data

* Remove variables

* Add paths to contracts

* Remove config paths

* Cache cache, log, temp

* Cleanup

* Add command to api

* Add clear all

* Fix case

* release: 0.0.1-alpha.10 (#474)

* release: 0.0.1-alpha.10

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* feat(crypto-transaction-username-registration): limit one transaction by sender in pool (#475)

* Rename variable

* Fix text

* Check transaction already in the pool

* feat(validator): log loaded validators (#477)

* Inject

* Print method

* Print on bootstrap

* Rename method

* Execute after state check

* Improve text

* Log 0 validators

* Determine activa & standby

* Wallet to string

* chore: fix typo in transaction fee errors (#476)

* feat(state): implements `sizeOfIndex` on WalletRepository (#479)

* Add sizeOfIndex

* Add initial implementation

* Wallet repository clone

* Implement on wallet repo clone

* Add missing attribute

* FIx validator resignation

* release: 0.0.1-alpha.11 (#480)

* release: 0.0.1-alpha.11

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* feat: port to ES modules (#478)

* initial browser support

* add package link script

* port api-common

* port api-database

* port api-development

* port api-http

* port api-sync

* port api-transaction-pool

* port api

* port bootstrap

* port cli

* port configuration-generator

* port consensus

* port webhooks

* port validator

* port validator-set-vote-weighted

* port validator-set-static

* port validation

* port utils

* port transactions

* port transaction-pool

* port test-framework

* port state

* port serializer

* port proposer

* port processor

* port p2p

* port networking-ntp

* port networking-dns

* port logger-winston

* port logger-pino

* port kernel

* port fees

* port fees-static

* port fees-managed

* port fees-burn

* port database

* port crypto-worker

* port crypto-wif

* port crypto-validation

* port crypto-transaction

* port crypto-transaction-vote

* port crypto-transaction-validator-resignation

* port crypto-transaction-validator-registration

* port crypto-transaction-username-resignation

* port crypto-transaction-username-registration

* port crypto-transaction-transfer

* port crypto-transaction-multi-signature-registration

* port crypto-transaction-multi-payment

* port crypto-signature-schnorr

* port crypto-signature-schnorr-secp256k1

* port crypto-signature-ed25519

* port crypto-signature-ecdsa

* port crypto-signature-bls12-381

* port crypto-messages

* port crypto-key-pair-schnorr

* port crypto-key-pair-ed25519

* port crypto-key-pair-ecdsa

* port crypto-key-pair-bls12-381

* port crypto-hash-wasm

* port crypto-hash-noble

* port crypto-hash-bcrypto

* port crypto-consensus-bls12-381

* port crypto-config

* port crypto-commit

* port crypto-block

* port crypto-address-ss58

* port crypto-address-keccak256

* port crypto-address-bech32m

* port crypto-address-bech32

* port crypto-address-base58

* port core

* port contracts

* port container

* update tsconfig to nodenext

* fix kleur/color

* update core/bin/run.js

* command fixes

* lmdb import fixes

* p2p fixes

* ajv fix

* get __dirname

* update pnpm-lock.yaml

* remove unused @pm2/io dependency

* replace fileURLToPath

* use filesystem service inside kernel

* cleanup

* update TypeScript to 5.4.2

* move __dirname into local scope

* replace fast-memoize with memoizee

* test-runner packacge

* re-export test-runner

* tests: utils

* tests: validation

* tests: crypto-config

* tests: container

* tests: kernel

* tests: transactions

* style: resolve style guide violations

* fix more tests

* fix transaction dependency lookup

* fix p2p tests

* more fixes

* fix cli and configuration-generator

* cli fixes

* kernel fixes

* transaction-pool

* all pass

* commit dirty

* style: resolve style guide violations

* fix api-http integration tests

* fix deps:check

* runtime fixes

---------

Co-authored-by: oXtxNt9U <[email protected]>
Co-authored-by: sebastijankuzner <[email protected]>

* fix(api): broken entrypoint (#481)

* fix api entrypoint

* fix more commands

* refactor(transaction-pool): return tx indexes as integers (#483)

* return tx indexes as integers

* fix compile error

* chore: update dependencies (#482)

* update dependencies

* Empyt commit

---------

Co-authored-by: sebastijankuzner <[email protected]>

* fix wallet response (#485)

* fix(configuration-generator): create genesis block script (#484)

* fix create genesis block script

* Empty commit

---------

Co-authored-by: sebastijankuzner <[email protected]>

* refactor(core): rename run script to have explicit file extension (#486)

* ensure run script has explicit file extension

fixes ERR_UNKNOWN_FILE_EXTENSION

* empty commit

* fix: use .js extension in `start` commands (#487)

* Fix start commands

* Fix package.json

* Fix tests

* release: 0.0.1-alpha.12 (#488)

* release: 0.0.1-alpha.12

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* fix(core): resolve correct plugin `package.json` path (#489)

* Fix package manifest

* Skip tests

* release: 0.0.1-alpha.13 (#490)

* release: 0.0.1-alpha.13

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* feat(cli): determine correct entrypoint paths (#491)

* Add setup class

* Fix setup

* Bind

* Fixes

* Use setup paths

* Use in api

* Remove logs

* Fix tests

* Cleanup tests

* fix(test-framework): list project packages in dependencies (#492)

* Use direct dependencies

* Empty commit

* Fix dependencies

* Fix dependencies

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* exclude genesis transactions from fee statistics calculation (#494)

* fix(crypto): manage static fees via milestones (#493)

* add static fees to milestones

* update tests

* style: resolve style guide violations

* initialize static fees only in a single place

---------

Co-authored-by: oXtxNt9U <[email protected]>

* fix(api): sync active milestones on change (#495)

* sync active milestones on change

* fix test

* fix(api-http): add missing fields to transaction resource (#496)

* improve error logging

* populate all transaction fields

* review

* remove type cast

* add comment

* simplify more

* rename block model too and add assert

* fix paths according to the latest paths naming convention (#497)

* refactor(p2p): replace ip with `url` in api nodes (#498)

* api node urls

* update protobuf definitions

* update test fixtures

* cleanup

* style: resolve style guide violations

---------

Co-authored-by: oXtxNt9U <[email protected]>

* fix(transaction-pool): invalid tx error reporting (#500)

* fix tx pool error reporting

* empty commit

* test: use `tsx` TypeScript loader (#499)

* Add tsx

* Fix runner

* Fix test-runner scripts

* Update tsconfig

* Fix tests

* Use test config

* Fix api tests

* api-common

* Api-database

* api-development

* api-http

* api-sync

* api-transaction-pool

* bootstrap

* cli partial

* Fix cli tests

* Runner extends contracts

* Configuration generator

* Consensus

* Container

* Contracts

* Core

* Crypto address

* Crypto block

* Cypto commit

* Crypto config

* Crypto

* Crypto messages

* Crypto signature

* Crypto transaction

* Crypto

* Database

* Fees

* Kernel

* Logger pino

* Logger winston

* Networking

* Server

* Processor, proposer, serializer

* State

* Transaction pool

* Transactions

* Utils

* Validation

* Validator

* Validator set

* Webhooks

* Remove tsm

* Fix integration tests

* Update lint CI

* Fix dependencies

* Prettier

* Lint

* Perttier

* style: resolve style guide violations

* refactor: remove `__dirname` usage (#501)

* Remove __dirname

* Fix tests

* Factory require config

* test(functional/consensus): add skeleton for functional tests (#503)

* Prepare base structure

* Add test runner

* Base test

* Add base packages

* Register base packages

* Add config

* Add pacakges

* Export bootstrap

* Export individual bootstrappers

* Register bootstrappers

* Extract bootstrapper itnerface

* Test

* Use tsm

* Pass url to PluginManifest

* Register service provider

* Setup up to validator package

* Register all necessary packages

* Add missing packages

* Boot

* Register transactions

* Process genesis

* Run consensus

* Add worker

* Fix worker

* Fix broadcaster

* refactor(consensus-storage): extract storage logic into package (#502)

* Add consensus storage package

* Prepare service provider

* Remove storage from consensus

* Add dependencies

* Move root into consensus storage

* Rename identifier

* Fix identifiers

* Edit contracts

* Fix deps

* Update packages/consensus-storage/README.md

Co-authored-by: oXtxNt9U <[email protected]>

---------

Co-authored-by: oXtxNt9U <[email protected]>

* milestone generator add static fees (#504)

* test(functional/transaction-pool-api): initial boilerplate and tests (#505)

* update gitignore

* add tx pool api boilerplate and basic broadcast

* add signWithKeyPair to tx builder

* update functional consensus milestones

* wait for block and assert committed transaction

* invalid transfer test

* assert invalid transactions are not committed

* test with invalid / malformed signature

* fix(test-runner): rethrow error in runHook (#506)

* bubble up error thrown in runHook

* Empty

---------

Co-authored-by: sebastijankuzner <[email protected]>

* refactor(database): return commits instead blocks (#507)

* getBlock to getCommit

* Fix tests

* getLastBlock -> getLastCommit

* Fix tests

* Implement isEmpty

* Fix tests

* feat(transaction-pool): support `in-memory` database (#510)

* Support im memory database

* Deps

* Test

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* test(functional/consensus): prepare package replacements, asserts and p2p layer (#508)

* Bind consensus storage

* Mock database

* Add contracts

* Use relative paths

* Prepare 2 setups

* Run 2 nodes

* Make log protected

* Make MemoryLogger fields protected

* Prepare custom logger

* Prepare p2p layer

* Fix p2p

* MemoryDatabase

* Load crypto

* Read validators

* Prepare validators

* Use common config

* Add snooze for one block

* Stop node

* Snooze for block

* Prepare smaller config

* Asserts

* Fix and check TS code

* Add script for check & test

* Use strict true

* Support plugin options

* Assert validators

* refactor(kernel): create bootstraper for shutdown signals  (#511)

* Register error handler first

* Move listen to shutdown signals into bootstrapper

* test(functional/transaction-pool-api): test all transaction types (#509)

* missing dependency

* transfer

* vote

* username-registration

* username-resignation

* validator-registration

* validator-resignation

* multipayment

* fix default payload

* update utils

* multi signature test plus fixes

* fix compile error

* test transfer with multisig

* rename tests for clarity

* add wallets to context

* tsc strict

* add snapshot based balance checks

* reduce block time

* review

* test(functional/transaction-pool): increase vote coverage (#512)

* votes

* empty commit

* test switch vote and unvote for non voted validator

* test(functional/transaction-pool): increase validator registration coverage (#513)

* votes

* empty commit

* validator registration

* empty commit

* test(functional/transaction-pool): increase validator resignation coverage (#514)

* votes

* empty commit

* validator resignation

* empty commit

* test(functional/transaction-pool): increase username registration coverage (#515)

* votes

* empty commit

* username registration

* empty commit

* test(functional/transaction-pool): increase username resignation coverage (#516)

* votes

* empty commit

* username resignation

* empty commit

* fix(kernel): minority and majority calculation (#520)

* Fix majority, minority

* Tests

* Add extra tests

* fix(api-http): allow 0 nonce in schema (#521)

* Allow nonce 0

* Empty commit

* fix(api-http): implement missing `/transaction/fees` route (#523)

* implement missing route /transaction/fees

* add test

* style: resolve style guide violations

* remove unused query param

---------

Co-authored-by: oXtxNt9U <[email protected]>

* test(functional/transaction-pool): increase multi sig registration coverage  (#517)

* more multi signature tests

* empty commit

* update min participants

* test missing participant signature

* test(functional/transaction-pool): add more misc coverage  (#518)

* more multi signature tests

* empty commit

* add misc tests

* empty commit

* release: 0.0.1-alpha.14 (#522)

* release: 0.0.1-alpha.14

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* feat(consensus): emit events (#524)

* Add bootstrapped

* New round

* Add events

* Dispatch events

* Fix tests

* test(functional/transaction-pool): extract transaction builders into separate package (#525)

* introduce test-transaction-builders package

* use test transactions package

* include type when logging rejected tx

* style: resolve style guide violations

* fix deps:check

* style: resolve style guide violations

---------

Co-authored-by: oXtxNt9U <[email protected]>

* test(functional/consensus): test proposal scenarios (#526)

* Add initial test

* Rename base test

* Optional blockId

* Full test

* Bind custom proposer selector

* Check generatorPublic key

* Make consensus methods protected

* Expose boot and bootstrap methods

* Skip error handler registration

* Make consensus methods public

* Assert blockRound

* Implement *Many helpers

* Fix base test

* Force async to p2p

* Test missing propose

* Simulate double propose

* Simulate 50:50 split

* Remove assertCommitValidators

* Record messages

* Asserts

* majority minority split

* SnozeForBlock with height

* Assert next block is fine

* Check multiple rounds

* Check invalid proposer

* Add CI for functional

* Rename tests to proposal

* Rename tests

* fix(api-http): delegate search (#527)

* Fix delegate search in API

* Initial support for sorting on jsonb fields

* Update tests

* style: resolve style guide violations

---------

Co-authored-by: oXtxNt9U <[email protected]>

* refactor(p2p): log route on codec error (#528)

* Log error

* Allow empty

* test(functional/transaction-pool): add .gitkeep (#530)

* add .gitkeep

* empty commit

* test(functional/consensus): test prevote & precommit scenarios (#529)

* Check minority not prevoting

* Test null prevotes

* Extract methods to utils

* Check random block

* Check with multiple prevotes

* Lint

* Fix ts errors

* Disable unicorn/no-useless-undefined

* Check missing precommits

* Test precommits

* Check multiple messages

* fix(configuration-generator): update export paths (#531)

* Update paths

* Empty

* feat(api-development): add `peers/banned` endpoint (#532)

* Disposer returns list of banned peers

* Add endpoint

* Add pagiantion

* Format timeout

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* test(functional): update ci workflow (#534)

* run all functional tests in ci

* test

* style: resolve style guide violations

* test

* revert me

* style: resolve style guide violations

* include matrix name

* revert trigger

---------

Co-authored-by: oXtxNt9U <[email protected]>

* test(functional/consensus): test rejection of invalid block proposals (#533)

* custom funded wallet provider

* REVERT ME: debug logs

* export Proposer

* custom block proposal

* emit event on invalid block

* add assertInvalidBlock

* extract custom proposal function

* ensure wallet exists on each node

* invalid proposals

* seed with randomBytes

* log error instance on mismatch

* lint

* Revert "REVERT ME: debug logs"

This reverts commit defdf7e.

* deps: update lmdb (#535)

* Update lmdb

* Log if commit cannot be read

* Await transaction flushed

* Await flush

* test(functional): fix `MaxListenersExceeded` warning (#537)

* fix MaxListenersExceededWarning

* empty commit

* feat(api-http): support sorting on jsonb attributes (#538)

* support sort on wallet attributes

* NULLS LAST

* tests

* style: resolve style guide violations

---------

Co-authored-by: oXtxNt9U <[email protected]>

* fix(p2p): peer ban and validate ip plugin (#539)

* Skip header check if peer is not in repo

* Validate peer ip

* Remove repo check

* Validate ip and data separately

* Fix test

* Update default peer ban time

* feat(cli): add --overwrite flag to `config:publish:custom` (#536)

* expose `skip` callback

* update publish:custom command

* style: resolve style guide violations

* Make fields optional

* Require flags error

---------

Co-authored-by: oXtxNt9U <[email protected]>
Co-authored-by: sebastijankuzner <[email protected]>

* feat(crypto): add browser support for bls12-381 packages (#540)

* add bls12-381 browser support

* update test

* style: resolve style guide violations

* dep check exception

---------

Co-authored-by: oXtxNt9U <[email protected]>

* release: 0.0.1-alpha.15 (#542)

* release: 0.0.1-alpha.15

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* fix(p2p): postTransactions response schema and proto (#543)

* Update proto

* Build proto

* Fix schema

* Fix tests

* refactor(api): show `meta` field in response at top (#545)

* show `meta` field in response at top

* style: resolve style guide violations

* eslint: disable key sort

---------

Co-authored-by: oXtxNt9U <[email protected]>

* fix(api-http): change default sort for `/delegates` (#544)

* sort /delegates by rank by default

* empty commit

* refactor(block-processor): log commit round (#546)

* Log block round

* Empty commit

* perf(consensus): verify proposal signatures on main thread (#548)

* Verify signature on main thread

* Empty commit

* refactor(contracts): remove Consensus prefix from contracts (#549)

* Rename contracts

* Empty commit

* refactor(consensus): remove hasValidBlockGenerator check (#550)

* Remove hasValidBlockGenerator check

* Empty commit

* fix(api-http): sort delegates by rank asc by default (#552)

* sort delegates by rank asc by default

* empty commit

* test(e2e): add e2e tests and workflow (#547)

* network with 3 nodes

* add check for target block height

* workflow

* revert me

* exclude e2e directory

* style: resolve style guide violations

* docker fixes

* test

* add timeout

* test

* wait for checks to finish

* run detached

* show logs

* style: resolve style guide violations

* increase sleep

* increase target height

* revert trigger condition

* revert changes to defaults

* style: resolve style guide violations

* reply with 200

* Update tests/e2e/consensus/checks/index.mjs

Co-authored-by: Sebastijan K. <[email protected]>

* reduce timeout for now

---------

Co-authored-by: oXtxNt9U <[email protected]>
Co-authored-by: Sebastijan K. <[email protected]>

* release: 0.0.1-alpha.16 (#553)

* release: 0.0.1-alpha.16

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* feat(validator): support secret encryption (#554)

* remove skipValidation flag

* write validator keystore

* support validator with encrypted passphrase

* update commands

* update tests

* optional keystore

* style: resolve style guide violations

* support --password

* review

* style: resolve style guide violations

---------

Co-authored-by: oXtxNt9U <[email protected]>

* perf: deserialize proposal in steps (#551)

* Rename ProposedBlock to ProposedData

* Remove ProposedBlockJson

* Rename proposal.block to proposal.data

* Fix consensus tests

* Fix crypto-message tests

* Add getData and isDataDeserialized

* Fix consensus tests

* Test proposal

* Rename method

* Make makeProposedDataFromBytes public

* Make proposal injectable

* Fix tests

* Add deserialize to proposal

* Check status before returning data

* Include deserializer

* Fix tests

* Pass only serialized data to proposal

* Deserialize in proposal processor

* Deserialize in handler

* Remove todo

* Fix tests

* Fix header

* Verify lock proof after deserialization

* Fix functional tests

* Fix proposal types

* Fix proposal creation

* perf(consensus): run pending RoundStates only once (#555)

* Set pending jobs

* Remove key

* Reduce complexity

* fix: dispatch block events with expected payload (#558)

* dispatch BlockEvent.Forged again

* dispatch only block instead of whole commit

* fix

* test

* update e2e check

* chore: upgrade pnpm v9 (#556)

* upgrade pnpm v9

* empty commit

* support webhook condition on nested key (#557)

* improve stability (#564)

* fix(webhooks): restore webhooks on boot (#562)

* restore webhooks on boot

* skip events during bootstrap

* skip all but kernel events

* style: resolve style guide violations

* review

---------

Co-authored-by: oXtxNt9U <[email protected]>

* chore(ci): add workflow to enforce minimum commit count (#565)

* check minimum commit count

* style: resolve style guide violations

* rename

---------

Co-authored-by: oXtxNt9U <[email protected]>

* release: 0.0.1-alpha.17 (#566)

* release: 0.0.1-alpha.17

* style: resolve style guide violations

---------

Co-authored-by: sebastijankuzner <[email protected]>

* fix(api-sync): upsert version on bootstrap (#567)

* upsert version on bootstrap

* empty commit

* feat: add `blockPrepareTime` to milestones (#568)

* Add blockPrepareTime

* Nest

* Scheduler

* Sync

* Fix generator

* Test config generator

* Test crypto config

* Fix scheduler

* Add test

* Fix functional tests

* stageTime to stageTimeout

* Fix api-http tests

* refactor(api-sync): add `syncInterval` option (#569)

* Implement getSyncIntervalMs on abstractListener

* Add syncInterval defaults

* Use configuration

* fix(api-sync): process transactions in chunks to support very large blocks (#572)

* sync transactions in chunks

* style: resolve style guide violations

---------

Co-authored-by: oXtxNt9U <[email protected]>

* refactor(consensus): prepare block after commit (#571)

* Log on round start

* Propose after commit

* Use timestamp

* Rename methods

* Fix tests

* Rename method

* Fix tests

* Deps

* Fix consensus tests

* Fix tests

* Update packages/validator/source/validator.ts

Co-authored-by: oXtxNt9U <[email protected]>

* style: resolve style guide violations

---------

Co-authored-by: oXtxNt9U <[email protected]>
Co-authored-by: sebastijankuzner <[email protected]>

* refactor(consensus):  dispatch *any events only once per round (#574)

* Return scheduler status

* Test scheduler

* Skip multiple dispatches

* Tests

* style: resolve style guide violations

* fix deps:check

---------

Co-authored-by: Sebastijan K <[email protected]>
Co-authored-by: sebastijankuzner <[email protected]>
Co-authored-by: Adrian Kerchev <[email protected]>
Co-authored-by: Edgar Goetzendorff <[email protected]>
Co-authored-by: oXtxNt9U <[email protected]>
Co-authored-by: sebastijankuzner <[email protected]>
  • Loading branch information
7 people authored May 15, 2024
1 parent 82aac9f commit a1a754a
Show file tree
Hide file tree
Showing 126 changed files with 714 additions and 397 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/check-commit-count.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
pull_request:
types: [opened, synchronize]

jobs:
check-commits:
runs-on: ubuntu-latest
steps:
- name: Check number of commits in PR
id: commits
uses: actions/github-script@v6
with:
script: |
const payload = await github.rest.pulls.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
return payload.data.length;
- name: Post comment if commits are fewer than 2
if: steps.commits.outputs.result < 2
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: 'This pull request does not contain the minimum required number of commits (2). Please add more commits.'
});
- name: Fail the job if fewer than 2 commits
if: steps.commits.outputs.result < 2
run: |
echo "Failing the job because there are fewer than 2 commits."
exit 1
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "0.0.1-alpha.16"
"version": "0.0.1-alpha.17"
}
2 changes: 1 addition & 1 deletion packages/api-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/api-common",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "Common API building blocks for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand Down
2 changes: 1 addition & 1 deletion packages/api-database/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/api-database",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "API database for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand Down
2 changes: 1 addition & 1 deletion packages/api-development/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/api-development",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "Development API for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand Down
2 changes: 1 addition & 1 deletion packages/api-evm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/api-evm",
"version": "0.0.1-alpha.11",
"version": "0.0.1-alpha.17",
"description": "Ethereum JSON-RPC compatible API for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand Down
2 changes: 1 addition & 1 deletion packages/api-http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/api-http",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "HTTP/S API for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand Down
11 changes: 7 additions & 4 deletions packages/api-http/test/fixtures/node_configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@
"decimals": 8,
"denomination": 100000000
},
"blockTime": 8000,
"stageTimeout": 2000,
"timeouts": {
"blockTime": 8000,
"blockPrepareTime": 4000,
"stageTimeout": 2000,
"stageTimeoutIncrease": 2000
},
"activeValidators": 0,
"multiPaymentLimit": 256,
"vendorFieldLength": 255,
"stageTimeoutIncrease": 2000
"vendorFieldLength": 255
},
"core": {
"version": "0.0.1"
Expand Down
5 changes: 3 additions & 2 deletions packages/api-sync/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/api-sync",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "API database sync for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand All @@ -26,7 +26,8 @@
"@mainsail/container": "workspace:*",
"@mainsail/contracts": "workspace:*",
"@mainsail/kernel": "workspace:*",
"@mainsail/utils": "workspace:*"
"@mainsail/utils": "workspace:*",
"joi": "17.12.2"
},
"devDependencies": {
"uvu": "^0.5.6"
Expand Down
3 changes: 3 additions & 0 deletions packages/api-sync/source/defaults.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const defaults = {
syncInterval: 8000,
};
12 changes: 10 additions & 2 deletions packages/api-sync/source/listeners/abstract-listener.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Contracts as ApiDatabaseContracts, Identifiers as ApiDatabaseIdentifiers } from "@mainsail/api-database";
import { inject, injectable } from "@mainsail/container";
import { inject, injectable, tagged } from "@mainsail/container";
import { Contracts, Exceptions, Identifiers } from "@mainsail/contracts";
import { Providers } from "@mainsail/kernel";

import { EventListener } from "../contracts.js";

Expand All @@ -13,6 +14,10 @@ export type ListenerEventMapping = { [key: Contracts.Kernel.EventName]: Listener

@injectable()
export abstract class AbstractListener<TEventData, TEntity extends { [key: string]: any }> implements EventListener {
@inject(Identifiers.ServiceProvider.Configuration)
@tagged("plugin", "api-sync")
private readonly pluginConfiguration!: Providers.PluginConfiguration;

@inject(Identifiers.Cryptography.Configuration)
protected readonly configuration!: Contracts.Crypto.Configuration;

Expand Down Expand Up @@ -55,9 +60,12 @@ export abstract class AbstractListener<TEventData, TEntity extends { [key: strin
}
}

protected getSyncIntervalMs(): number {
return this.pluginConfiguration.getRequired<number>("syncInterval");
}

protected abstract getEventMapping(): ListenerEventMapping;
protected abstract getEventId(event: TEventData): string;
protected abstract getSyncIntervalMs(): number;
protected abstract mapEventToEntity(event: TEventData): TEntity;
protected abstract makeEntityRepository(
dataSource: ApiDatabaseContracts.RepositoryDataSource,
Expand Down
4 changes: 0 additions & 4 deletions packages/api-sync/source/listeners/api-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ export class ApiNodes extends AbstractListener<Contracts.P2P.ApiNode, Models.Api
return event.url;
}

protected getSyncIntervalMs(): number {
return this.configuration.getMilestone().blockTime;
}

protected mapEventToEntity(event: Contracts.P2P.ApiNode): Models.ApiNode {
return {
height: event.height,
Expand Down
4 changes: 0 additions & 4 deletions packages/api-sync/source/listeners/mempool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export class Mempool extends AbstractListener<Contracts.Crypto.TransactionData,
return id;
}

protected getSyncIntervalMs(): number {
return this.configuration.getMilestone().blockTime;
}

protected mapEventToEntity(event: Contracts.Crypto.TransactionData): Models.MempoolTransaction {
return {
amount: event.amount.toFixed(),
Expand Down
4 changes: 0 additions & 4 deletions packages/api-sync/source/listeners/peers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ export class Peers extends AbstractListener<Contracts.P2P.Peer, Models.Peer> {
return ip;
}

protected getSyncIntervalMs(): number {
return this.configuration.getMilestone().blockTime;
}

protected mapEventToEntity(event: Contracts.P2P.Peer): Models.Peer {
return {
height: event.header.height,
Expand Down
4 changes: 0 additions & 4 deletions packages/api-sync/source/listeners/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export class Plugins extends AbstractListener<Event, Models.Plugin> {
return event.name;
}

protected getSyncIntervalMs(): number {
return this.configuration.getMilestone().blockTime;
}

protected mapEventToEntity({ name }: Event): Models.Plugin {
const serviceProvider = this.serviceProviderRepository.get(name);
const configuration = serviceProvider.config().all();
Expand Down
7 changes: 7 additions & 0 deletions packages/api-sync/source/service-provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Identifiers } from "@mainsail/contracts";
import { Providers } from "@mainsail/kernel";
import Joi from "joi";

import { Listeners } from "./listeners.js";
import { Sync } from "./service.js";
Expand All @@ -16,4 +17,10 @@ export class ServiceProvider extends Providers.ServiceProvider {
public async dispose(): Promise<void> {
await this.app.get<Listeners>(Identifiers.ApiSync.Listener).dispose();
}

public configSchema(): Joi.ObjectSchema {
return Joi.object({
syncInterval: Joi.number().required(),
}).unknown(true);
}
}
14 changes: 5 additions & 9 deletions packages/api-sync/source/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { inject, injectable, tagged } from "@mainsail/container";
import { Contracts, Identifiers } from "@mainsail/contracts";
import { Providers, Types, Utils } from "@mainsail/kernel";
import { sleep, validatorSetPack } from "@mainsail/utils";
import { chunk, sleep, validatorSetPack } from "@mainsail/utils";
import { performance } from "perf_hooks";

import { Listeners } from "./contracts.js";
Expand Down Expand Up @@ -200,13 +200,13 @@ export class Sync implements Contracts.ApiSync.Service {
await this.configurationRepositoryFactory()
.createQueryBuilder()
.insert()
.orIgnore()
.values({
activeMilestones: this.configuration.getMilestone(0) as Record<string, any>,
cryptoConfiguration: (this.configuration.all() ?? {}) as Record<string, any>,
id: 1,
version: this.app.version(),
})
.orUpdate(["crypto_configuration", "version"], ["id"])
.execute();
}

Expand Down Expand Up @@ -307,18 +307,14 @@ export class Sync implements Contracts.ApiSync.Service {
supply: () => `supply + ${deferred.block.reward}`,
})
.where("id = :id", { id: 1 })
// TODO: consider additional check constraint (OLD.height = NEW.height - 1)
.andWhere("height = :previousHeight", {
previousHeight: Utils.BigNumber.make(deferred.block.height).minus(1).toFixed(),
})
.execute();

await transactionRepository
.createQueryBuilder()
.insert()
.orIgnore()
.values(deferred.transactions)
.execute();
for (const batch of chunk(deferred.transactions, 256)) {
await transactionRepository.createQueryBuilder().insert().orIgnore().values(batch).execute();
}

if (deferred.validatorRound) {
await validatorRoundRepository
Expand Down
2 changes: 1 addition & 1 deletion packages/api-transaction-pool/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/api-transaction-pool",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "Transaction Pool API for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/api",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "API for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand Down
2 changes: 1 addition & 1 deletion packages/bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/bootstrap",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "Bootstrap manager for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/cli",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "CLI utilities for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand Down
2 changes: 1 addition & 1 deletion packages/configuration-generator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/configuration-generator",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "Configuration generator for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ export const makeApplication = async (configurationPath: string, options: Record

// @ts-ignore
app.get<Contracts.Crypto.Configuration>(Identifiers.Cryptography.Configuration).setConfig({
milestones: [{ address: addressMilestone, blockTime: 8000, height: 0 }],
milestones: [
{
address: addressMilestone,
height: 0,
timeouts: { blockPrepareTime: 4000, blockTime: 8000, stageTimeout: 2000, stageTimeoutIncrease: 2000 },
},
],
});

app.bind(InternalIdentifiers.Application).toConstantValue(app);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ describe<{
multiPaymentLimit: 256,
reward: "0",
satoshi: match.object,
stageTimeout: 2000,
stageTimeoutIncrease: 2000,
stageTimeoutout: 2000,
stageTimeoutoutIncrease: 2000,
vendorFieldLength: 255,
}),
match({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ describe<{
maxTransactions: 100,
version: 1,
},
blockTime: 8000,
timeouts: {
blockPrepareTime: 4000,
blockTime: 8000,
stageTimeout: 2000,
stageTimeoutIncrease: 2000,
},
epoch: date.toISOString().slice(0, 11) + "00:00:00.000Z",
fees: {
staticFees: {
Expand All @@ -62,8 +67,6 @@ describe<{
decimals: 8,
denomination: 1e8,
},
stageTimeout: 2000,
stageTimeoutIncrease: 2000,
vendorFieldLength: 255,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export class MilestonesGenerator {
maxTransactions: options.maxTxPerBlock,
version: 1,
},
blockTime: options.blockTime,
epoch: options.epoch.toISOString().slice(0, 11) + "00:00:00.000Z",
fees: {
staticFees: {
Expand All @@ -36,8 +35,12 @@ export class MilestonesGenerator {
decimals: 8,
denomination: 1e8,
},
stageTimeout: 2000,
stageTimeoutIncrease: 2000,
timeouts: {
blockPrepareTime: options.blockTime / 2,
blockTime: options.blockTime,
stageTimeout: 2000,
stageTimeoutIncrease: 2000,
},
vendorFieldLength: options.vendorFieldLength,
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/consensus-storage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/consensus-storage",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "Consensus storage for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand Down
2 changes: 1 addition & 1 deletion packages/consensus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mainsail/consensus",
"version": "0.0.1-alpha.16",
"version": "0.0.1-alpha.17",
"description": "Consensus for the Mainsail blockchain",
"license": "GPL-3.0-only",
"contributors": [],
Expand Down
Loading

0 comments on commit a1a754a

Please sign in to comment.