Structurally impossible blocks are rejected with 503 {retryable:true} instead of 400 {retryable:false}
Report
Severity (suggested): Medium — inconsistent API responses / validation gap. No fund risk.
XE payout address: will be provided in a follow-up comment (this was found from throwaway testnet accounts; happy to give a stable mainnet address when the pool is finalized).
Contract
API Reference → "Retryable errors" states:
A rejected block returns
{"error":"block rejected: …","retryable":<bool>}: 400 withretryable: falsefor a deterministically invalid block (bad signature or PoW, structural or value validation), 503 withretryable: truefor a transient failure (a dependency this node has not synced yet, a frontier race). Branch on the flag, not the prose.
Both cases below can never become valid, yet the node returns 503 + retryable:true.
The official SDK branches on isRetryable(err), so a conforming client retries these blocks forever.
Case A — non-open block for an account that has no declared public key
POST /blocks/send
{"type":"send","account":"<unopened-address>","previous":"<valid 64-hex>","balance":…,
"timestamp":…,"asset":"XE","destination":"<address>","amount":1,"signature":…,"pow_nonce":…}
HTTP/1.1 503
{"error":"block rejected: signature: unopened account abababababab... has no declared public key",
"retryable":true}
A block with previous != "0" and no pub_key, for an account that was never opened, is structurally
impossible — waiting and retrying cannot help. Reproduced 4/4.
Case B — previous = 0 on an account that already has a chain
HTTP/1.1 503
{"error":"block rejected: previous mismatch: got 000000000000..., want 898c054e658b...",
"retryable":true}
Same account and fields with the real frontier → 201, so signing and the chain are fine.
Reproduced as 503 retryable:true in 5 of 6 attempts; once returned
400 {"…block conflicts with finalized block…","retryable":false} for the same construction.
Either way a client cannot tell from the documented contract whether to retry.
Reproducer
Single file, stdlib + cryptography only (no XE binary needed; the encoder is a byte-for-byte port of
core/encoding.go / crypto.go / pow.go, validated against sdk/test/vectors.json —
send/receive/burn: canonical_hex, hash and signature all byte-identical):
export XE_SEED=<64-hex seed of a funded testnet account>
python repro_retryable_503.py --node https://ldn.core.test.network
<details> <summary>repro_retryable_503.py</summary>
#!/usr/bin/env python3
"""Standalone reproducer: structurally impossible blocks are rejected with 503 retryable:true.
Dependencies: stdlib + `cryptography` (ed25519). No XE binary needed.
export XE_SEED=<64-hex seed of a funded testnet account>
python repro_retryable_503.py --node https://ldn.core.test.network
Exit codes: 1 = reproduced, 0 = correctly rejected, 2 = could not run.
"""
import argparse, hashlib, json, os, struct, sys, time, urllib.error, urllib.request
NODE_DEFAULT = "https://ldn.core.test.network"
VERSION_BYTE, TYPE_SEND = 0x02, 0x01
AUX_TAG_PUBKEY = b"xe/block/pubkey/v1"
ACCOUNT_DOMAIN = b"xe/account/v1"
DEFAULT_DIFFICULTY = 0xFFFFF80000000000
def u64(v): return struct.pack(">Q", v & 0xFFFFFFFFFFFFFFFF)
def hex32(s):
b = bytes.fromhex(s)
if len(b) != 32: raise ValueError(f"expected 32 bytes, got {len(b)}")
return b
def derive_address(pub_hex):
return hashlib.sha256(ACCOUNT_DOMAIN + bytes.fromhex(pub_hex)).hexdigest()
def canonical(b):
out = bytearray([VERSION_BYTE, TYPE_SEND])
out += (b.get("asset") or "").encode().ljust(8, b"\x00")
out += hex32(b["account"])
out += b"\x00" * 32 if b.get("previous", "0") == "0" else hex32(b["previous"])
out += u64(int(b.get("balance") or 0))
out += u64(int(b.get("timestamp") or 0))
out += hex32(b["destination"])
out += u64(int(b.get("amount") or 0))
out += b"\x00" * 32 # representative
memo = (b.get("memo") or "").encode()
out.append(len(memo)); out += memo
return bytes(out)
def aux(b):
pk = b.get("pub_key") or ""
if not pk: return b""
tag, val = AUX_TAG_PUBKEY, pk.encode()
return u64(len(tag)) + tag + u64(len(val)) + val
def block_hash(b, network_id):
h = hashlib.sha256(); h.update(network_id.encode()); h.update(canonical(b)); h.update(aux(b))
return h.hexdigest()
def pow_hash(nonce, hb):
h = hashlib.blake2b(digest_size=8)
h.update(struct.pack("<Q", nonce & 0xFFFFFFFFFFFFFFFF)); h.update(hb)
return struct.unpack(">Q", h.digest())[0]
def compute_pow(bh, difficulty=DEFAULT_DIFFICULTY):
hb, n = bytes.fromhex(bh), 0
while pow_hash(n, hb) < difficulty: n += 1
return n
def sign(b, seed, network_id, declare_pub_key=False):
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
priv = Ed25519PrivateKey.from_private_bytes(seed)
pub = priv.public_key().public_bytes(serialization.Encoding.Raw,
serialization.PublicFormat.Raw)
out = dict(b)
if declare_pub_key and not out.get("pub_key"): out["pub_key"] = pub.hex()
out["hash"] = block_hash(out, network_id)
out["signature"] = priv.sign(bytes.fromhex(out["hash"])).hex()
out["pow_nonce"] = compute_pow(out["hash"])
return out
def get(u):
with urllib.request.urlopen(u, timeout=25) as r: return json.loads(r.read())
def post(u, body):
req = urllib.request.Request(u, data=json.dumps(body).encode(), method="POST",
headers={"Content-Type": "application/json"})
try:
with urllib.request.urlopen(req, timeout=25) as r: return r.status, r.read().decode()[:400]
except urllib.error.HTTPError as e: return e.code, e.read().decode()[:400]
def main():
ap = argparse.ArgumentParser(); ap.add_argument("--node", default=NODE_DEFAULT)
args = ap.parse_args()
seed_hex = os.environ.get("XE_SEED", "").strip()
if len(seed_hex) != 64:
print("ERROR: set XE_SEED to a funded testnet account's 64-hex seed", file=sys.stderr); return 2
seed = bytes.fromhex(seed_hex)
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
priv = Ed25519PrivateKey.from_private_bytes(seed)
pub_hex = priv.public_key().public_bytes(serialization.Encoding.Raw,
serialization.PublicFormat.Raw).hex()
node = args.node.rstrip("/"); me = derive_address(pub_hex)
network_id = get(f"{node}/node")["network_id"]
total = int(get(f"{node}/accounts/{me}/chain?limit=1").get("total") or 0)
if total == 0:
print("ERROR: account unopened; fund it from the faucet first", file=sys.stderr); return 2
frontier = get(f"{node}/accounts/{me}/chain?limit=1&offset={total-1}")["blocks"][-1]["hash"]
bal = int((get(f"{node}/accounts/{me}/balance").get("balances") or {}).get("XE") or 0)
other, now = hashlib.sha256(b"repro-destination").hexdigest(), time.time_ns()
c1 = {"type": "send", "account": me, "previous": "0", "balance": bal - 1,
"timestamp": now, "asset": "XE", "destination": other, "amount": 1}
st1, bd1 = post(f"{node}/blocks/send", sign(c1, seed, network_id, declare_pub_key=True))
c2 = {"type": "send", "account": hashlib.sha256(b"repro-unopened").hexdigest(),
"previous": frontier, "balance": bal - 1, "timestamp": now,
"asset": "XE", "destination": other, "amount": 1}
st2, bd2 = post(f"{node}/blocks/send", sign(c2, seed, network_id))
def rep(name, st, bd):
try: rt = json.loads(bd).get("retryable")
except Exception: rt = None
bad = st >= 500 and rt is True
print(f"[{name}] expected HTTP 400 retryable:false | observed HTTP {st} retryable={rt}")
print(f" body: {bd.strip()[:200]}")
print(f" -> {'REPRODUCED' if bad else 'correctly rejected'}")
return bad
print(f"node={node} network={network_id} account={me[:12]}… height={total}")
ok = rep("case1 previous=0", st1, bd1) | rep("case2 unopened account", st2, bd2)
return 1 if ok else 0
if __name__ == "__main__":
raise SystemExit(main())
</details>
Suggested fix
Distinguish "structurally impossible" from "not ready yet":
previous == 0while the account already has a chain →400 retryable:false;- non-open block whose
accountis unknown / has no declaredpub_key, so the block can never be attributed →400 retryable:false; - keep
503 retryable:trueonly for the documented transient cases (apreviousthe node knows about but has not synced yet; frontier races).
Out of scope / already checked clean
Same campaign, all correctly rejected with 400 retryable:false: account set to an existing account but
signed by another key (account takeover attempt), pub_key declared on a non-open block, asset:"xe",
timestamp:0, amount = 2^64-1, balance = 2^64-1, amount = 0, over-balance amount, memo 65 bytes,
destination = self.
Two things I initially suspected and then disproved, so they are not claimed here: hex case is not malleability (upper/lower produce an identical block hash — the canonical encoding decodes hex to bytes), and replaying a signed block is idempotent (balance decreases once, height unchanged).
Thread
XE payout address: b68f2b4d8a062d9219590f0c2d7753d783ec9f5d43d85a125230bb0f7a41a86e
This is a locally held key. The address is sha256(xe/account/v1 ‖ pubkey) and does not depend on
the network id, so the same key yields the same address after a testnet wipe and at mainnet genesis.
Say the word if you'd rather have a different form (e.g. a designated mainnet address) and I'll supply it.
Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0014.