Skip to content

Commit 59d832c

Browse files
committed
Add chain-type policies and allowlist support
Introduce ChainTypesConfig and AllowlistConfig to support chain-type-level default policies (cache rules and allowlists) while allowing per-chain overrides. Rework caching to key caches by primitives::Chain and derive cache rules from chain types or per-chain config: MemoryCache now accepts ChainTypesConfig and chain configs when created, and RequestCache/CacheProvider interfaces adjusted (removed legacy should_cache). NodeService now enforces allowlists via chain_types and returns HTTP 403 for disallowed requests. Updated config.yml with chain_types entries, added allowlist and chain type cache examples, exported new config types, wired chain_types through main, proxy builder and services, and updated/added tests to reflect the new behavior.
1 parent a96e28f commit 59d832c

18 files changed

Lines changed: 632 additions & 259 deletions

core/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/apps/dynode/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ settings_chain = { path = "../../crates/settings_chain" }
2323
serde_serializers = { path = "../../crates/serde_serializers" }
2424

2525
url = { workspace = true }
26+
uuid = { workspace = true }
2627
gem_auth = { path = "../../crates/gem_auth", features = ["client"] }

core/apps/dynode/config.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,23 @@ retry:
4646

4747
cache:
4848
max_memory_mb: 1024
49-
rules:
50-
ethereum:
49+
50+
chain_types:
51+
ethereum:
52+
allowlist:
53+
- rpc_method: eth_chainId
54+
- rpc_method: eth_sendRawTransaction
55+
cache:
5156
- rpc_method: eth_chainId
5257
ttl: 1h
53-
tron:
58+
bitcoin:
59+
allowlist:
60+
- path: /api/v2/address/**
61+
method: GET
62+
- path: /api/v2/sendtx/
63+
method: POST
64+
tron:
65+
cache:
5466
- path: /wallet/getchainparameters
5567
method: GET
5668
ttl: 1d
@@ -66,24 +78,24 @@ cache:
6678
- path: /wallet/getReward
6779
method: POST
6880
inflight: true
69-
solana:
81+
solana:
82+
cache:
7083
- rpc_method: getVoteAccounts
7184
ttl: 1h
72-
cosmos:
85+
cosmos:
86+
cache:
7387
- path: /cosmos/staking/v1beta1/validators
7488
method: GET
7589
ttl: 1d
76-
bitcoin:
77-
- path: /api/v2/block/**
78-
method: GET
79-
ttl: 0s
80-
hypercore:
90+
hypercore:
91+
cache:
8192
- path: /info
8293
method: POST
8394
ttl: 1h
8495
params:
8596
type: metaAndAssetCtxs
86-
aptos:
97+
aptos:
98+
cache:
8799
- path: /v1/view
88100
method: POST
89101
ttl: 1h

0 commit comments

Comments
 (0)