Diameter of a weighted Hamming cube Let $C=(\mathbb{Z}/2\mathbb{Z})^N$ be the Hamming cube with its usual graph structure, and assume each edge $e=(x,x+\epsilon)$ (where $x\in C$ and $\epsilon$ has one $1$ and $N-1$ zeros) is given a length $\ell(x,\epsilon)$ satisfying the constraints
$$ \sum_\epsilon \ell(x,\epsilon) \le 1 \qquad \forall x\in C.$$
Denote by $d_\ell$ the distance function induced by these lengths.

Q1: What is the growth of the largest possible diameter $D(N)$ for such $(C,d_\ell)$?

I think I can prove a bound $D(N) \lesssim log(N)$, but I wonder if a constant bound could be true.
In fact, this is not the real question I have, but it seemed a reasonable way to get to it. The real question is about functions $f:C\to \mathbb{R}$ such that
$$(1) \qquad \sum_\epsilon \lvert f(x+\epsilon) - f(x) \rvert \le 1 \qquad \forall x\in C$$
and of vanishing average.

Q2: What is the largest possible value $\lVert f\rVert_\infty$ for such a function?

(My motivation is a toy example to test some concentration inequalities for Markov chains. In some cases I figured the semi-norm $\max_x \sum_\epsilon \lvert f(x+\epsilon)-f(x)\rvert$ should be efficient for the Glauber dynamic (aka lazy random walk) on $C$, but I need the above to get a good spectral gap in the corresponding functional space)
 A: It looks like even the sharp upper estimate 1 may be obtained. We use the following
Lemma. If $q_0,\dots,q_{N-1}$ are non-negative real numbers such that $q_i-q_{i+1}+q_{i+2}-\dots+q_{i+2s}\geqslant 0$ for all $0\leqslant i\leqslant i+2s\leqslant N-1$, then there exist non-negative numbers $p_0,\dots,p_{N}$ such that $q_i=p_i+p_{i+1}$ for $i=0,\dots,N-1$.
Proof. Denote $p_0=t$, then $p_1=q_0-t$, $p_2=q_1-q_0+t$, $p_3=q_2-q_1+q_0-t$, $\dots$, $p_N=q_{N-1}-q_{N-2}+\dots+(-1)^{N-1}q_0+(-1)^Nt$. We need all $p_i$'s be non-negative, this gives certain upper and lower estimates for $t$. They must be consistent. It holds if any lower estimate is consistent with any upper estimate. Say, these two estimates come from the inequalities $p_i\geqslant 0$ and $p_{i+2s+1}\geqslant 0$, where $0\leqslant i< i+2s+1\leqslant N$. Their consistence rewrites as $p_i+p_{i+2s+1}\geqslant 0$ (the left hand side does not depend on $t$), and it is exactly what we supposed.
Note that the assumption of the lemma holds if $q_0\geqslant q_1\geqslant q_2\geqslant \dots \geqslant q_m\leqslant q_{m+1}\leqslant q_{m+2}\dots \leqslant q_{N-1}$ for some $m$. This is what we actually use. 
We should find a path of length at most 1 between two opposite vertices, say, from $(0,\dots,0)$ to $(1,\dots,1)$ (all other cases reduce to this by induction in $N$). Sum up the lengths of all $N!$ paths (consisting of $n$ edges), denote the sum by $S$. It suffices to prove that $S\leqslant N!$. Using our lemma, we choose non-negative numbers $p_0,p_1,\dots,p_N$ such that $p_i+p_{i+1}=i!(N-i-1)!$ for all $i=0,\dots,N-1$. Then $S$ equals $\sum_{x\in C} p_{|x|}f(x)$, where $f(x)$ is your sum $\sum_\epsilon \ell(x,\epsilon)$ which does not exceed 1 (and $|x|$ denotes a number of coordinates 1 in $x$). Indeed, if $|x|=i$, $|x+\epsilon|=i+1$, then the edge between $x$ and $x+\epsilon$ belongs to $i!(N-i-1)!$ our paths, and it goes with coefficient $p_i+p_{i+1}$ to our sum. 
So, $S$ does not exceed $\sum_{i=0}^N p_i\binom{N}i=\sum_{i=0}^{N-1}(p_i+p_{i+1})\binom{N-1}i=N(N-1)!=N!$ as desired. 
Here is an almost computation-free explanation why Benoît Kloeckner's explicit formula for $p_i$ works. 
We have $N+1$ levels $L_0,\dots,L_N$ of vertices of the cube ($L_k$ consists of vertices with the sum equal to $k$), and $N$ levels $P_0,\dots,P_{N-1}$ of edges ($P_i$ consists of edges between $L_i$ and $L_{i+1}$). Choose $i$ at random uniformly in $\{0,1,\dots,N\}$ and after that choose a random edge from a random (uniformly chosen) vertex $v\in L_i$. We get a random edge, and I claim that its level is uniformly distributed. Indeed, the probability to get an edge from $P_k$ equals $\frac1{N+1}(\frac{N-k}N+\frac{k+1}N)=\frac1N$, where the first summand corresponds to $i=k$ and the second to $i=k+1$. Thus the distribution of edges is exactly the same as if we get a random path of length $N$ between $L_0$ and $L_N$ and choose its random edge.
A: This was too long for a comment, Fedor Petrov gave a very nice answer with sharp constant (see also fedja's comment with a finite constant), and I just want to give the  reference where the problem was solved back in 2000, for $f$ taking values in an arbitrary normed linear space $B$. 
The OP is asking a particular case of what is now called Pisier's inequality for $p=\infty$ without $\log(n)$ factor. 
Let $f:\{-1,1\}^{n} \to B,$ where $B$ is linear normed space. Define 
$$
D_{j}f(x) = \frac{f(x)-f(x^{j})}{2},
$$ 
where $x^{j}=(x_{1}, \ldots, -x_{j}, \ldots, x_{n})$, i.e., it puts negative sign in front of $j$-th coordinate. Then Pisier proved  

Theorem (Pisier, 1986). For all $1\leq p \leq \infty$, and any $f:\{-1,1\}^{n} \to B$ we have
  $$ (\mathbb{E}\|f-\mathbb{E}f\|^{p})^{1p} \leq C
 \log(n)\left(\mathbb{E}_{x} \mathbb{E}_{y}\|\sum_{j=1}^{n}
 y_{j}D_{j}f(x) \|^{p}\right)^{1/p}. $$

Later Talagrand (1993) showed that in general for $p<\infty$,  $\log(n)$ factor is sharp. However in case of $B=\mathbb{R}$, $\log(n)$ factor can be removed but with $C=C(p)$ (again $p<\infty$), and for the real-valued functions, the inequality is sometimes called Poincar\'e inequality, because the right hand side (by Khinchin's inequality) can be replaced by a more familiar discrete gradient:
$$
\|\nabla f\|_{p}:= \left(\mathbb{E}\left(\sum_{j=1}^{n} |D_{j}f|^{2}\right)^{p/2}\right)^{1/p}
$$
Finally, Wagner (2000) closed the gap by showing 

