Skip to content

Commit

Permalink
dockerfile updates for archive node (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
mechanical-turk authored May 31, 2024
1 parent e7bca36 commit 2e088a9
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 9 deletions.
8 changes: 6 additions & 2 deletions core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ARG VER_VERSION=version_unset
ARG VER_BRANCH=branch_unset
ARG VER_COMMIT=commit_unset

ARG RUN_MODE=full

# Prepare build environment
WORKDIR /build
COPY node node
Expand Down Expand Up @@ -39,7 +41,9 @@ LABEL org.opencontainers.image.title="River Node" \
RUN apk add --no-cache libcap supervisor && \
adduser -D riveruser

COPY supervisord.conf /etc/supervisord.conf
COPY run.sh /etc/run.sh
COPY full_node.supervisord.conf /etc/full_node.supervisord.conf
COPY archive_node.supervisord.conf /etc/archive_node.supervisord.conf
COPY --from=builder /bin/stream_node /usr/bin/stream_node
COPY --from=builder /bin/xchain_node /usr/bin/xchain_node

Expand All @@ -66,4 +70,4 @@ ARG DD_GIT_REPOSITORY_URL="https://github.com/river-build/river"
ENV DD_GIT_REPOSITORY_URL=${DD_GIT_REPOSITORY_URL} \
DD_GIT_COMMIT_SHA=${GIT_SHA}

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
CMD ["sh", "/etc/run.sh"]
18 changes: 18 additions & 0 deletions core/archive_node.supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[supervisord]
logfile=/riveruser/supervisord/logs/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/riveruser/supervisord/logs/supervisord.pid
nodaemon=true
loglevel=info
logfile=/dev/stdout
logfile_maxbytes=0

[program:archive_node]
command=/usr/bin/stream_node archive
directory=/riveruser/stream_node
autostart=true
autorestart=false
user=riveruser
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
3 changes: 2 additions & 1 deletion core/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ services:
- DATABASE__PASSWORD=postgres
- DATABASE__EXTRA=?sslmode=disable&pool_max_conns=1000
- DATABASE__HOST=host.docker.internal
- RUN_MODE=archive
- ARCHIVE__ARCHIVEID=1
- DATABASE__PORT=5433
- LOG__FORMAT=json
- LOG__NOCOLOR=true
Expand All @@ -28,7 +30,6 @@ services:
- USEBLOCKCHAINSTREAMREGISTRY=true
- BASECHAIN__NETWORKURL=http://host.docker.internal:8545
- RIVERCHAIN__NETWORKURL=http://host.docker.internal:8546
- WALLETPRIVATEKEY=51e02cbb807a535b05ae02f15cc3cbf73950e61d6dde55b3a77ad2be8815147c
- ARCHITECTCONTRACT__ADDRESS=0x2552FcE4D398492E4fd063e6aA77186e5c6d0EF1
- REGISTRYCONTRACT__ADDRESS=0x531Faa70a60e151d20395E0E4ce9A32FB767Ca00
- ENTITLEMENT_CONTRACT__ADDRESS=0x2bdCC0de6bE1f7D2ee689a0342D76F52E8EFABa3
File renamed without changes.
6 changes: 3 additions & 3 deletions core/node/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ type ArchiveConfig struct {
Filter FilterConfig

// Number of miniblocks to read at once from the remote node.
ReadMiniblcocksSize uint64
ReadMiniblocksSize uint64

DisablePrintStats bool
PrintStatsPeriod time.Duration // If 0, default to 1 minute.
Expand Down Expand Up @@ -250,10 +250,10 @@ type MetricsConfig struct {
}

func (ac *ArchiveConfig) GetReadMiniblocksSize() uint64 {
if ac.ReadMiniblcocksSize <= 0 {
if ac.ReadMiniblocksSize <= 0 {
return 100
}
return ac.ReadMiniblcocksSize
return ac.ReadMiniblocksSize
}

func (ac *ArchiveConfig) GetPrintStatsPeriod() time.Duration {
Expand Down
10 changes: 10 additions & 0 deletions core/node/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,14 @@ test_contract:
address: ''
version: '3'

archive:
archiveId: ''
# filter: ''
# readMiniblocksSize: ''
# disablePrintStats: ''
printStatsPeriod: '10s'
# taskQueueSize: ''
# workerPoolSize: ''
# streamsContractCallPageSize: ''

enableDebugEndpoints: false
6 changes: 3 additions & 3 deletions core/node/rpc/archiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func TestArchiveOneStream(t *testing.T) {

archiveCfg := tester.getConfig()
archiveCfg.Archive.ArchiveId = "arch" + GenShortNanoid()
archiveCfg.Archive.ReadMiniblcocksSize = 3
archiveCfg.Archive.ReadMiniblocksSize = 3

chainMonitor := tester.btc.ChainMonitor
bc := tester.btc.NewWalletAndBlockchain(ctx)
Expand Down Expand Up @@ -355,7 +355,7 @@ func TestArchive100StreamsWithData(t *testing.T) {

archiveCfg := tester.getConfig()
archiveCfg.Archive.ArchiveId = "arch" + GenShortNanoid()
archiveCfg.Archive.ReadMiniblcocksSize = 3
archiveCfg.Archive.ReadMiniblocksSize = 3

listener, err := net.Listen("tcp", "localhost:0")
require.NoError(err)
Expand Down Expand Up @@ -403,7 +403,7 @@ func TestArchiveContinuous(t *testing.T) {

archiveCfg := tester.getConfig()
archiveCfg.Archive.ArchiveId = "arch" + GenShortNanoid()
archiveCfg.Archive.ReadMiniblcocksSize = 3
archiveCfg.Archive.ReadMiniblocksSize = 3

listener, err := net.Listen("tcp", "localhost:0")
require.NoError(err)
Expand Down
16 changes: 16 additions & 0 deletions core/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -euo pipefail

if [ -z "$RUN_MODE" ]; then
echo "RUN_MODE is not set"
exit 1
elif [ "$RUN_MODE" == "full" ]; then
echo "Running full node"
exec /usr/bin/supervisord -c /etc/full_node.supervisord.conf
elif [ "$RUN_MODE" == "archive" ]; then
echo "Running archive node"
exec /usr/bin/supervisord -c /etc/archive_node.supervisord.conf
else
echo "Unknown RUN_MODE: $RUN_MODE"
exit 1
fi

0 comments on commit 2e088a9

Please sign in to comment.