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

Removed alphanumeric enforcement for node IDs #3688

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions docker/start
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ run_graph_node() {
wait_for_ipfs "$ipfs"
sleep 5
graph-node \
--node-id "${node_id//-/_}" \
--node-id "$node_id" \
--config "$GRAPH_NODE_CONFIG" \
--ipfs "$ipfs" \
${fork_base:+ --fork-base "$fork_base"}
Expand All @@ -71,7 +71,7 @@ run_graph_node() {
sleep 5

graph-node \
--node-id "${node_id//-/_}" \
--node-id "$node_id" \
--postgres-url "$postgres_url" \
--ethereum-rpc $ethereum \
--ipfs "$ipfs" \
Expand All @@ -98,6 +98,14 @@ start_combined_node() {
run_graph_node
}

# Allow operators to opt out of legacy character
# restrictions on the node ID by setting enablement
# variable to a non-zero length string:
if [ -z "$GRAPH_NODE_ID_USE_LITERAL_VALUE" ]
then
node_id="${node_id//-/_}"
fi

if [ -n "$disable_core_dumps" ]
then
ulimit -c 0
Expand Down
6 changes: 6 additions & 0 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ those.
in parallel and deploy to specific nodes; each ID must be unique among the set
of nodes. A single node should have the same value between consecutive restarts.
Subgraphs get assigned to node IDs and are not reassigned to other nodes automatically.
- `GRAPH_NODE_ID_USE_LITERAL_VALUE`: (Docker only) Use the literal `node_id`
provided to the docker start script instead of replacing hyphens (-) in names
with underscores (\_). Changing this for an existing `graph-node`
installation requires also changing the assigned node IDs in the
`subgraphs.subgraph_deployment_assignment` table in the database. This can be
done with GraphMan or via the PostgreSQL command line.
- `GRAPH_LOG`: control log levels, the same way that `RUST_LOG` is described
[here](https://docs.rs/env_logger/0.6.0/env_logger/)
- `THEGRAPH_STORE_POSTGRES_DIESEL_URL`: postgres instance used when running
Expand Down
10 changes: 2 additions & 8 deletions graph/src/data/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,8 @@ impl NodeId {
pub fn new(s: impl Into<String>) -> Result<Self, ()> {
let s = s.into();

// Enforce length limit
if s.len() > 63 {
return Err(());
}

// Check that the ID contains only allowed characters.
// Note: these restrictions are relied upon to prevent SQL injection
if !s.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
// Enforce minimum and maximum length limit
if s.len() > 63 || s.len() < 1 {
return Err(());
}

Expand Down
4 changes: 2 additions & 2 deletions node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ async fn main() {
std::process::exit(0);
}

let node_id =
NodeId::new(opt.node_id.clone()).expect("Node ID must contain only a-z, A-Z, 0-9, and '_'");
let node_id = NodeId::new(opt.node_id.clone())
.expect("Node ID must be between 1 and 63 characters in length");
let query_only = config.query_only(&node_id);

// Obtain subgraph related command-line arguments
Expand Down