Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support custom chain_id (e.g. for subnets) #1669

Merged
merged 3 commits into from
Jun 10, 2023

Conversation

zone117x
Copy link
Member

@zone117x zone117x commented Jun 10, 2023

Adds a new environment variable that can be used to specify the network (mainnet or testnet) for a given chain_id.

For example, the current subnet testnet chain_id is 0x55005500. This can be configured with the env var:

CUSTOM_CHAIN_IDS=testnet=0x55005500

Multiple values can be configured using comma-separated key-value pairs:

# configure custom testnet and mainnet chainIDs for other networks such as subnets,
# multiple values can be set using comma-separated key-value pairs.
# TODO: currently configured with the default subnet testnet ID, the mainnet values
# are placeholders that should be replaced with the actual subnet mainnet chainID
CUSTOM_CHAIN_IDS=testnet=0x55005500,mainnet=12345678,mainnet=0xdeadbeaf

Implementation

With the introduction of subnets, there is no longer a 1-to-1 mapping between chain_id and network name. For example, it's no longer chain_id(0x00000001) === mainnet, chain_id(0x80000000) === testnet. Any given chain_id can now be either testnet or mainnet. So the const enum mapping between chain_id<->network has been removed, and replaced with a function that determines which network a given chain_id corresponds to.

Because chain_ids for subnets can be configured dynamically / per-deployment, we do not have an known list of mappings. So a new env var has been added which allows deployments to specify chain_id<->network mappings.

@github-actions
Copy link

github-actions bot commented Jun 10, 2023

@github-actions github-actions bot temporarily deployed to pull request June 10, 2023 11:40 Inactive
@codecov
Copy link

codecov bot commented Jun 10, 2023

Codecov Report

Merging #1669 (c02a7bd) into develop (b050b1b) will decrease coverage by 0.29%.
The diff coverage is 41.00%.

@@             Coverage Diff             @@
##           develop    #1669      +/-   ##
===========================================
- Coverage    78.17%   77.89%   -0.29%     
===========================================
  Files           79       79              
  Lines        11241    11296      +55     
  Branches      2495     2528      +33     
===========================================
+ Hits          8788     8799      +11     
- Misses        2339     2376      +37     
- Partials       114      121       +7     
Impacted Files Coverage Δ
src/api/routes/address.ts 88.19% <ø> (ø)
src/api/routes/bns/addresses.ts 100.00% <ø> (ø)
src/api/routes/bns/names.ts 98.86% <ø> (ø)
src/api/routes/rosetta/network.ts 91.22% <ø> (ø)
src/datastore/pg-store.ts 94.10% <ø> (ø)
src/index.ts 0.00% <0.00%> (ø)
src/token-metadata/tokens-processor-queue.ts 86.74% <ø> (ø)
src/event-stream/reader.ts 42.85% <15.62%> (-3.17%) ⬇️
src/helpers.ts 69.73% <27.27%> (-1.99%) ⬇️
src/api/routes/bns/pricing.ts 79.41% <42.85%> (-4.97%) ⬇️
... and 11 more

@github-actions github-actions bot temporarily deployed to pull request June 10, 2023 11:53 Inactive
@github-actions github-actions bot temporarily deployed to commit June 10, 2023 11:54 Inactive
@coveralls
Copy link
Collaborator

Coverage Status

coverage: 77.871%. remained the same when pulling c02a7bd on feat/custom-chain-id into b050b1b on develop.

@zone117x zone117x merged commit 1c6e35a into develop Jun 10, 2023
36 of 37 checks passed
@zone117x zone117x deleted the feat/custom-chain-id branch June 10, 2023 12:08
blockstack-devops pushed a commit that referenced this pull request Jun 10, 2023
## [7.2.0-beta.4](v7.2.0-beta.3...v7.2.0-beta.4) (2023-06-10)

### Features

* support custom chain_id (e.g. for subnets) ([#1669](#1669)) ([1c6e35a](1c6e35a))
@blockstack-devops
Copy link

🎉 This PR is included in version 7.2.0-beta.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

blockstack-devops pushed a commit that referenced this pull request Jul 12, 2023
## [7.3.0](v7.2.2...v7.3.0) (2023-07-12)

### Features

* stacking pool members endpoint ([#1592](#1592)) ([3cd6023](3cd6023)), closes [#465](#465)
* support custom chain_id (e.g. for subnets) ([#1669](#1669)) ([1c6e35a](1c6e35a))
* support for subnets ([#1549](#1549)) ([5d7056c](5d7056c))
* support for subnets ([#1625](#1625)) ([bfac932](bfac932)), closes [#1549](#1549) [#1528](#1528) [#1583](#1583) [#1583](#1583)

### Bug Fixes

* add indexes to pox3_events table used for stacker lookup endpoints ([86304be](86304be))
* disabled BTC faucet endpoint ([#1530](#1530)) ([ce55212](ce55212))
* domain migration ([#1596](#1596)) ([2769e68](2769e68))
* enable requests auto logging ([#1656](#1656)) ([2015b9c](2015b9c))
* fixed the order of microblocks_streamed returned in reverse order in block endpoint ([#1528](#1528)) ([764f64a](764f64a))
* log cleanup ([#1613](#1613)) ([a067e39](a067e39))
* log level issues ([#1605](#1605)) ([c3a2377](c3a2377)), closes [#1603](#1603) [#1603](#1603) [#1604](#1604) [#1604](#1604) [#1452](#1452)
* npm publish step ([#1617](#1617)) ([c9cdbb6](c9cdbb6))
* optimize queries to retrieve BNS names ([#1581](#1581)) ([1a6fde1](1a6fde1))
* use chaintip-cache-control in `/stx_supply` endpoints [#1590](#1590) ([#1594](#1594)) ([a47f153](a47f153))
* use pox3 for `/extended/beta/stacking/...` endpoint ([872f7e6](872f7e6))
* warning logger level for RPC proxy errors ([#1612](#1612)) ([2454932](2454932))
@blockstack-devops
Copy link

🎉 This PR is included in version 7.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants