Go-Cachecash is a project focusing on decentralized content distribution.
This repository uses git-lfs
for large test data artifacts, among other things; you'll need to install it:
# Ubuntu
apt-get install git-lfs
# macOS
brew install git-lfs
# Archlinux
pacman -S git-lfs
# Windows
Download from https://git-lfs.github.com/
Next, clone the cachecash repo into a folder:
git clone git@github.com:cachecashproject/go-cachecash.git
And initialize git-lfs in that repo:
cd go-cachecash
git lfs install
git lfs fetch
git lfs checkout
Go to /deploy/secret and modify .secret file named after each database container based on template files provided. For example, this is my ledger.secret:
POSTGRES_USER=cachecash
POSTGRES_PASSWORD=cachecashPW
POSTGRES_DB=ledger
LEDGER_DATABASE=host=ledger-db port=5432 user=cachecash password=cachecashPW dbname=ledger sslmode=disable
You will need a working Go toolchain. We tend to stay on the latest stable version.
You will also need some extra code generation tools:
make dev-setup
To generate source from proto files:
make gen
To generate documentation from the proto files:
make gen-docs
To generate all the binaries:
make all
Please notice you need to update your docker-compose to the latest version. Download it here: https://docs.docker.com/compose/compose-file/
For the first time of running, you need to build all images:
docker-compose build
Next, bring up the network:
docker-compose up
If you are having trouble launching the network after building, or if the daemons keep showing errors, you need to examine the network by pull up the network in the background and see the docker containers' status. Use the following command to run the network in background.
docker-compose up -d
Then examine the container's status
docker ps
If any containers exit with code 1, please check the logs
docker logs "daemon name"
It's going to take 1-2 minutes until everything is initialized, this includes the postgres initialization, the caches
announcing themselves to the bootstrap service, the publisher requesting a list of all caches from the bootstrap service
and finally the publisher and the caches negotiating an escrow, and a distributed tracing backend store. After the escrow
is setup you can download from the caches using cachecash-curl
or typescript-cachecash
In this case we're going to build the cachecash-curl
program.'cachecash-curl' is a tool that tests the ability to transfer data between publisher and client. The resulting file
(here, output.bin
) should exactly match the original artifact (here, testdata/content/file0.bin
).
The -logLevel
option can be changed to control output verbosity for each program.
To build cachecash-curl, please run
make ccc
To test
./bin/cachecash-curl -o output.bin -logLevel=debug -trace http://localhost:14268 cachecash://localhost:7070/file0.bin
diff output.bin testdata/content/file0.bin
To get the base image we use for building our software, type make pull-base-image
to receive it. It will be used for all operations around
building and running the software in our development environment.
To build the image yourself:
$ make base-image
If you have write access to our repositories on docker hub, you can also push an updated image:
$ make push-base-image
This is recommended whenever your changes land in the master
branch, but
not before then.
# Remove cached results. (Should not normally be necessary, but can be useful while working on the test suite.)
go clean -testcache
# Run unit and integration tests that do not have external dependencies.
go test -v -race ./...
To run tests that use postgres, you must launch it first; you can use this command to launch your postgres container:
# Make sure dbname and dbports are same as what's in the secret files
docker run -d -p (dbport):5432 --net=cachecash --name=(dbname)-db --env-file ./deploy/secrets/(dbname).secret postgres:11
# Run a test that has external dependencies, including those automatically
# generated by the ORM system.
go test -v -race -tags="external_test sqlboiler_test" ./path/to/test/...
CACHECASH_INSECURE can be set to true for any commands to disable TLS checking against the bootstrap/publisher/observability endpoints. Protocol cryptography is still secure.
There are fuzzing targets that can be used with go-fuzz.
# install dependencies
go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
# start fuzzing
make fuzz