Skip to content

feat(polygon): Add Polygon PoS Full Node Blueprint using Erigon#236

Merged
frbrkoala merged 1 commit intoaws-samples:mainfrom
snese:feat/polygon-blueprint
Mar 25, 2026
Merged

feat(polygon): Add Polygon PoS Full Node Blueprint using Erigon#236
frbrkoala merged 1 commit intoaws-samples:mainfrom
snese:feat/polygon-blueprint

Conversation

@snese
Copy link
Contributor

@snese snese commented Mar 25, 2026

Add Polygon PoS Full Node Blueprint

Adds a Polygon PoS blueprint under lib/polygon/ using Erigon as a single-container all-in-one client, with both single-node and highly-available deployment options.

Architecture

Uses 0xpolygon/erigon:v3.4.0 (Polygon's fork of Erigon) with --chain=bor-mainnet and --bor.heimdall=https://heimdall-api.polygon.technology. Single container per node, no separate Heimdall node needed.

Why Erigon over Heimdall+Bor: The traditional dual-container approach (Heimdall + Bor) is currently unreliable due to the ongoing Heimdall v1→v2 migration. Erigon provides a simpler, single-container alternative that connects to Polygon's official Heimdall API endpoint. See heimdall-v2#568 for the Docker image issues we found.

What's included

  • CDK Stacks:
    • polygon-common — IAM role, exports
    • polygon-single-node — Single EC2 instance with CloudWatch dashboard (reuses SingleNodeConstruct)
    • polygon-ha-nodes — ALB + ASG multi-AZ HA setup (reuses HANodesConstruct)
  • Config: .env based, with mainnet and amoy sample configs
  • User-data: Docker CE from official repo (with compose plugin), EBS volume detection, Erigon startup, CloudWatch metrics cron (IMDSv2)
  • Security: P2P (30303) and torrent sync (42069) public; RPC (8545) VPC-internal only; --http.vhosts=localhost,127.0.0.1; data dir owned by UID 1000 with mode 750
  • Tests: 4 Jest tests across 2 suites (common stack, cdk-nag, single-node stack, HA nodes stack) — all passing
  • README: Full deployment guide for both single and HA, Well-Architected checklist
  • Website: Docusaurus page at website/docs/Blueprints/Polygon.md
  • CI: Removed polygon from test exclusion list in run-all-cdk-tests.sh

Hardware specs

Network Instance Storage IOPS Throughput Est. cost
Mainnet m7g.4xlarge (Graviton3) 8 TB gp3 16,000 1,000 MB/s ~$1,100/mo per node
Amoy m7g.xlarge (Graviton3) 1 TB gp3 5,000 250 MB/s ~$250/mo per node

Storage specs per Polygon official docs.

Deployment verification

  • Single node: CDK CREATE_COMPLETE (8/8 resources) in us-east-1, Erigon syncing Amoy via OtterSync, 21 peers, RPC responding, Graviton ARM
  • HA nodes: CDK CREATE_COMPLETE (17/17 resources), ALB + ASG with 2 nodes, health checks passing

Key design decisions

  1. Erigon single-container — Avoids Heimdall v1→v2 migration issues entirely. Connects to Polygon's official Heimdall API endpoint.
  2. OtterSync — Erigon's built-in torrent-based snapshot sync. No manual snapshot download needed.
  3. No CreationPolicy/cfn-signal for single-node — Removed to avoid circular dependency with VolumeAttachment. HA stack uses LaunchTemplate (no circular dependency). Node health monitored via CloudWatch.
  4. Docker CE from official repo — Uses docker-compose-plugin instead of standalone binary, no checksum management needed.

Closes #7
Refs #233

@snese snese force-pushed the feat/polygon-blueprint branch from 5464b06 to 6d70dba Compare March 25, 2026 03:01
@snese snese force-pushed the feat/polygon-blueprint branch 7 times, most recently from c084fab to 77b5754 Compare March 25, 2026 04:31
Add Polygon PoS Full Node blueprint under lib/polygon/ using Erigon
(0xpolygon/erigon:v3.4.0) as a single-container all-in-one client.

Stacks:
- polygon-common: IAM role with SSM and CloudWatch policies
- polygon-single-node: single EC2 instance (reuses SingleNodeConstruct)
- polygon-ha-nodes: ALB + ASG multi-AZ HA (reuses HANodesConstruct)

Why Erigon over Heimdall+Bor:
- Heimdall v1->v2 migration breaks P2P for v1 clients on both networks
- Heimdall v2 Docker image has init bugs (reported: 0xPolygon/heimdall-v2#568)
- Erigon connects to Polygon official Heimdall API endpoint instead
- Built-in OtterSync for torrent-based snapshot sync

Includes:
- Config with mainnet and amoy sample .env files
- Security group: P2P (30303), torrent (42069) public; RPC (8545) VPC-only
- User-data: Docker install, EBS volume detection, Erigon startup, CloudWatch cron
- README with deployment guide and Well-Architected checklist
- Website docs page
- Jest tests (3/3 passing), cdk-nag compliant
- package.json for CI integration
- Removed polygon from CI test exclusion list

Deployment verified on Graviton m7g.xlarge in us-east-1.

Closes aws-samples#7
Refs aws-samples#233
@snese snese force-pushed the feat/polygon-blueprint branch from 77b5754 to 394e310 Compare March 25, 2026 04:43
Copy link
Contributor

@frbrkoala frbrkoala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good! Thanks a lot for your contribution!

@frbrkoala frbrkoala merged commit af39953 into aws-samples:main Mar 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run Polygon nodes on AWS

2 participants