blockfrost / blockfrost-backend-ryo

Blockfrost API backend. You can now Run-Your-Own.
Apache License 2.0
66 stars 17 forks source link

Running on a custom testnet #72

Open klntsky opened 1 year ago

klntsky commented 1 year ago

I noticed that in the config we can only specify one of the known networks. How hard would it be to run Blockfrost on a custom private testnet? We definitely need it for our plans of supporting Blockfrost backend in cardano-transaction-library.

mmahut commented 1 year ago

Probably not very hard - you would need some changes to support custom getConfig().network. That being said, I'm not sure if anyone has ever tried it on a custom testnet.

vladimirvolek commented 1 year ago

Just search getConfig().network.

Affected endpoints are:

/epochs/latest/index.ts /epochs/number/index.ts /epochs/number/next.ts /ledger /network and validation functions in /utils.

It should be pretty straightforward. Is that good enough for you?

klntsky commented 1 year ago

They are hardcoded deeply: https://github.com/blockfrost/blockfrost-backend-ryo/blob/1a513e4f37bcf8072663a70d11289ec63ca8c39f/src/types/common.ts#L8

klntsky commented 1 year ago

Would you accept a PR that adds the ability to run on a custom testnet?

1000101 commented 1 year ago

I'm probably a little late to the party, but this may also require a change in validation utils.

klntsky commented 1 year ago

@1000101 True. We have a tool called plutip that spawns clusters with network ID set to mainnet, but the network is using very different parameters, so we need to support this case. The validation module relies on the assumption that network name is set to mainnet if and only if the network ID is also mainnet. And network names are tied to particular network configurations.

But there is no concept of network name in cardano domain, there is only ID and protocol parameters.

Network names are something more ad hoc, they are basically defined by whatever is put into this repo: https://github.com/input-output-hk/cardano-configurations

I think the best way to move forward would be to:

vladimirvolek commented 1 year ago

I will look into this.

vladimirvolek commented 1 year ago

@klntsky Do you have something already?

klntsky commented 1 year ago

@vladimirvolek I started looking into this deeper and realized that the implicit assumption propagates to @blockfrost/blockfrost-utils, so either the validator utils should be changed to accept a network ID (0 = testnet, 1 = mainnet) instead of network name, or I'll have to add code that works around the fact they expect one of 4 variants and "guesses" the correct network name given an ID.

lemmon-714 commented 1 year ago

bump