Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
fc307da
fix reportingInterval for tally
ImNumber4 Jan 25, 2024
8512a5b
switch to log.debug for success with filter case
ImNumber4 Jan 27, 2024
219f43a
Merge remote-tracking branch 'upstream/master'
HenryYYang Feb 26, 2024
14f2192
fix broken workflow
HenryYYang Feb 26, 2024
d7c72a5
fix broken workflow
HenryYYang Feb 26, 2024
11f2b57
Merge branch 'coinbase:master' into master
leozc Mar 21, 2024
0a12563
Merge branch 'coinbase:master' into master
leozc Apr 5, 2024
4f394ca
fix merge error for workflow
aegis-cipherowl May 24, 2024
ccba1e0
Merge pull request #3 from cipherowl-ai/fix_merge_error
aegis-cipherowl May 25, 2024
65ac455
TIT-157 Support BCH and LTC
samsuse Jun 12, 2024
bb741c2
Support ltc mweb address type
samsuse Jun 18, 2024
d262ccd
validate ltc script pubkey
samsuse Jun 18, 2024
d174bd6
add metrics for replicator
Jun 26, 2024
a1f4a94
Figure out the gap and timeSinceLastBlock in replicator execution pha…
Jun 26, 2024
cd19fad
update watermark
Jun 26, 2024
6a844c3
TIT-158 Continuous sync replicator
samsuse Jun 27, 2024
af50ed5
involve channel
Jun 27, 2024
7bb4cdf
fix updateWatermark bug
Jun 28, 2024
08fa6ca
Add new activity to fetch latest block
samsuse Jun 29, 2024
81cdad9
Add logger
samsuse Jun 29, 2024
bf13d3d
Fix nil pointer
samsuse Jun 30, 2024
9393c5a
Merge pull request #6 from cipherowl-ai/replicator-metrics
BarryLiii Jul 2, 2024
f7dcdc2
Merge pull request #4 from cipherowl-ai/TIT-157-support-bch-and-ltc
samsuse Jul 2, 2024
ec2ddce
Review issue fixes
samsuse Jul 2, 2024
6f455ac
Merge remote-tracking branch 'origin/master' into TIT-158-continuous-…
samsuse Jul 2, 2024
e1197df
Reformat code
samsuse Jul 2, 2024
7178a3a
Merge pull request #8 from cipherowl-ai/TIT-158-continuous-replicator
samsuse Jul 2, 2024
07f75a4
Update README.md (#103)
xiaying-peng Jun 12, 2024
9b19f71
feat: Remove sdk address (#105)
wangwzhou Sep 20, 2024
886793e
feat: Port ethereum beacon support (#104)
wangwzhou Sep 20, 2024
9e69cd6
feat: Port blockchains client/parser changes (#106)
wangwzhou Sep 23, 2024
ddb6a37
Port workflow-related changes (#107)
wangwzhou Sep 24, 2024
74176d2
Merge pull request #15 from cipherowl-ai/merge_upstream
aegis-cipherowl Jan 17, 2025
06a83e6
Add support for Tron
PikaZ76 Nov 6, 2024
ef92e0d
Merge pull request #13 from PikaZ76/feature/Tron
zhanwu Jan 24, 2025
06e502b
Support story protocol
BarryLiii Feb 6, 2025
4158486
Support story protocol
BarryLiii Feb 6, 2025
408b874
Support story protocol
BarryLiii Feb 6, 2025
6b5f8eb
Support story protocol
BarryLiii Feb 7, 2025
48a8f1f
Support story protocol
BarryLiii Feb 7, 2025
55468eb
Support story protocol
BarryLiii Feb 10, 2025
48588a4
Support story protocol
BarryLiii Feb 10, 2025
7363261
Support story protocol
BarryLiii Feb 10, 2025
5c03697
Support story protocol
BarryLiii Feb 10, 2025
69dd118
Support story protocol
BarryLiii Feb 11, 2025
f410447
add nft header
samsuse Feb 12, 2025
fc8b110
Merge pull request #16 from cipherowl-ai/support-story
BarryLiii Feb 14, 2025
5e4dc9e
Merge pull request #18 from cipherowl-ai/add-nft-header
samsuse Feb 14, 2025
e1a04e9
support ZSTD compression
PikaZ76 Feb 13, 2025
ac7a907
put GetObjectKey as method into Compressor
PikaZ76 Feb 18, 2025
0ebb892
Merge pull request #19 from PikaZ76/featrue/zstd-compress
aegis-cipherowl Feb 18, 2025
c1c215d
transform Hash and Account Address into Tronscan format
PikaZ76 Feb 24, 2025
ff41177
generate the python code from proto
zhanwu Mar 2, 2025
5b5556f
Merge pull request #23 from cipherowl-ai/python
zhanwu Mar 3, 2025
efe1ecc
Merge pull request #20 from PikaZ76/fix/TronAccountAddress
aegis-cipherowl Mar 6, 2025
e2e6ca9
Integrate with CircleCI
samsuse Mar 7, 2025
0e2e610
Skip failed tests
samsuse Mar 10, 2025
7c4feaf
uncomment failed test
samsuse Mar 10, 2025
2493d39
add fields for TransactionReceipt of Tron;
PikaZ76 Mar 19, 2025
12a008e
Merge pull request #27 from PikaZ76/fix/add_tron_fields
leozc Mar 24, 2025
62edbdb
Merge pull request #24 from cipherowl-ai/circleci-pipeline
leozc Mar 24, 2025
02cab46
merge latest from coinbase repo
PikaZ76 Mar 27, 2025
6d8b58b
fix tron error check
PikaZ76 Mar 27, 2025
3380eeb
Merge pull request #28 from PikaZ76/sync-coinbase
PikaZ76 Mar 27, 2025
49aaae0
start multiple backfiller
BarryLiii Mar 17, 2025
150569e
Merge pull request #26 from cipherowl-ai/start-multiple-bf
BarryLiii Mar 27, 2025
2cb73ca
fix ci issues
samsuse Apr 2, 2025
6a42458
Merge pull request #29 from cipherowl-ai/fix-ci-issues
samsuse Apr 3, 2025
71b347b
use python grpcio-tools to generate python code
zhanwu Apr 16, 2025
072e4c2
Merge pull request #30 from cipherowl-ai/python
zhanwu Apr 16, 2025
bc6280d
fix overwrite bug in Tron Nativate Parser
PikaZ76 May 2, 2025
094136d
Merge pull request #32 from PikaZ76/fix/TronMetaDataBlockHash
PikaZ76 May 7, 2025
c3a8f49
Validate Anchor Type
samsuse May 9, 2025
b5f400b
replace github.com/coinbase/rosetta-sdk-go with github.com/coinbase/m…
aegis-cipherowl May 14, 2025
3ca0283
fix codegen
aegis-cipherowl May 14, 2025
5e74433
Merge pull request #34 from cipherowl-ai/fix-rosett-to-mesh
aegis-cipherowl May 14, 2025
d0bad9a
Merge pull request #33 from cipherowl-ai/Validate-PayToAnchor
samsuse May 20, 2025
250f5e6
fix-vuls
samsuse Jun 5, 2025
a840823
feat(tally): add prometheus metrics reporter
dnjp Jun 9, 2025
9336fed
Merge pull request #36 from dnjp/feat/prometheus-reporter
aegis-cipherowl Jun 10, 2025
0855fb6
Merge pull request #35 from cipherowl-ai/fix-vuls
leozc Jun 12, 2025
ab92867
fix tron parser of internal Tx for only native token
PikaZ76 Jun 18, 2025
c4537d4
Merge pull request #37 from cipherowl-ai/fix/TronNativeTokenInInternalTx
PikaZ76 Jun 19, 2025
5807490
docs: add CLAUDE.md development guide
leozc Jun 29, 2025
6f85fb7
docs: add ChainStorage component diagram
leozc Jun 29, 2025
e8c4266
docs: improve component diagram readability
leozc Jun 29, 2025
f3817f2
docs: apply Nord color palette to component diagrams
leozc Jun 29, 2025
944d350
docs: add blockchain data searchability enhancement proposal
leozc Jun 29, 2025
4ab2c21
Merge pull request #49 from cipherowl-ai/leozc/inf-187-add-claudemd-d…
leozc Jul 4, 2025
c534b9d
get tx contract Type as Tx Type for Tron to tell native Token or TRC1…
PikaZ76 Jul 11, 2025
f5ef055
add call type setting
PikaZ76 Jul 13, 2025
30778c9
fix review comment
PikaZ76 Jul 13, 2025
0e3c361
Merge pull request #54 from cipherowl-ai/fix/tron_tx_type
PikaZ76 Jul 13, 2025
fb48448
- Fix golang.org/x/net:v0.34.0/CVE-2025-22870
samsuse Jul 23, 2025
b20fe65
Feature/postgres metadata (#52)
WilliamChenn Aug 12, 2025
f39d0c9
Update/migrator workflow (#56)
WilliamChenn Aug 14, 2025
66d8c84
Merge remote-tracking branch 'origin/master' into update-deps-for-vuls
samsuse Aug 14, 2025
1a5b0e0
Update/migrator workflow (#57)
WilliamChenn Aug 15, 2025
40f710e
Refactor/migrator sorting (#58)
WilliamChenn Aug 19, 2025
1fea9a9
Merge pull request #55 from cipherowl-ai/update-deps-for-vuls
aegis-cipherowl Aug 19, 2025
28fb166
Refactor/migrator multi reorgs (#59)
WilliamChenn Aug 19, 2025
b164941
change to optional for pg configs
WilliamChenn Aug 19, 2025
6b3b0dc
removed postgres required
WilliamChenn Aug 19, 2025
50a1d74
removed aws config require for storage type
WilliamChenn Aug 19, 2025
b7cd3cb
removed validate required
WilliamChenn Aug 19, 2025
a157577
Merge pull request #61 from cipherowl-ai/fix/optional_pg_configs
aegis-cipherowl Aug 19, 2025
6591a67
ptr
WilliamChenn Aug 19, 2025
f9668df
added tests and validate
WilliamChenn Aug 19, 2025
8502382
check for nil
WilliamChenn Aug 19, 2025
e06283d
config test nil checks
WilliamChenn Aug 19, 2025
c9d50b6
Merge pull request #62 from cipherowl-ai/fix/env
aegis-cipherowl Aug 19, 2025
050f89b
allow
WilliamChenn Aug 20, 2025
8b32d32
Merge pull request #63 from cipherowl-ai/fix/reuse_policy
PikaZ76 Aug 20, 2025
eead77f
add ethereum classis client and parser
PikaZ76 Aug 18, 2025
469651f
fix client and parser
PikaZ76 Aug 27, 2025
ee2754d
update dbinit to grab correct master credentials
WilliamChenn Aug 27, 2025
bebb93a
Merge pull request #69 from cipherowl-ai/update/dbinit_command
PikaZ76 Aug 27, 2025
828f7fc
Merge pull request #71 from PikaZ76/feature/ethereum-classic
PikaZ76 Aug 28, 2025
5455ee8
always run migrations (#72)
WilliamChenn Sep 4, 2025
12b5f2d
Fix chain continuity errors during reorg in RDS metadata storage
aegis-cipherowl Sep 18, 2025
efab901
fix lint
aegis-cipherowl Sep 18, 2025
738cd42
Merge pull request #73 from cipherowl-ai/fix/rds-reorg-chain-continuity
aegis-cipherowl Sep 19, 2025
3b48fb7
Refactor/migration_event continuity (#64)
WilliamChenn Sep 19, 2025
c01ce58
add validation, deleted deprecated migration sequence plan
WilliamChenn Sep 19, 2025
864dab6
Update internal/workflow/activity/migrator.go
WilliamChenn Sep 19, 2025
a0740d2
add New chain: Plasma
PikaZ76 Sep 24, 2025
db9f06c
Merge pull request #75 from PikaZ76/feature/plasma
PikaZ76 Sep 24, 2025
eecb409
Merge pull request #76 from cipherowl-ai/feature/plasma-dev
PikaZ76 Sep 24, 2025
0216379
fix: add more frequent heartbeats in syncer activity to prevent timeouts
aegis-cipherowl Sep 26, 2025
1d43881
Merge pull request #77 from cipherowl-ai/fix/syncer-heartbeat-timeout
PikaZ76 Sep 26, 2025
f260d96
drop duplicate requests
PikaZ76 Sep 27, 2025
ecdd469
add test case for default txBatchSize
PikaZ76 Sep 27, 2025
051ec26
fix txIDSet with bool as value
PikaZ76 Sep 29, 2025
0551fd5
Merge pull request #78 from PikaZ76/fix/bitcoin-duplicate-tx-request
PikaZ76 Sep 29, 2025
02e4cf6
Merge pull request #74 from cipherowl-ai/update/add_valiation
aegis-cipherowl Oct 29, 2025
410ba10
fix: Add watermark-based visibility control for Postgres metastorage
aegis-cipherowl Oct 29, 2025
8d3b5c2
test: Add comprehensive tests for watermark visibility control
aegis-cipherowl Oct 29, 2025
3ad589c
Optimize watermark initialization query using CTE
aegis-cipherowl Oct 29, 2025
725014e
fix lint
aegis-cipherowl Oct 30, 2025
dd5d2bb
fix lint
aegis-cipherowl Oct 30, 2025
4c66694
Merge pull request #80 from cipherowl-ai/fix/postgres-watermark-reorg…
PikaZ76 Oct 30, 2025
744ad1f
fix compression in replicator
PikaZ76 Nov 19, 2025
3adfaec
Merge pull request #81 from cipherowl-ai/fix/replictor_compression
PikaZ76 Nov 20, 2025
4172add
fix replicator to process skipped blocks
PikaZ76 Nov 23, 2025
75dc199
fix
PikaZ76 Nov 24, 2025
514a546
Merge pull request #82 from cipherowl-ai/fix/replicator-skipped-blocks
PikaZ76 Nov 25, 2025
9ba055c
retry workflow for create temporal session failure by continue as new
PikaZ76 Nov 26, 2025
3b94d65
fix
PikaZ76 Nov 26, 2025
4a91f78
Merge pull request #83 from PikaZ76/fix/retry-for-createSession-failure
PikaZ76 Nov 27, 2025
99870d9
add monad
PikaZ76 Nov 27, 2025
4995231
fix poller workflow wait
PikaZ76 Nov 27, 2025
2027ba4
fix comment
PikaZ76 Nov 27, 2025
8937b0c
Merge pull request #84 from cipherowl-ai/feature/evm-monad
PikaZ76 Nov 27, 2025
fcf3b8e
add megaeth
PikaZ76 Dec 26, 2025
8c3eeaf
Merge pull request #86 from cipherowl-ai/feature/megaeth
PikaZ76 Dec 26, 2025
aadc5dc
add abstract
PikaZ76 Dec 26, 2025
4070a72
Merge pull request #87 from cipherowl-ai/feature/abstract
PikaZ76 Dec 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: 2.1
jobs:
build_and_test:
docker:
- image: ${CIPHEROWL_ECR_URL}/cipherowl/circleci:1d37a87f73dd5dfb2c36b6ad25ab48ada1768717
working_directory: ~/chainstorage
steps:
- checkout
- setup_remote_docker:
version: default
- run:
name: Install dependencies
command: |
set +x
make bootstrap
- run:
name: Run unit tests
command: "make test"
- run:
name: Run integration tests
command: |
set +x

docker-compose -f docker-compose-testing.yml up -d --force-recreate
sleep 10

# Due to how the remote docker engine works with docker-compose
# in circleci, we have to run our integration tests from
# a remote container so that the tests can access network services
# spun up by docker-compose.
docker create -v /home/circleci --name chainstorage alpine:3.21 /bin/true
# docker cp /home/circleci/go chainstorage:/home/circleci/go
docker cp /home/circleci/chainstorage chainstorage:/home/circleci/chainstorage

docker run --network chainstorage_default \
--volumes-from chainstorage \
-w /home/circleci/chainstorage \
-e CHAINSTORAGE_AWS_POSTGRES_HOST=postgres \
-e CHAINSTORAGE_AWS_POSTGRES_PORT=5432 \
-e CHAINSTORAGE_AWS_POSTGRES_USER=postgres \
-e CHAINSTORAGE_AWS_POSTGRES_PASSWORD=postgres \
-e CHAINSTORAGE_AWS_POSTGRES_DATABASE=postgres \
${CIPHEROWL_ECR_URL}/cipherowl/circleci:1d37a87f73dd5dfb2c36b6ad25ab48ada1768717 \
/bin/bash -c "sudo chown -R circleci:circleci ~/ && make bootstrap && \
echo '🔧 Test databases already set up by init script' && \
TEST_TYPE=integration go test ./... -v -p=1 -parallel=1 -timeout=15m -failfast -run=TestIntegration"
- run:
name: Run functional tests
command: |
set +x
echo "functional tests skipped"

# docker run --network chainstorage_default \
# --volumes-from chainstorage \
# -w /home/circleci/chainstorage \
# ${CIPHEROWL_ECR_URL}/cipherowl/circleci:1d37a87f73dd5dfb2c36b6ad25ab48ada1768717 \
# /bin/bash -c "sudo chown -R circleci:circleci ~/ && make bootstrap && TEST_TYPE=functional go test ./... -v -p=1 -parallel=1 -timeout=45m -failfast -run=TestIntegration"

docker-compose -f docker-compose-testing.yml down

workflows:
version: 2
default:
jobs:
- build_and_test:
name: build_and_test
context: cipherowl_build_context
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
# pg
postgres_*

# ignore all files in dev-data/
dev-data/

# ignore binaries
/scripts/bin
173 changes: 173 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# ChainStorage Development Guide

This guide helps Claude understand the ChainStorage project structure and common development tasks.

## Project Overview

ChainStorage is a blockchain data storage and processing system that:
- Continuously replicates blockchain changes (new blocks)
- Acts as a distributed file system for blockchain data
- Stores raw data in horizontally-scalable storage (S3 + DynamoDB)
- Supports multiple blockchains: Ethereum, Bitcoin, Solana, Polygon, etc.
- Can serve up to 1,500 blocks per second in production

## Key Commands

### Testing
```bash
# Run all unit tests
make test

# Run specific package tests
make test TARGET=internal/blockchain/...

# Run integration tests
make integration TARGET=internal/storage/...

# Run functional tests (requires secrets.yml)
make functional TARGET=internal/workflow/...
```

### Linting and Type Checking
```bash
# Run linter (includes go vet, errcheck, ineffassign)
make lint
# Note: May encounter errors with Go versions > 1.22

# No separate typecheck command - type checking happens during build
```

### Building
```bash
# Initial setup (once)
make bootstrap

# Build everything
make build

# Generate protobuf files
make proto

# Generate configs from templates
make config
```

### Local Development
```bash
# Start local infrastructure (LocalStack)
make localstack

# Start server (Ethereum mainnet)
make server

# Start server (other networks)
make server CHAINSTORAGE_CONFIG=ethereum_goerli
```

## Project Structure

```
/cmd/ - Command line tools
/admin/ - Admin CLI tool
/api/ - API server
/server/ - Main server
/worker/ - Worker processes

/internal/ - Core implementation
/blockchain/ - Blockchain clients and parsers
/client/ - Chain-specific clients
/parser/ - Chain-specific parsers
/storage/ - Storage implementations
/blobstorage/ - S3/GCS storage
/metastorage/ - DynamoDB/Firestore storage
/workflow/ - Temporal workflows
/activity/ - Workflow activities

/config/ - Generated configurations
/config_templates/ - Configuration templates
/protos/ - Protocol buffer definitions
/sdk/ - Go SDK for consumers
```

## Key Workflows

1. **Backfiller**: Backfills historical blocks
2. **Poller**: Polls for new blocks continuously
3. **Streamer**: Streams blocks in real-time
4. **Monitor**: Monitors system health
5. **Benchmarker**: Benchmarks performance

## Environment Variables

- `CHAINSTORAGE_NAMESPACE`: Service namespace (default: chainstorage)
- `CHAINSTORAGE_CONFIG`: Format: `{blockchain}-{network}` (e.g., ethereum-mainnet)
- `CHAINSTORAGE_ENVIRONMENT`: Environment (local/development/production)

## Common Tasks

### Adding Support for New Blockchain
1. Create config templates in `/config_templates/chainstorage/{blockchain}/{network}/`
2. Implement client in `/internal/blockchain/client/{blockchain}/`
3. Implement parser in `/internal/blockchain/parser/{blockchain}/`
4. Run `make config` to generate configs
5. Add tests

### Debugging LocalStack Services
```bash
# Check S3 files
aws s3 --no-sign-request --region local --endpoint-url http://localhost:4566 ls --recursive example-chainstorage-ethereum-mainnet-dev/

# Check DynamoDB
aws dynamodb --no-sign-request --region local --endpoint-url http://localhost:4566 scan --table-name example_chainstorage_blocks_ethereum_mainnet

# Check SQS DLQ
aws sqs --no-sign-request --region local --endpoint-url http://localhost:4566 receive-message --queue-url "http://localhost:4566/000000000000/example_chainstorage_blocks_ethereum_mainnet_dlq"
```

### Working with Temporal Workflows
```bash
# Start backfiller
go run ./cmd/admin workflow start --workflow backfiller --input '{"StartHeight": 11000000, "EndHeight": 11000100}' --blockchain ethereum --network mainnet --env local

# Start poller
go run ./cmd/admin workflow start --workflow poller --input '{"Tag": 0, "MaxBlocksToSync": 100}' --blockchain ethereum --network mainnet --env local

# Check workflow status
tctl --address localhost:7233 --namespace chainstorage-ethereum-mainnet workflow show --workflow_id workflow.backfiller
```

## Important Notes

1. **Always run tests before committing**: Use `make test` and `make lint`
2. **Config generation**: After modifying templates, run `make config`
3. **Secrets**: Never commit `secrets.yml` files (used for endpoint configurations)
4. **Endpoint groups**: Master (sticky) for canonical chain, Slave (round-robin) for data ingestion
5. **Parser types**: Native (default), Mesh, or Raw

## Dependencies

- Go 1.22 (required - newer versions may cause lint errors)
- Protobuf 25.2
- Temporal (workflow engine)
- LocalStack (local AWS services)
- Docker & Docker Compose

## Architecture Insights

### Client Architecture
- **Multi-endpoint system**: Master (primary), Slave (load distribution), Validator, Consensus
- **Protocol support**: JSON-RPC (most chains) and REST API (Rosetta)
- **Shared implementations**: EVM chains (Polygon, BSC, Arbitrum) share Ethereum client code
- **Factory pattern**: Each blockchain has a client factory registered with dependency injection

### Key Design Patterns
1. **Interceptor Pattern**: Wraps clients for instrumentation and parsing
2. **Option Pattern**: Modifies client behavior (e.g., WithBestEffort())
3. **Batch Processing**: Configurable batch sizes for performance
4. **Error Handling**: Standardized errors with network-specific handling

### Supported Blockchains
- **EVM-based**: Ethereum, Polygon, BSC, Arbitrum, Optimism, Base, Fantom, Avalanche
- **Bitcoin-based**: Bitcoin, Bitcoin Cash, Dogecoin, Litecoin
- **Other**: Solana, Aptos, Tron
- **Special**: Ethereum Beacon Chain support
Loading