Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 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
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
60 changes: 60 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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 \
${CIPHEROWL_ECR_URL}/cipherowl/circleci:1d37a87f73dd5dfb2c36b6ad25ab48ada1768717 \
/bin/bash -c "sudo chown -R circleci:circleci ~/ && make bootstrap && 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
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
3 changes: 2 additions & 1 deletion cmd/admin/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func init() {

func startWorkflow() error {
workflowIdentity := workflow.GetWorkflowIdentify(workflowFlags.workflow)
workflowId := workflowFlags.workflowID
if workflowIdentity == workflow.UnknownIdentity {
return xerrors.Errorf("invalid workflow: %v", workflowFlags.workflow)
}
Expand All @@ -101,7 +102,7 @@ func startWorkflow() error {
}
defer app.Close()

ctx := context.Background()
ctx := context.WithValue(context.Background(), "workflowId", workflowId)
workflowIdentityString, err := workflowIdentity.String()
if err != nil {
return xerrors.Errorf("error parsing workflowIdentity: %w", err)
Expand Down
Loading