Theorem (Wagner, 2000). For $p=\infty$ Pisier's inequality holds without $\log(n)$ factor.

This answers OP,   because for $B=\mathbb{R}$,  Pisier's inequality  becomes  (without $\log(n)$ factor)
$$
\|f-Ef\|_{\infty} \leq C \| \sum_{j=1}^{n}|D_{j}f| \|_{\infty}.
$$
Pisier, Gilles, Probabilistic methods in the geometry of Banach spaces, Probability and analysis, Lect. Sess. C.I.M.E., Varenna/Italy 1985, Lect. Notes Math. 1206, 167-241 (1986). ZBL0606.60008.
Wagner, R., Notes on an inequality by Pisier for functions on the discrete cube, Milman, V. D. (ed.) et al., Geometric aspects of functional analysis. Proceedings of the Israel seminar (GAFA) 1996-2000. Berlin: Springer. Lect. Notes Math. 1745, 263-268 (2000). ZBL0981.46021.
Talagrand, M., Isoperimetry, logarithmic Sobolev inequalities on the discrete cube, and Margulis’ graph connectivity theorem, Geom. Funct. Anal. 3, No. 3, 295-314 (1993). ZBL0806.46035.
A: Edit: the argument below doesn't answer the right question
Assuming the sum in (1) is over all edges and not only over edges incident to each vertex, Q2 implies Q1, and the answer to Q2 is positive.
For Q2, let $g$ be the linear interpolation of $f$ on the cube graph. Assumption (1) says that the total variation of $g$ is at most $1$. By the coarea formula, the integral over the range of $g$ of the number of preimages is at most $1$. 
Since the number of preimages is at least $1$, the range has length at most $1$. 
