Skip to content

Commit 53d219d

Browse files
committed
fix: update soft block limit to 2MiB
This is needed because the 1MiB limit is the chunker limit, however the actual blocks can be wrapped in protobuf which adds a small ~10 byte overhead.
1 parent 5615715 commit 53d219d

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

core/commands/cmdutils/utils.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111

1212
const (
1313
AllowBigBlockOptionName = "allow-big-block"
14-
SoftBlockLimit = 1024 * 1024 // https://github.com/ipfs/go-ipfs/issues/7421#issuecomment-910833499
14+
SoftBlockLimit = 1024 * 1024 * 2 // https://github.com/web3-storage/web3.storage/pull/1269#issuecomment-1108834504
1515
)
1616

1717
var AllowBigBlockOption cmds.Option
1818

1919
func init() {
20-
AllowBigBlockOption = cmds.BoolOption(AllowBigBlockOptionName, "Disable block size check and allow creation of blocks bigger than 1MiB. WARNING: such blocks won't be transferable over the standard bitswap.").WithDefault(false)
20+
AllowBigBlockOption = cmds.BoolOption(AllowBigBlockOptionName, "Disable block size check and allow creation of blocks bigger than 2MiB. WARNING: such blocks won't be transferable over the standard bitswap.").WithDefault(false)
2121
}
2222

