Open
Description
I've followed the Get Started with Hasura DDN and ClickHouse
guide using the following table and data:
CREATE TABLE IF NOT EXISTS chaingraph.block
(
internal_id UInt64 COMMENT 'A unique, UInt64 identifier for this block assigned by Chaingraph. This value is not guaranteed to be consistent between Chaingraph instances.' CODEC(DoubleDelta, ZSTD),
height UInt32 COMMENT 'The height of this block: the number of blocks mined between this block and its genesis block (block 0).' CODEC(Delta, ZSTD),
version Int32 COMMENT 'The "version" field of this block; a 4-byte field typically represented as an Int32. While originally designed to indicate a block''s version, this field has been used for several other purposes. BIP34 ("Height in Coinbase") enforced a minimum version of 2, BIP66 ("Strict DER Signatures") enforced a minimum version of 3, then BIP9 repurposed most bits of the version field for network signaling. In recent years, the version field is also used for the AsicBoost mining optimization.' CODEC(T64, ZSTD),
timestamp UInt32 COMMENT 'The Uint32 current Unix timestamp claimed by the miner at the time this block was mined. By consensus, block timestamps must be within ~2 hours of the actual time, but timestamps are not guaranteed to be accurate. Timestamps of later blocks can also be earlier than their parent blocks.' CODEC(T64, ZSTD),
hash FixedString(32) COMMENT 'The 32-byte, double-sha256 hash of the block header (encoded using the standard P2P network format) in big-endian byte order. This is used as a universal, unique identifier for the block. Big-endian byte order is typically seen in block explorers and user interfaces (as opposed to little-endian byte order, which is used in standard P2P network messages).', -- While a hash, mining produces less-random values, so default compression is enabled rather than CODEC(NONE)
previous_block_hash FixedString(32) COMMENT 'The 32-byte, double-sha256 hash of the previous block''s header in big-endian byte order. This is the byte order typically seen in block explorers and user interfaces (as opposed to little-endian byte order, which is used in standard P2P network messages).', -- References block hashes, so also uses default compression
merkle_root FixedString(32) COMMENT 'The 32-byte root hash of the double-sha256 merkle tree of transactions confirmed by this block. Note, the unusual merkle tree construction used by most chains is vulnerable to CVE-2012-2459. The final node in oddly-numbered levels is duplicated, and special care is required to ensure trees contain minimal duplication.' CODEC(NONE),
bits UInt32 COMMENT 'The Uint32 packed representation of the difficulty target being used for this block. To be valid, the block hash value must be less than this difficulty target.' CODEC(T64, ZSTD),
nonce UInt32 COMMENT 'The uint32 nonce used for this block. This field allows miners to introduce entropy into the block header, changing the resulting hash during mining.',
size_bytes UInt32 COMMENT 'The network-encoded size of this block in bytes including transactions.' CODEC(T64, ZSTD) -- Requires migration to UInt64 beyond ~4.2GB
)
ENGINE = MergeTree
ORDER BY (internal_id)
COMMENT 'A blockchain block.';
And some sample data:
INSERT INTO chaingraph.block (`internal_id`, `height`, `version`, `timestamp`, `hash`, `previous_block_hash`, `merkle_root`, `bits`, `nonce`, `size_bytes`) VALUES (883295, 881225, 696573952, 1736993947, '\0\0\0\0\0\0\0\0\0e??w=ܼ??A?3C???7?\b?', '\0\0\0\0\0\0\0\0\0?????-p???`??`?*"??B7', 'b?&bBV?"P?:?b|?Sn?Ձ@m?x\f\00)', 402794910, 2174162995, 105300), (883294, 881224, 541065216, 1736992984, '\0\0\0\0\0\0\0\0\0?????-p???`??`?*"??B7', '\0\0\0\0\0\0\0\0\0>?\\?ժ?w?~\r????b3??', '\0?KrW??n?ʓ/?\t}??\f????^G?\\?R', 402795160, 2767849536, 16946), (883293, 881223, 536952832, 1736992824, '\0\0\0\0\0\0\0\0\0>?\\?ժ?w?~\r????b3??', '\0\0\0\0\0\0\0\0\0?v?\'??trU??)5\fߏO??,, '????{??5???\rI?rݼ6?AY?WV-??]', 402795183, 3150015996, 57903), (883292, 881222, 636264448, 1736992264, '\0\0\0\0\0\0\0\0\0?v?\'??trU??)5\fߏO??,, '\0\0\0\0\0\0\0\0??j[lH?lV?L0? 0???Ӄ', '??Zf?\n?1?TӤ???\n$?2}??\n1?ޟ?\n?', 402795393, 3363543219, 12386), (883291, 881221, 1040187392, 1736992033, '\0\0\0\0\0\0\0\0??j[lH?lV?L0? 0???Ӄ', '\0\0\0\0\0\0\0\0\b??,?r?|????\0T?|I?\r?@?U', 'زr?*ǫ????ؒ??V??>?;?c\tZ?????', 402795454, 2916308377, 41081), (883290, 881220, 794255360, 1736991539, '\0\0\0\0\0\0\0\0\b??,?r?|????\0T?|I?\r?@?U', '\0\0\0\0\0\0\0\0\0?q???!?}B1?<_?(????r?', '?W???g!???f^D?b\'c?=l??P<?0?G?\'', 402795651, 1693175809, 17300), (883289, 881219, 593846272, 1736991284, '\0\0\0\0\0\0\0\0\0?q???!?}B1?<_?(????r?', '\0\0\0\0\0\0\0\0%ף???w?I??M????o', '<????8?E\r??C??ӼX??3a?X"?\t?g?R?', 402795170, 1472665657, 133537), (883288, 881218, 1006632960, 1736989840, '\0\0\0\0\0\0\0\0%ף???w?I??M????o', '\0\0\0\0\0\0\0\0L???2DX??3ZV??}???\0B', '?yN?q???`*V?ц?)H?p?Sj???W', 402795488, 1505436101, 16579), (883287, 881217, 577945600, 1736989799, '\0\0\0\0\0\0\0\0L???2DX??3ZV??}???\0B', '\0\0\0\0\0\0\0\0\0l"???\b٣???+H~X?S??', '?`j?DA]??2??Yj`???ՠ?ITH}?h??(??', 402795659, 597684090, 33317), (883286, 881216, 603979776, 1736989498, '\0\0\0\0\0\0\0\0\0l"???\b٣???+H~X?S??', '\0\0\0\0\0\0\0\0?u}??\tzb?.%??&???is??,?', '?Ug?1bV}??.?*}?a>4XB?}??"q$?', 402795930, 236196732, 12783);
Queries requesting e.g. numbers are successful:
{
chaingraphBlock(limit: 10, order_by: {height: Desc}) {
height
sizeBytes
}
}
{
"data": {
"chaingraphBlock": [
{
"height": 881225,
"sizeBytes": 105300
},
{
"height": 881224,
"sizeBytes": 16946
},
{
"height": 881223,
"sizeBytes": 57903
},
{
"height": 881222,
"sizeBytes": 12386
},
{
"height": 881221,
"sizeBytes": 41081
},
{
"height": 881220,
"sizeBytes": 17300
},
{
"height": 881219,
"sizeBytes": 133537
},
{
"height": 881218,
"sizeBytes": 16579
},
{
"height": 881217,
"sizeBytes": 33317
},
{
"height": 881216,
"sizeBytes": 12783
}
]
}
}
While queries which request a FixedString
field fail with the error: internal error: ndc_unexpected: ndc_client error: request to connector failed with status code N/A: error decoding response body
E.g.:
{
chaingraphBlock(limit: 10, order_by: {height: Desc}) {
height
hash
}
}
{
"data": {
"chaingraphBlock": null
},
"errors": [
{
"message": "internal error",
"path": [
"chaingraphBlock"
]
}
]
}