This blockchain is for educational purposes only and should not be used for production purposes in its current state. As the application matures and meets standards, then at that point it can be used for production purposes.
Images for this project can be found: https://hub.docker.com/r/exilesprx/blockchain
Helper scripts:
- run-build
- this will build an image containing the source files
- tag using the current branch name
- build the bank and miner to ensure no JavaScript issues
- run-test
- this will build a test image with containing the source files
- tag using the current branch name
- runs the tests
- nodemon uses ts-node to run typescript removing the extra step of compiling the code before running
- the build command exists to ensure no errors will present themselves upon run time, so its important to "compile" the source code at some point
TypeScript is used for the source code of the application. The source code is then "compiled" into raw JavaScript and placed in the "build" folder. - commands: - build:miner - build:bank
See: tsconfig.json
Jest is used to test the applicaiton code. However, Babel is required in order to support TypeScript when testing the source code.
Using ts-node allows us to remove compilation of TypeScript files. So we can setup our directories to match.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Blockchain",
"type": "node",
"request": "attach",
"restart": true,
"port": 9229,
"address": "endeavour",
"localRoot": "${workspaceFolder}/src",
"remoteRoot": "/usr/app/src",
"protocol": "inspector",
"sourceMaps": true,
}
]
}
- Database
use eventstoreDBpersist transactions submitted (from API)- persist transactiosn verified (from auditor)
persist mined blocks (from miner)
- App
- Transactions
added to a pool via APIbroadcasts event "transaction added"
- Blockchain
add mined block to chain from streamnote: this chain is only present to add another node for a consensus check
- Transactions
- Miner
- Transactions
added to a pool via streamdetermine if we should create a blockto start use arbitrary rule of "block count > 20"
if yes, create a block and mine
- Blockchain
broadcast event "block mined"add the mined block to the chain from streamif previous block hash doesn't match, then a block proceeded it, so throw it out (we're using a stream with guaranteed ordering)broadcast event "block added"- implement consensus model
- Transactions
- Logger
treat as a featureadd graylogadd winston gelfwrap logger in support class
- Auditor
- Transactions
- compare "generated transactions" vesus "processed transactions"
- should "rebroadcast" so they're appended to the chain
- happens every X seconds/minutes
- Transactions
- Restoration
- Application
- grab the last few block events
- restore the chain with the blocks pulled
- Miner
- Application
- End to end testing
- Scheduler
- Produces transactions every X seconds (start with manual entry at first)
- Scheduler
- Process
update to use nodemonupdate to use ts-nodeupdate to use npm app and npm app:debugremove ts building in container imageuse docker cp or rebuild image to run new changestransition to github actions
- Tests
update the tests to match all the changes madeadd code coverage- increase code coverage with meaningful tests
- Notes
- Consumers/miners
- MULTIPLE CONSUMERS MUST BE ON DIFFERENT GROUPS
- Transactions dropped
- if a transaction is never added to a block, how do we find the transaction? And how do we rebroadcast it?
- Miner
- if block mined event is received, so if its currently mining, if so, stop it, and start mining a new block (if reqs are met)
- Docker build
clean up the build processtargets for container buildssource - foundation of imagemain - includes development source code from mainversion - includes production source code from main, tagged, and packaged for a release version
- Consumers/miners
- Pipelines
update feature.yml to build and use local docker containers because when/if the docker image changes, the code changes need to run against themupdate the build.yml to build the docker source image first and push, then the following steps can use the newly built and pushed images