mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 13:25:43 +01:00
gossipd: drop zlib support.
This was removed from the spec on Apr 25, 2022. We stopped ever sending them in 0.12.0 (2022-08-23). Now we remove receive support. Changelog-Protocol: Removed support for zlib-compressed short-channel-ids in query responses. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
d60977f37f
commit
531845971c
4
Makefile
4
Makefile
@ -271,9 +271,9 @@ ifeq ($(STATIC),1)
|
||||
# For MacOS, Jacob Rapoport <jacob@rumblemonkey.com> changed this to:
|
||||
# -L/usr/local/lib -lsqlite3 -lz -Wl,-lm -lpthread -ldl $(COVFLAGS)
|
||||
# But that doesn't static link.
|
||||
LDLIBS = -L$(CPATH) -Wl,-dn $(SQLITE3_LDLIBS) -lz -Wl,-dy -lm -lpthread -ldl $(COVFLAGS)
|
||||
LDLIBS = -L$(CPATH) -Wl,-dn $(SQLITE3_LDLIBS) -Wl,-dy -lm -lpthread -ldl $(COVFLAGS)
|
||||
else
|
||||
LDLIBS = -L$(CPATH) -lm $(SQLITE3_LDLIBS) -lz $(COVFLAGS)
|
||||
LDLIBS = -L$(CPATH) -lm $(SQLITE3_LDLIBS) $(COVFLAGS)
|
||||
endif
|
||||
|
||||
# If we have the postgres client library we need to link against it as well
|
||||
|
@ -2,25 +2,6 @@
|
||||
#include <ccan/cast/cast.h>
|
||||
#include <common/decode_array.h>
|
||||
#include <wire/peer_wire.h>
|
||||
#include <zlib.h>
|
||||
|
||||
static u8 *unzlib(const tal_t *ctx, const u8 *encoded, size_t len)
|
||||
{
|
||||
/* http://www.zlib.net/zlib_tech.html gives 1032:1 as worst-case,
|
||||
* which is 67632120 bytes for us. But they're not encoding zeroes,
|
||||
* and each scid must be unique. So 1MB is far more reasonable. */
|
||||
unsigned long unclen = 1024*1024;
|
||||
int zerr;
|
||||
u8 *unc = tal_arr(ctx, u8, unclen);
|
||||
|
||||
zerr = uncompress(unc, &unclen, encoded, len);
|
||||
if (zerr != Z_OK)
|
||||
return tal_free(unc);
|
||||
|
||||
/* Truncate and return. */
|
||||
tal_resize(&unc, unclen);
|
||||
return unc;
|
||||
}
|
||||
|
||||
struct short_channel_id *decode_short_ids(const tal_t *ctx, const u8 *encoded)
|
||||
{
|
||||
@ -43,11 +24,7 @@ struct short_channel_id *decode_short_ids(const tal_t *ctx, const u8 *encoded)
|
||||
type = fromwire_u8(&encoded, &max);
|
||||
switch (type) {
|
||||
case ARR_ZLIB_DEPRECATED:
|
||||
encoded = unzlib(tmpctx, encoded, max);
|
||||
if (!encoded)
|
||||
return NULL;
|
||||
max = tal_count(encoded);
|
||||
/* fall thru */
|
||||
return NULL;
|
||||
case ARR_UNCOMPRESSED:
|
||||
scids = tal_arr(ctx, struct short_channel_id, 0);
|
||||
while (max) {
|
||||
@ -86,11 +63,7 @@ bigsize_t *decode_scid_query_flags(const tal_t *ctx,
|
||||
*/
|
||||
switch (qf->encoding_type) {
|
||||
case ARR_ZLIB_DEPRECATED:
|
||||
encoded = unzlib(tmpctx, encoded, max);
|
||||
if (!encoded)
|
||||
return NULL;
|
||||
max = tal_count(encoded);
|
||||
/* fall thru */
|
||||
return NULL;
|
||||
case ARR_UNCOMPRESSED:
|
||||
flags = tal_arr(ctx, bigsize_t, 0);
|
||||
while (max)
|
||||
@ -120,11 +93,7 @@ decode_channel_update_timestamps(const tal_t *ctx,
|
||||
* query_short_channel_ids_tlvs! */
|
||||
switch (timestamps_tlv->encoding_type) {
|
||||
case ARR_ZLIB_DEPRECATED:
|
||||
encoded = unzlib(tmpctx, encoded, max);
|
||||
if (!encoded)
|
||||
return NULL;
|
||||
max = tal_count(encoded);
|
||||
/* fall thru */
|
||||
return NULL;
|
||||
case ARR_UNCOMPRESSED:
|
||||
ts = tal_arr(ctx, struct channel_update_timestamps, 0);
|
||||
while (max) {
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <ccan/str/hex/hex.h>
|
||||
#include <common/decode_array.h>
|
||||
#include <stdio.h>
|
||||
#include <zlib.h>
|
||||
|
||||
static NORETURN void usage(void)
|
||||
{
|
||||
@ -43,20 +42,7 @@ int main(int argc, char *argv[])
|
||||
if (encoding == ARR_UNCOMPRESSED)
|
||||
printf("%02x%s\n", encoding, tal_hex(NULL, data));
|
||||
else if (encoding == ARR_ZLIB_DEPRECATED) {
|
||||
/* https://www.zlib.net/zlib_tech.html:
|
||||
* the only expansion is an overhead of five bytes per 16 KB
|
||||
* block (about 0.03%), plus a one-time overhead of six bytes
|
||||
* for the entire stream.
|
||||
*/
|
||||
unsigned long compressed_len = tal_bytelen(data)
|
||||
+ 6 + 5*(tal_bytelen(data) + 16384)/16384;
|
||||
u8 *z = tal_arr(NULL, u8, compressed_len);
|
||||
if (compress2(z, &compressed_len, data, tal_bytelen(data),
|
||||
Z_DEFAULT_COMPRESSION) != Z_OK)
|
||||
errx(1, "Error compressing stream?");
|
||||
|
||||
printf("%02x%s\n", encoding,
|
||||
tal_hexstr(NULL, z, compressed_len));
|
||||
errx(1, "ZLIB compression deprecated");
|
||||
} else {
|
||||
errx(1, "Unknown encoding %u", encoding);
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <gossipd/gossipd_wiregen.h>
|
||||
#include <gossipd/gossmap_manage.h>
|
||||
#include <gossipd/queries.h>
|
||||
#include <zlib.h>
|
||||
|
||||
static u32 dev_max_encoding_bytes = -1U;
|
||||
|
||||
|
@ -14,15 +14,12 @@
|
||||
# define IF_SQLITE3(...)
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <zlib.h>
|
||||
|
||||
static const char template[] =
|
||||
"/* Generated file by tools/headerversions, do not edit! */\n"
|
||||
IF_SQLITE3("/* SQLITE3 version: %u */\n")
|
||||
"/* ZLIB version: %s */\n"
|
||||
"#include <ccan/err/err.h>\n"
|
||||
IF_SQLITE3("#include <sqlite3.h>\n")
|
||||
"#include <zlib.h>\n"
|
||||
"\n"
|
||||
"static inline void check_linked_library_versions(void)\n"
|
||||
"{\n"
|
||||
@ -36,10 +33,6 @@ static const char template[] =
|
||||
" errx(1, \"SQLITE major version mismatch: compiled %%u, now %%u\",\n"
|
||||
" SQLITE_VERSION_NUMBER, sqlite3_libversion_number());\n"
|
||||
)
|
||||
" /* zlib documents that first char alters ABI. Kudos! */\n"
|
||||
" if (zlibVersion()[0] != ZLIB_VERSION[0])\n"
|
||||
" errx(1, \"zlib version mismatch: compiled %%s, now %%s\",\n"
|
||||
" ZLIB_VERSION, zlibVersion());\n"
|
||||
"}\n";
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@ -57,8 +50,7 @@ int main(int argc, char *argv[])
|
||||
err(1, "Reading %s", argv[1]);
|
||||
|
||||
new = tal_fmt(NULL, template,
|
||||
IF_SQLITE3(sqlite3_libversion_number(),)
|
||||
zlibVersion());
|
||||
IF_SQLITE3(sqlite3_libversion_number()));
|
||||
if (!file || !streq(new, file)) {
|
||||
int fd = open(argv[1], O_TRUNC|O_WRONLY|O_CREAT, 0666);
|
||||
if (fd < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user