mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
Dial /v1, the only prefix luxd serves
luxd pins baseURL="/v1" (node/server/http/server.go:33) and has never served /ext, so both exported constructors — plugin/evm/client.NewClient and warp.NewClient — built a path no node answers. They are the seam every out-of-tree caller goes through: cli/pkg/utils/staking.go, sdk/validatormanager/uptime.go and netrunner/api all hand them a bare node URI, and staking.go's own SplitRPCURI already parsed /v1/bc/<id>/rpc. Those callers were already on /v1; this package was the lagging outlier, so fixing it here fixes all of them without touching one. Also corrects the simulator's default websocket endpoint, the hardhat default, and the docs — including api.testnet.lux.network, which does not serve RPC at all. The testnet host is api.lux-test.network (chainId 0x17870). Prefix-only sweeps miss that class of error. Tests pin the constructed path against an httptest server, with both an alias and a blockchain ID, so a future prefix change fails loudly instead of silently 404ing in production. Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
@@ -45,7 +45,7 @@ The `--sybil-protection-enabled=false` flag is only suitable for local testing.
|
||||
1. Ignore stake weight on the P-Chain and count each connected peer as having a stake weight of 1
|
||||
2. Automatically opts in to validate every Subnet
|
||||
|
||||
Once you have Luxd running locally, it will be running an HTTP Server on the default port `9650`. This means that the RPC Endpoint for the C-Chain will be http://127.0.0.1:9650/ext/bc/C/rpc and ws://127.0.0.1:9650/ext/bc/C/ws for WebSocket connections.
|
||||
Once you have Luxd running locally, it will be running an HTTP Server on the default port `9650`. This means that the RPC Endpoint for the C-Chain will be http://127.0.0.1:9650/v1/bc/C/rpc and ws://127.0.0.1:9650/v1/bc/C/ws for WebSocket connections.
|
||||
|
||||
Now, we can run the simulator command to simulate some load on the local C-Chain for 30s:
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ func BuildFlagSet() *pflag.FlagSet {
|
||||
func addSimulatorFlags(fs *pflag.FlagSet) {
|
||||
fs.Bool(VersionKey, false, "Print the version and exit")
|
||||
fs.String(ConfigFilePathKey, "", "Specify the config path to use to load a YAML config for the simulator")
|
||||
fs.StringSlice(EndpointsKey, []string{"ws://127.0.0.1:9630/ext/bc/C/ws"}, "Specify a comma separated list of RPC Websocket Endpoints (minimum of 1 endpoint)")
|
||||
fs.StringSlice(EndpointsKey, []string{"ws://127.0.0.1:9630/v1/bc/C/ws"}, "Specify a comma separated list of RPC Websocket Endpoints (minimum of 1 endpoint)")
|
||||
fs.Int64(MaxFeeCapKey, 50, "Specify the maximum fee cap to use for transactions denominated in GWei (must be > 0)")
|
||||
fs.Int64(MaxTipCapKey, 1, "Specify the max tip cap for transactions denominated in GWei (must be >= 0)")
|
||||
fs.Uint64(TxsPerWorkerKey, 100, "Specify the number of transactions to create per worker (must be > 0)")
|
||||
|
||||
+4
-4
@@ -53,14 +53,14 @@ In EVM, we provide a pre-configured file [hardhat.config.ts](https://github.com/
|
||||
The HardHat config file includes a single network configuration: `local`. `local` defaults to using the following values for the RPC URL and the Chain ID:
|
||||
|
||||
```js
|
||||
var local_rpc_uri = process.env.RPC_URI || "http://127.0.0.1:9650/ext/bc/C/rpc";
|
||||
var local_rpc_uri = process.env.RPC_URI || "http://127.0.0.1:9650/v1/bc/C/rpc";
|
||||
var local_chain_id = process.env.CHAIN_ID || 99999;
|
||||
```
|
||||
|
||||
You can use this network configuration by providing the environment variables and specifying the `--network` flag, as EVM does in its testing suite:
|
||||
|
||||
```bash
|
||||
RPC_URI=http://127.0.0.1:9650/ext/bc/28N1Tv5CZziQ3FKCaXmo8xtxoFtuoVA6NvZykAT5MtGjF4JkGs/rpc CHAIN_ID=77777 npx hardhat test --network local
|
||||
RPC_URI=http://127.0.0.1:9650/v1/bc/28N1Tv5CZziQ3FKCaXmo8xtxoFtuoVA6NvZykAT5MtGjF4JkGs/rpc CHAIN_ID=77777 npx hardhat test --network local
|
||||
```
|
||||
|
||||
Alternatively, you can copy and paste the `local` network configuration to create a new network configuration for your own local testing. For example, you can copy and paste the `local` network configuration to create your own network and fill in the required details:
|
||||
@@ -69,7 +69,7 @@ Alternatively, you can copy and paste the `local` network configuration to creat
|
||||
{
|
||||
"networks": {
|
||||
"mynetwork": {
|
||||
"url": "http://127.0.0.1:9650/ext/bc/28N1Tv5CZziQ3FKCaXmo8xtxoFtuoVA6NvZykAT5MtGjF4JkGs/rpc",
|
||||
"url": "http://127.0.0.1:9650/v1/bc/28N1Tv5CZziQ3FKCaXmo8xtxoFtuoVA6NvZykAT5MtGjF4JkGs/rpc",
|
||||
"chainId": 33333,
|
||||
"accounts": [
|
||||
"derive from MNEMONIC index 0 or set TREASURY_PRIVATE_KEY env var",
|
||||
@@ -103,6 +103,6 @@ You can define custom hardhat tasks in [tasks.ts](https://github.com/luxfi/lux-s
|
||||
|
||||
Tests are written for a local network which runs a EVM Blockchain.
|
||||
|
||||
E.g `RPC_URI=http://127.0.0.1:9650/ext/bc/28N1Tv5CZziQ3FKCaXmo8xtxoFtuoVA6NvZykAT5MtGjF4JkGs/rpc CHAIN_ID=77777 npx hardhat test --network local`.
|
||||
E.g `RPC_URI=http://127.0.0.1:9650/v1/bc/28N1Tv5CZziQ3FKCaXmo8xtxoFtuoVA6NvZykAT5MtGjF4JkGs/rpc CHAIN_ID=77777 npx hardhat test --network local`.
|
||||
|
||||
EVM must activate any precompiles used in the test in the genesis.
|
||||
|
||||
@@ -3,7 +3,7 @@ import "./tasks"
|
||||
|
||||
// HardHat users must populate these environment variables in order to connect to their evm instance
|
||||
// Since the blockchainID is not known in advance, there's no good default to use and we use the C-Chain here.
|
||||
var local_rpc_uri = process.env.RPC_URI || "http://127.0.0.1:9650/ext/bc/C/rpc"
|
||||
var local_rpc_uri = process.env.RPC_URI || "http://127.0.0.1:9650/v1/bc/C/rpc"
|
||||
var local_chain_id = parseInt(process.env.CHAIN_ID, 10) || 99999
|
||||
|
||||
export default {
|
||||
@@ -19,7 +19,7 @@ export default {
|
||||
},
|
||||
networks: {
|
||||
local: {
|
||||
//"http://{ip}:{port}/ext/bc/{chainID}/rpc
|
||||
//"http://{ip}:{port}/v1/bc/{chainID}/rpc
|
||||
// expected to be populated by the environment variables above
|
||||
url: local_rpc_uri,
|
||||
chainId: local_chain_id,
|
||||
|
||||
@@ -15,7 +15,7 @@ Deploy and interact with Solidity smart contracts on the Lux EVM with full Ether
|
||||
const { ethers } = require("ethers");
|
||||
|
||||
// Connect to Lux EVM
|
||||
const provider = new ethers.JsonRpcProvider("http://localhost:9650/ext/bc/C/rpc");
|
||||
const provider = new ethers.JsonRpcProvider("http://localhost:9650/v1/bc/C/rpc");
|
||||
const wallet = new ethers.Wallet(privateKey, provider);
|
||||
|
||||
// Deploy contract
|
||||
@@ -55,7 +55,7 @@ npx hardhat run scripts/deploy.js --network luxevm
|
||||
```bash
|
||||
# Deploy with forge
|
||||
forge create src/MyContract.sol:MyContract \
|
||||
--rpc-url http://localhost:9650/ext/bc/C/rpc \
|
||||
--rpc-url http://localhost:9650/v1/bc/C/rpc \
|
||||
--private-key $PRIVATE_KEY \
|
||||
--constructor-args "Constructor Arg"
|
||||
```
|
||||
@@ -63,7 +63,7 @@ forge create src/MyContract.sol:MyContract \
|
||||
```bash
|
||||
# Deploy with script
|
||||
forge script script/Deploy.s.sol:DeployScript \
|
||||
--rpc-url http://localhost:9650/ext/bc/C/rpc \
|
||||
--rpc-url http://localhost:9650/v1/bc/C/rpc \
|
||||
--broadcast \
|
||||
--private-key $PRIVATE_KEY
|
||||
```
|
||||
@@ -181,7 +181,7 @@ abstract contract UUPSUpgradeable {
|
||||
module.exports = {
|
||||
networks: {
|
||||
luxevm: {
|
||||
url: "http://localhost:9650/ext/bc/C/rpc",
|
||||
url: "http://localhost:9650/v1/bc/C/rpc",
|
||||
chainId: 43112,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -373,7 +373,7 @@ curl -X POST --data '{
|
||||
"method":"eth_gasPrice",
|
||||
"params":[],
|
||||
"id":1
|
||||
}' http://localhost:9650/ext/bc/C/rpc
|
||||
}' http://localhost:9650/v1/bc/C/rpc
|
||||
|
||||
# Get fee history
|
||||
curl -X POST --data '{
|
||||
@@ -381,7 +381,7 @@ curl -X POST --data '{
|
||||
"method":"eth_feeHistory",
|
||||
"params":[10, "latest", [25, 50, 75]],
|
||||
"id":1
|
||||
}' http://localhost:9650/ext/bc/C/rpc
|
||||
}' http://localhost:9650/v1/bc/C/rpc
|
||||
```
|
||||
|
||||
### Gas Profiling
|
||||
|
||||
@@ -106,7 +106,7 @@ Configurable economic parameters:
|
||||
module.exports = {
|
||||
networks: {
|
||||
luxevm: {
|
||||
url: "http://localhost:9650/ext/bc/C/rpc",
|
||||
url: "http://localhost:9650/v1/bc/C/rpc",
|
||||
chainId: 43112,
|
||||
accounts: [privateKey]
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@ Lux EVM is fully compatible with the Ethereum Virtual Machine. Most contracts de
|
||||
module.exports = {
|
||||
networks: {
|
||||
luxMainnet: {
|
||||
url: "https://api.lux.network/ext/bc/C/rpc",
|
||||
url: "https://api.lux.network/v1/bc/C/rpc",
|
||||
chainId: 96369,
|
||||
accounts: [process.env.PRIVATE_KEY],
|
||||
},
|
||||
luxTestnet: {
|
||||
url: "https://api.testnet.lux.network/ext/bc/C/rpc",
|
||||
url: "https://api.lux-test.network/v1/bc/C/rpc",
|
||||
chainId: 96370,
|
||||
accounts: [process.env.PRIVATE_KEY],
|
||||
},
|
||||
@@ -60,8 +60,8 @@ module.exports = {
|
||||
```toml
|
||||
# foundry.toml
|
||||
[rpc_endpoints]
|
||||
luxMainnet = "https://api.lux.network/ext/bc/C/rpc"
|
||||
luxTestnet = "https://api.testnet.lux.network/ext/bc/C/rpc"
|
||||
luxMainnet = "https://api.lux.network/v1/bc/C/rpc"
|
||||
luxTestnet = "https://api.lux-test.network/v1/bc/C/rpc"
|
||||
```
|
||||
|
||||
### 2. Update Chain ID References
|
||||
@@ -122,7 +122,7 @@ const provider = new ethers.JsonRpcProvider("https://mainnet.infura.io/v3/...");
|
||||
|
||||
// After
|
||||
const provider = new ethers.JsonRpcProvider(
|
||||
"https://api.lux.network/ext/bc/C/rpc"
|
||||
"https://api.lux.network/v1/bc/C/rpc"
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
@@ -387,7 +387,7 @@ contract Efficient {
|
||||
|
||||
```bash
|
||||
# Check state size
|
||||
curl http://localhost:9650/ext/metrics | grep state
|
||||
curl http://localhost:9650/v1/metrics | grep state
|
||||
|
||||
# State trie metrics
|
||||
state_trie_cache_hits
|
||||
|
||||
+17
-17
@@ -40,18 +40,18 @@ module.exports = {
|
||||
},
|
||||
networks: {
|
||||
luxevm: {
|
||||
url: "http://localhost:9650/ext/bc/C/rpc",
|
||||
url: "http://localhost:9650/v1/bc/C/rpc",
|
||||
chainId: 43112,
|
||||
accounts: [process.env.PRIVATE_KEY],
|
||||
gasPrice: 25000000000,
|
||||
},
|
||||
luxMainnet: {
|
||||
url: "https://api.lux.network/ext/bc/C/rpc",
|
||||
url: "https://api.lux.network/v1/bc/C/rpc",
|
||||
chainId: 96369,
|
||||
accounts: [process.env.PRIVATE_KEY],
|
||||
},
|
||||
luxTestnet: {
|
||||
url: "https://api.testnet.lux.network/ext/bc/C/rpc",
|
||||
url: "https://api.lux-test.network/v1/bc/C/rpc",
|
||||
chainId: 96370,
|
||||
accounts: [process.env.PRIVATE_KEY],
|
||||
},
|
||||
@@ -90,7 +90,7 @@ npx hardhat run scripts/deploy.js --network luxevm
|
||||
npx hardhat verify --network luxevm CONTRACT_ADDRESS "Constructor Arg"
|
||||
|
||||
# Start local node (fork)
|
||||
npx hardhat node --fork http://localhost:9650/ext/bc/C/rpc
|
||||
npx hardhat node --fork http://localhost:9650/v1/bc/C/rpc
|
||||
```
|
||||
|
||||
### Foundry
|
||||
@@ -116,9 +116,9 @@ optimizer_runs = 200
|
||||
evm_version = "cancun"
|
||||
|
||||
[rpc_endpoints]
|
||||
luxevm = "http://localhost:9650/ext/bc/C/rpc"
|
||||
luxMainnet = "https://api.lux.network/ext/bc/C/rpc"
|
||||
luxTestnet = "https://api.testnet.lux.network/ext/bc/C/rpc"
|
||||
luxevm = "http://localhost:9650/v1/bc/C/rpc"
|
||||
luxMainnet = "https://api.lux.network/v1/bc/C/rpc"
|
||||
luxTestnet = "https://api.lux-test.network/v1/bc/C/rpc"
|
||||
|
||||
[etherscan]
|
||||
luxevm = { key = "${EXPLORER_API_KEY}", url = "https://explorer.lux.network/api" }
|
||||
@@ -192,7 +192,7 @@ Configure MetaMask for Lux EVM:
|
||||
| Network | Mainnet | Testnet | Local |
|
||||
|---------|---------|---------|-------|
|
||||
| Name | Lux Mainnet | Lux Testnet | Lux Local |
|
||||
| RPC URL | https://api.lux.network/ext/bc/C/rpc | https://api.testnet.lux.network/ext/bc/C/rpc | http://localhost:9650/ext/bc/C/rpc |
|
||||
| RPC URL | https://api.lux.network/v1/bc/C/rpc | https://api.lux-test.network/v1/bc/C/rpc | http://localhost:9650/v1/bc/C/rpc |
|
||||
| Chain ID | 96369 | 96370 | 43112 |
|
||||
| Symbol | LUX | LUX | LUX |
|
||||
| Explorer | https://explorer.lux.network | https://explorer.testnet.lux.network | - |
|
||||
@@ -212,7 +212,7 @@ async function addLuxNetwork() {
|
||||
symbol: "LUX",
|
||||
decimals: 18,
|
||||
},
|
||||
rpcUrls: ["https://api.lux.network/ext/bc/C/rpc"],
|
||||
rpcUrls: ["https://api.lux.network/v1/bc/C/rpc"],
|
||||
blockExplorerUrls: ["https://explorer.lux.network"],
|
||||
},
|
||||
],
|
||||
@@ -238,7 +238,7 @@ const luxMainnet = {
|
||||
},
|
||||
rpcUrls: {
|
||||
default: {
|
||||
http: ["https://api.lux.network/ext/bc/C/rpc"],
|
||||
http: ["https://api.lux.network/v1/bc/C/rpc"],
|
||||
},
|
||||
},
|
||||
blockExplorers: {
|
||||
@@ -263,7 +263,7 @@ import { ethers } from "ethers";
|
||||
|
||||
// Connect to Lux EVM
|
||||
const provider = new ethers.JsonRpcProvider(
|
||||
"http://localhost:9650/ext/bc/C/rpc"
|
||||
"http://localhost:9650/v1/bc/C/rpc"
|
||||
);
|
||||
|
||||
// Create wallet
|
||||
@@ -296,7 +296,7 @@ const luxMainnet = {
|
||||
symbol: "LUX",
|
||||
},
|
||||
rpcUrls: {
|
||||
default: { http: ["https://api.lux.network/ext/bc/C/rpc"] },
|
||||
default: { http: ["https://api.lux.network/v1/bc/C/rpc"] },
|
||||
},
|
||||
blockExplorers: {
|
||||
default: { name: "Explorer", url: "https://explorer.lux.network" },
|
||||
@@ -338,7 +338,7 @@ const hash = await walletClient.writeContract({
|
||||
const Web3 = require("web3");
|
||||
|
||||
// Connect to Lux EVM
|
||||
const web3 = new Web3("http://localhost:9650/ext/bc/C/rpc");
|
||||
const web3 = new Web3("http://localhost:9650/v1/bc/C/rpc");
|
||||
|
||||
// Add account
|
||||
const account = web3.eth.accounts.privateKeyToAccount(privateKey);
|
||||
@@ -363,10 +363,10 @@ const tx = await contract.methods.setValue("New Value").send({
|
||||
|
||||
```bash
|
||||
# Start local Lux EVM fork
|
||||
anvil --fork-url http://localhost:9650/ext/bc/C/rpc --chain-id 43112
|
||||
anvil --fork-url http://localhost:9650/v1/bc/C/rpc --chain-id 43112
|
||||
|
||||
# With specific block
|
||||
anvil --fork-url http://localhost:9650/ext/bc/C/rpc --fork-block-number 1000000
|
||||
anvil --fork-url http://localhost:9650/v1/bc/C/rpc --fork-block-number 1000000
|
||||
```
|
||||
|
||||
### Cast (CLI Tool)
|
||||
@@ -529,7 +529,7 @@ curl -X POST --data '{
|
||||
"method":"debug_traceTransaction",
|
||||
"params":["0x...", {"tracer": "callTracer"}],
|
||||
"id":1
|
||||
}' http://localhost:9650/ext/bc/C/rpc
|
||||
}' http://localhost:9650/v1/bc/C/rpc
|
||||
|
||||
# Get storage at slot
|
||||
curl -X POST --data '{
|
||||
@@ -537,7 +537,7 @@ curl -X POST --data '{
|
||||
"method":"eth_getStorageAt",
|
||||
"params":["0xcontract", "0x0", "latest"],
|
||||
"id":1
|
||||
}' http://localhost:9650/ext/bc/C/rpc
|
||||
}' http://localhost:9650/v1/bc/C/rpc
|
||||
```
|
||||
|
||||
## CI/CD Integration
|
||||
|
||||
@@ -120,7 +120,7 @@ Once the tag is created, you need to test it on the Testnet testnet both locally
|
||||
"method": "platform.getBlockchains",
|
||||
"params": {},
|
||||
"id": 1
|
||||
}' https://api.lux-test.network/ext/bc/P | \
|
||||
}' https://api.lux-test.network/v1/bc/P | \
|
||||
jq -r '.result.blockchains[] | select(.subnetID=="7WtoAMPhrmh5KosDUsFL9yTcvw7YSxiKHPpdfs4JsgW47oZT5") | "\(.name)\nBlockchain id: \(.id)\nVM id: \(.vmID)\n"'
|
||||
```
|
||||
|
||||
@@ -140,7 +140,7 @@ Once the tag is created, you need to test it on the Testnet testnet both locally
|
||||
"method": "platform.getBlockchains",
|
||||
"params": {},
|
||||
"id": 1
|
||||
}' https://api.lux-test.network/ext/bc/P | \
|
||||
}' https://api.lux-test.network/v1/bc/P | \
|
||||
jq -r '.result.blockchains[] | select(.subnetID=="i9gFpZQHPLcGfZaQLiwFAStddQD7iTKBpFfurPFJsXm1CkTZK") | "\(.name)\nBlockchain id: \(.id)\nVM id: \(.vmID)\n"'
|
||||
```
|
||||
|
||||
@@ -241,7 +241,7 @@ Once the tag is created, you need to test it on the Testnet testnet both locally
|
||||
"method": "eth_blockNumber",
|
||||
"params": [],
|
||||
"id": 1
|
||||
}' localhost:9650/ext/bc/2D8RG4UpSXbPbvPCAWppNJyqTG2i2CAXSkTgmTBBvs7GKNZjsY/rpc
|
||||
}' localhost:9650/v1/bc/2D8RG4UpSXbPbvPCAWppNJyqTG2i2CAXSkTgmTBBvs7GKNZjsY/rpc
|
||||
```
|
||||
|
||||
- Echo:
|
||||
@@ -252,7 +252,7 @@ Once the tag is created, you need to test it on the Testnet testnet both locally
|
||||
"method": "eth_blockNumber",
|
||||
"params": [],
|
||||
"id": 1
|
||||
}' localhost:9650/ext/bc/98qnjenm7MBd8G2cPZoRvZrgJC33JGSAAKghsQ6eojbLCeRNp/rpc
|
||||
}' localhost:9650/v1/bc/98qnjenm7MBd8G2cPZoRvZrgJC33JGSAAKghsQ6eojbLCeRNp/rpc
|
||||
```
|
||||
|
||||
#### Canary deployment
|
||||
|
||||
@@ -49,7 +49,7 @@ type client struct {
|
||||
|
||||
// NewClient returns a Client for interacting with EVM [chain]
|
||||
func NewClient(uri, chain string) Client {
|
||||
requestUri := fmt.Sprintf("%s/ext/bc/%s", uri, chain)
|
||||
requestUri := fmt.Sprintf("%s/v1/bc/%s", uri, chain)
|
||||
return NewClientWithURL(requestUri)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright (C) 2019-2026, Lux Industries, Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// NewClient is the exported seam every out-of-tree caller goes through —
|
||||
// cli, sdk and netrunner all hand it a bare node URI and let it build the
|
||||
// path. luxd serves exactly one prefix, /v1 (node/server/http/server.go),
|
||||
// so the prefix this function bakes in decides whether those callers reach
|
||||
// the node at all.
|
||||
func TestNewClientRequestsV1Paths(t *testing.T) {
|
||||
seen := make(chan string, 4)
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
seen <- r.URL.Path
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"jsonrpc":"2.0","id":1,"result":{}}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
c := NewClient(srv.URL, "C")
|
||||
if err := c.StartCPUProfiler(context.Background()); err != nil {
|
||||
t.Fatalf("StartCPUProfiler: %v", err)
|
||||
}
|
||||
|
||||
got := <-seen
|
||||
if want := "/v1/bc/C/admin"; got != want {
|
||||
t.Fatalf("admin endpoint = %q, want %q", got, want)
|
||||
}
|
||||
if strings.Contains(got, "/ext/") {
|
||||
t.Fatalf("request still carries the legacy /ext prefix: %q", got)
|
||||
}
|
||||
|
||||
if _, err := c.GetCurrentValidators(context.Background(), nil); err != nil {
|
||||
t.Fatalf("GetCurrentValidators: %v", err)
|
||||
}
|
||||
if got, want := <-seen, "/v1/bc/C/validators"; got != want {
|
||||
t.Fatalf("validators endpoint = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
// The chain segment must be interpolated, not hardcoded, so a blockchain ID
|
||||
// works as well as an alias.
|
||||
func TestNewClientUsesChainArgument(t *testing.T) {
|
||||
seen := make(chan string, 1)
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
seen <- r.URL.Path
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"jsonrpc":"2.0","id":1,"result":{}}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
const chainID = "2T11SNJM9KYqSenoPb5yv6qahmj8HLefCjxt4gTD2iQWTHwdRu"
|
||||
if err := NewClient(srv.URL, chainID).StartCPUProfiler(context.Background()); err != nil {
|
||||
t.Fatalf("StartCPUProfiler: %v", err)
|
||||
}
|
||||
if got, want := <-seen, "/v1/bc/"+chainID+"/admin"; got != want {
|
||||
t.Fatalf("endpoint = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ curl -X POST --data '{
|
||||
"latest"
|
||||
],
|
||||
"id": 1
|
||||
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/2ebCneCbwthjQ1rYT41nhd7M76Hc6YmosMAQrTFhBq8qeqh6tt/rpc
|
||||
}' -H 'content-type:application/json;' 127.0.0.1:9650/v1/bc/2ebCneCbwthjQ1rYT41nhd7M76Hc6YmosMAQrTFhBq8qeqh6tt/rpc
|
||||
```
|
||||
|
||||
**Example Response:**
|
||||
@@ -78,7 +78,7 @@ curl -X POST --data '{
|
||||
"id" :1,
|
||||
"method" :"eth_getChainConfig",
|
||||
"params" :[]
|
||||
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/Nvqcm33CX2XABS62iZsAcVUkavfnzp1Sc5k413wn5Nrf7Qjt7/rpc
|
||||
}' -H 'content-type:application/json;' 127.0.0.1:9650/v1/bc/Nvqcm33CX2XABS62iZsAcVUkavfnzp1Sc5k413wn5Nrf7Qjt7/rpc
|
||||
```
|
||||
|
||||
**Example Response:**
|
||||
@@ -168,7 +168,7 @@ curl -X POST --data '{
|
||||
"method": "eth_getActivePrecompilesAt",
|
||||
"params": [],
|
||||
"id": 1
|
||||
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/Nvqcm33CX2XABS62iZsAcVUkavfnzp1Sc5k413wn5Nrf7Qjt7/rpc
|
||||
}' -H 'content-type:application/json;' 127.0.0.1:9650/v1/bc/Nvqcm33CX2XABS62iZsAcVUkavfnzp1Sc5k413wn5Nrf7Qjt7/rpc
|
||||
```
|
||||
|
||||
**Example Response:**
|
||||
@@ -216,7 +216,7 @@ curl -X POST --data '{
|
||||
"method": "eth_getActiveRulesAt",
|
||||
"params": [],
|
||||
"id": 1
|
||||
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/Nvqcm33CX2XABS62iZsAcVUkavfnzp1Sc5k413wn5Nrf7Qjt7/rpc
|
||||
}' -H 'content-type:application/json;' 127.0.0.1:9650/v1/bc/Nvqcm33CX2XABS62iZsAcVUkavfnzp1Sc5k413wn5Nrf7Qjt7/rpc
|
||||
```
|
||||
|
||||
**Example Response:**
|
||||
@@ -261,7 +261,7 @@ curl -X POST --data '{
|
||||
|
||||
This API retrieves the list of current validators for the Subnet/L1. It provides detailed information about each validator, including their ID, status, weight, connection, and uptime.
|
||||
|
||||
URL: `http://<server-uri>/ext/bc/<blockchainID>/validators`
|
||||
URL: `http://<server-uri>/v1/bc/<blockchainID>/validators`
|
||||
|
||||
**Signature:**
|
||||
|
||||
@@ -281,7 +281,7 @@ curl -X POST --data '{
|
||||
"nodeIDs": []
|
||||
},
|
||||
"id": 1
|
||||
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/C49rHzk3vLr1w9Z8sY7scrZ69TU4WcD2pRS6ZyzaSn9xA2U9F/validators
|
||||
}' -H 'content-type:application/json;' 127.0.0.1:9650/v1/bc/C49rHzk3vLr1w9Z8sY7scrZ69TU4WcD2pRS6ZyzaSn9xA2U9F/validators
|
||||
```
|
||||
|
||||
**Example Response:**
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
// Read-only fork of Lux mainnet (chain ID 96369). Captured from
|
||||
// platform.getCurrentValidators on https://api.lux.network/ext/bc/P while
|
||||
// platform.getCurrentValidators on https://api.lux.network/v1/bc/P while
|
||||
// C-chain eth_blockNumber was 0x10c1cf. Nothing here writes to mainnet; the
|
||||
// production validator set is used purely as fixture state.
|
||||
//
|
||||
|
||||
@@ -33,7 +33,7 @@ const (
|
||||
|
||||
var (
|
||||
// Mainnet-shaped numbers, measured 2026-07 from
|
||||
// platform.getCurrentValidators on https://api.lux.network/ext/bc/P:
|
||||
// platform.getCurrentValidators on https://api.lux.network/v1/bc/P:
|
||||
// 5 validators, each weight 5e17 nLUX, total 2.5e18.
|
||||
mainnetVdrWeight uint64 = 500_000_000_000_000_000
|
||||
mainnetTotalWeight uint64 = 2_500_000_000_000_000_000
|
||||
|
||||
@@ -91,7 +91,7 @@ var _ = ginkgo.Describe("[Load Simulator]", ginkgo.Ordered, func() {
|
||||
if !validatorIDs.Contains(nodeURI.NodeID) {
|
||||
continue
|
||||
}
|
||||
rpcEndpoints = append(rpcEndpoints, fmt.Sprintf("%s/ext/bc/%s/rpc", nodeURI.URI, blockchainID))
|
||||
rpcEndpoints = append(rpcEndpoints, fmt.Sprintf("%s/v1/bc/%s/rpc", nodeURI.URI, blockchainID))
|
||||
}
|
||||
commaSeparatedRPCEndpoints := strings.Join(rpcEndpoints, ",")
|
||||
require.NoError(os.Setenv("RPC_ENDPOINTS", commaSeparatedRPCEndpoints))
|
||||
|
||||
@@ -175,7 +175,7 @@ func CreateNewSubnet(ctx context.Context, genesisFilePath string) string {
|
||||
|
||||
// GetDefaultChainURI returns the default chain URI for a given blockchainID
|
||||
func GetDefaultChainURI(blockchainID string) string {
|
||||
return fmt.Sprintf("%s/ext/bc/%s/rpc", DefaultLocalNodeURI, blockchainID)
|
||||
return fmt.Sprintf("%s/v1/bc/%s/rpc", DefaultLocalNodeURI, blockchainID)
|
||||
}
|
||||
|
||||
// GetFilesAndAliases returns a map of aliases to file paths in given [dir].
|
||||
|
||||
@@ -752,9 +752,9 @@ func generateKeys(preFundedKey *ecdsa.PrivateKey, numWorkers int) ([]*key.Key, [
|
||||
}
|
||||
|
||||
func toWebsocketURI(uri string, blockchainID string) string {
|
||||
return fmt.Sprintf("ws://%s/ext/bc/%s/ws", strings.TrimPrefix(uri, "http://"), blockchainID)
|
||||
return fmt.Sprintf("ws://%s/v1/bc/%s/ws", strings.TrimPrefix(uri, "http://"), blockchainID)
|
||||
}
|
||||
|
||||
func toRPCURI(uri string, blockchainID string) string {
|
||||
return fmt.Sprintf("%s/ext/bc/%s/rpc", uri, blockchainID)
|
||||
return fmt.Sprintf("%s/v1/bc/%s/rpc", uri, blockchainID)
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ type client struct {
|
||||
|
||||
// NewClient returns a Client for interacting with EVM [chain]
|
||||
func NewClient(uri, chain string) (Client, error) {
|
||||
innerClient, err := rpc.Dial(fmt.Sprintf("%s/ext/bc/%s/rpc", uri, chain))
|
||||
innerClient, err := rpc.Dial(fmt.Sprintf("%s/v1/bc/%s/rpc", uri, chain))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to dial client. err: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user