2323
func CheckCIDSize(req *cmds.Request, c cid.Cid, dagAPI coreiface.APIDagService) error {
@@ -40,11 +40,11 @@ func CheckBlockSize(req *cmds.Request, size uint64) error {
4040
return nil
4141
}
4242

43-
// We do not allow producing blocks bigger than 1 MiB to avoid errors
44-
// when transmitting them over BitSwap. The 1 MiB constant is an
43+
// We do not allow producing blocks bigger than 2MiB to avoid errors
44+
// when transmitting them over BitSwap. The 2MiB constant is an
4545
// unenforced and undeclared rule of thumb hard-coded here.
4646
if size > SoftBlockLimit {
47-
return fmt.Errorf("produced block is over 1MiB: big blocks can't be exchanged with other peers. consider using UnixFS for automatic chunking of bigger files, or pass --allow-big-block to override")
47+
return fmt.Errorf("produced block is over 2MiB: big blocks can't be exchanged with other peers. consider using UnixFS for automatic chunking of bigger files, or pass --allow-big-block to override")
4848
}
4949
return nil
5050

test/sharness/t0050-block.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,17 +291,17 @@ test_expect_success "put with sha3 and cidv0 fails" '
291291
'
292292

293293
test_expect_success "'ipfs block put' check block size" '
294-
dd if=/dev/zero bs=2MB count=1 > 2-MB-file &&
295-
test_expect_code 1 ipfs block put 2-MB-file >block_put_out 2>&1
294+
dd if=/dev/zero bs=4MB count=1 > 4-MB-file &&
295+
test_expect_code 1 ipfs block put 4-MB-file >block_put_out 2>&1
296296
'
297297

298298
test_expect_success "ipfs block put output has the correct error" '
299-
grep "produced block is over 1MiB" block_put_out
299+
grep "produced block is over 2MiB" block_put_out
300300
'
301301

302302
test_expect_success "ipfs block put --allow-big-block=true works" '
303-
test_expect_code 0 ipfs block put 2-MB-file --allow-big-block=true &&
304-
rm 2-MB-file
303+
test_expect_code 0 ipfs block put 4-MB-file --allow-big-block=true &&
304+
rm 4-MB-file
305305
'
306306

307307
test_done

test/sharness/t0051-object.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,16 @@ test_object_cmd() {
225225

226226
test_expect_success "'ipfs object patch' check output block size" '
227227
DIR=$(ipfs object new unixfs-dir)
228-
for i in {1..13}
228+
for i in {1..14}
229229
do
230230
DIR=$(ipfs object patch "$DIR" add-link "$DIR.jpg" "$DIR")
231231
done
232-
# Fail when new block goes over the BS limit of 1MiB, but allow manual override
232+
# Fail when new block goes over the BS limit of 2MiB, but allow manual override
233233
test_expect_code 1 ipfs object patch "$DIR" add-link "$DIR.jpg" "$DIR" >patch_out 2>&1
234234
'
235235

236236
test_expect_success "ipfs object patch add-link output has the correct error" '
237-
grep "produced block is over 1MiB" patch_out
237+
grep "produced block is over 2MiB" patch_out
238238
'
239239

240240
test_expect_success "ipfs object patch --allow-big-block=true add-link works" '
@@ -310,7 +310,7 @@ test_object_cmd() {
310310
test_expect_success "'ipfs object stat --human' succeeds" '
311311
ipfs object stat $(cat multi_patch)/a --human > obj_stat_human_out
312312
'
313-
313+
314314
test_expect_success "ipfs object stat --human output looks good" '
315315
echo "NumLinks: 1" > obj_stat_human_exp &&
316316
echo "BlockSize: 47" >> obj_stat_human_exp &&

test/sharness/t0053-dag.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ test_dag_cmd() {
4545
'
4646

4747
test_expect_success "'ipfs dag put' check block size" '
48-
dd if=/dev/zero bs=2MB count=1 > 2-MB-file &&
49-
test_expect_code 1 ipfs dag put --input-codec=raw --store-codec=raw 2-MB-file >dag_put_out 2>&1
48+
dd if=/dev/zero bs=4MB count=1 > 4-MB-file &&
49+
test_expect_code 1 ipfs dag put --input-codec=raw --store-codec=raw 4-MB-file >dag_put_out 2>&1
5050
'
5151

5252
test_expect_success "ipfs dag put output has the correct error" '
53-
grep "produced block is over 1MiB" dag_put_out
53+
grep "produced block is over 2MiB" dag_put_out
5454
'
5555

5656
test_expect_success "ipfs dag put --allow-big-block=true works" '
57-
test_expect_code 0 ipfs dag put --input-codec=raw --store-codec=raw 2-MB-file --allow-big-block=true &&
58-
rm 2-MB-file
57+
test_expect_code 0 ipfs dag put --input-codec=raw --store-codec=raw 4-MB-file --allow-big-block=true &&
58+
rm 4-MB-file
5959
'
6060

6161
test_expect_success "can add an ipld object using dag-json to dag-json" '

test/sharness/t0054-dag-car-import-export.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,16 @@ test_expect_success "naked root import expected output" '
234234
'
235235

236236
test_expect_success "'ipfs dag import' check block size" '
237-
BIG_CID=$(dd if=/dev/zero bs=2MB count=1 | ipfs dag put --input-codec=raw --store-codec=raw --allow-big-block) &&
238-
ipfs dag export $BIG_CID > 2-MB-block.car &&
239-
test_expect_code 1 ipfs dag import 2-MB-block.car >dag_import_out 2>&1
237+
BIG_CID=$(dd if=/dev/zero bs=4MB count=1 | ipfs dag put --input-codec=raw --store-codec=raw --allow-big-block) &&
238+
ipfs dag export $BIG_CID > 4-MB-block.car &&
239+
test_expect_code 1 ipfs dag import 4-MB-block.car >dag_import_out 2>&1
240240
'
241241
test_expect_success "ipfs dag import output has the correct error" '
242-
grep "block is over 1MiB" dag_import_out
242+
grep "block is over 2MiB" dag_import_out
243243
'
244244

245245
test_expect_success "ipfs dag import --allow-big-block works" '
246-
test_expect_code 0 ipfs dag import --allow-big-block 2-MB-block.car
246+
test_expect_code 0 ipfs dag import --allow-big-block 4-MB-block.car
247247
'
248248

249249
cat > version_2_import_expected << EOE

0 commit comments

Comments
 (0)