7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

symbol-shoestringでのapiノードにおけるmetalデコード非対応について

Posted at

はじめに

いつのまにかsymbol-shoestringのバージョンアップが行われ、bootstrapで使用していたノードを引き継げるようになっていました。つまり、ハーベスターをそのままshoestringでノード運営ができます。
bootstrapはそもそもサードパーティ製でメンテナンスも難しいでしょうし、今後shoestringが主流になってくるので、これを機に乗り換えることをおすすめします。

方法は

こちらを参考にすれば問題はなかったのですが、後ほど数点追記しておきます。

ひとまずこの記事のメインはmetalデコードの対応についてなのでそちらを先に書きます。

Metalデコードとは?

Metal(メタル)とは Symbol ブロックチェーンに、任意の(サイズの)データを書き込んだり読み込んだりするためのプロトコルです。 簡単に言えば、Symbol ブロックチェーンをオンラインの不揮発性メモリ(ROM)として使用できます。

Symbolではわりと低コストで大容量のデータをBCに保存できるという点と、コミュニティがデータ保存に対する意識が強めなので、色々とこの保存の形式が模索されたりして多様のものが存在しているなかで、できればこのMetal(これ自体は僕が考えたものではない)が一般化すればいいなーと思ってREST APIでのデコードを容易にするためのアップデートをプルリクして承認されてました。

しかし、これまでのバージョンでは一つ設定を入れないと対応できませんでした。が、今回のshoestring (多分)v0.2.1からこの対応が不要になりました。

問題点

ただ、これ少しだけ問題があります。Metalを使って例えば卑猥な画像や個人情報など本来公開したくないものが悪意のある何者かによってアップされた場合でもデコードできてしまいます。
これをどう捉えるかはノード運営者さん次第なのですが企業ノードなどは避けたいという場合もあるかと思いますので、このMetalデコードに対応しないための設定をこの記事では書きたいと思います。

対応方法

ここからはMetal非対応の方法を書きますが、すでにshoestringでノード運営を始めていることが前提です。

まず、rest用の上書きファイルを作成します。ファイル名はなんでも良いですが今回は

rest-overrides.json
{
  "metal": null
}

とします、これにより初期設定では

rest.json
	"metal": {
		"cacheTtl": 300,
		"sizeLimit": 10000000
	}
}

となっているものをnullにします。rest.jsonはちょk書き換えなくていいです。
その後、

python3 -m shoestring upgrade \
  --config shoestring/shoestring.ini \
  --overrides shoestring/overrides.ini \
  --directory $(pwd) \
  --rest-overrides shoestring/rest-overrides.json

としてオプションでrest.jsonの上書きをします。
これで再度起動すればmetalデコードのエンドポイントにアクセスしてもエラーが返ってきて表示されません。

ただ、少し面倒なのがshoestringのアップデートなどでupgradeコマンドを実行するたびにこの上書き設定オプションが必要です。
コマンドがもともとわりと長めなのでおそらくコピペになるとは思いますが。

一応、書きたかったことはこれで終わりです。

bootstrap -> shoestringにあたって

余談で僕もbootstrapからshoestringに乗り換えたのですがそのときのtipsを書いておきます。

僕の環境ではshoestringのインストール時にこけました。

building 'ripemd._ripemd160' extension
      creating build/temp.linux-x86_64-cpython-312/src
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -DPYCRYPTO_LITTLE_ENDIAN -DSYS_BITS=64 -DLTC_NO_ASM -Isrc/ -I/home/toshi/symbol-node-shoestring/env/include -I/usr/include/python3.12 -c src/ripemd160.c -o build/temp.linux-x86_64-cpython-312/src/ripemd160.o
      error: command 'x86_64-linux-gnu-gcc' failed: No such file or directory
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for ripemd-hash
  Building wheel for safe-pysha3 (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for safe-pysha3 (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      /tmp/pip-build-env-emwf8o16/overlay/lib/python3.12/site-packages/setuptools/dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated.
      !!
      
              ********************************************************************************
              Please consider removing the following classifiers in favor of a SPDX license expression:
      
              License :: OSI Approved :: Python Software Foundation License
              License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
      
              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************
      
      !!
        self._finalize_license_expression()
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-312
      copying sha3.py -> build/lib.linux-x86_64-cpython-312
      running build_ext
      building '_pysha3' extension
      creating build/temp.linux-x86_64-cpython-312/Modules/_sha3
      x86_64-linux-gnu-gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O2 -Wall -fPIC -DPY_WITH_KECCAK=1 -I/home/toshi/symbol-node-shoestring/env/include -I/usr/include/python3.12 -c Modules/_sha3/sha3module.c -o build/temp.linux-x86_64-cpython-312/Modules/_sha3/sha3module.o
      error: command 'x86_64-linux-gnu-gcc' failed: No such file or directory
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for safe-pysha3
Successfully built zenlog
Failed to build symbol-lightapi ripemd-hash safe-pysha3
ERROR: Could not build wheels for symbol-lightapi, ripemd-hash, safe-pysha3, which is required to install pyproject.toml-based projects

以下でクリア

sudo apt update
sudo apt install build-essential python3-dev

bootstrap配下のファイルはshoestring配下においてるほうがいいかも

パソ美ちゃんも補足してくれてるけどbootstrapのファイル群を削除する可能性あるからね。前もってやってるほうが吉かと

/NODE/target/nodes/node/server-config/resources/config-harvesting.properties

/shoestring.ini
があるところと同じ箇所がいいと思う

同じく
/NODE/target/nodes/node/cert/node.key.pem
も同じところ
んで、
shoestring.ini

[imports]

harvester = /home/username/symbol-node-shoestring/shoestring/config-harvesting.properties
voter =
nodeKey = /home/user-name/symbol-node-shoestring/shoestring/node.key.pem

とかに書き換えておく。(絶対パスのがいいかも。人によって変わる)

データは丸々bootstrap配下から持ってきましょう

再同期は時間かかって仕方ないのでコピーしちゃいましょう

bootstrapとshoestringを停止した状態で

sudo cp -rf /home/username/bootstrap/target/databases/db /home/username/shoestring/dbdata

sudo cp -rf /home/username/bootstrap/target/target/nodes/node/data /home/username/shoestring/data

ちょっとでも進捗が知りたければ

sudo tar cf - -C /home/username/bootstrap/target/databases/db . | pv | sudo tar xf - -C /home/username/shoestring/dbdata

sudo tar cf - -C /home/username/bootstrap/target/nodes/node/data . | pv | sudo tar xf - -C /home/username/shoestring/data

この場合

sudo apt update
sudo apt install pv

が必要かも

2025/4月現在でdbが13GBでdataが89GBぐらいだと思います

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?