-
-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Arbitrum One and Arbitrum Nova Support #1112
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
BIN_IMAGE = blockbook-build | ||
DEB_IMAGE = blockbook-build-deb | ||
PACKAGER = $(shell id -u):$(shell id -g) | ||
DOCKER_VERSION = $(shell docker version --format '{{.Client.Version}}') | ||
BASE_IMAGE = $$(awk -F= '$$1=="ID" { print $$2 ;}' /etc/os-release):$$(awk -F= '$$1=="VERSION_ID" { print $$2 ;}' /etc/os-release | tr -d '"') | ||
NO_CACHE = false | ||
TCMALLOC = | ||
|
@@ -27,7 +28,7 @@ test-all: .bin-image | |
docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test-all ARGS="$(ARGS)" | ||
|
||
deb-backend-%: .deb-image | ||
docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh backend $* $(ARGS) | ||
docker run -t --rm -e PACKAGER=$(PACKAGER) -v /var/run/docker.sock:/var/run/docker.sock -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh backend $* $(ARGS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mount docker socket to enable the ability to pull docker images from inside a docker container |
||
|
||
deb-blockbook-%: .deb-image | ||
docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh blockbook $* $(ARGS) | ||
|
@@ -55,7 +56,7 @@ build-images: clean-images | |
.deb-image: .bin-image | ||
@if [ $$(build/tools/image_status.sh $(DEB_IMAGE):latest build/docker) != "ok" ]; then \ | ||
echo "Building image $(DEB_IMAGE)..."; \ | ||
docker build --no-cache=$(NO_CACHE) -t $(DEB_IMAGE) build/docker/deb; \ | ||
docker build --no-cache=$(NO_CACHE) --build-arg DOCKER_VERSION=$(DOCKER_VERSION) -t $(DEB_IMAGE) build/docker/deb; \ | ||
else \ | ||
echo "Image $(DEB_IMAGE) is up to date"; \ | ||
fi | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package arbitrum | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
|
||
"github.com/golang/glog" | ||
"github.com/juju/errors" | ||
"github.com/trezor/blockbook/bchain" | ||
"github.com/trezor/blockbook/bchain/coins/eth" | ||
) | ||
|
||
const ( | ||
ArbitrumOneMainNet eth.Network = 42161 | ||
ArbitrumNovaMainNet eth.Network = 42170 | ||
) | ||
|
||
// ArbitrumRPC is an interface to JSON-RPC arbitrum service. | ||
type ArbitrumRPC struct { | ||
*eth.EthereumRPC | ||
} | ||
|
||
// NewArbitrumRPC returns new ArbitrumRPC instance. | ||
func NewArbitrumRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) { | ||
c, err := eth.NewEthereumRPC(config, pushHandler) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
s := &ArbitrumRPC{ | ||
EthereumRPC: c.(*eth.EthereumRPC), | ||
} | ||
|
||
return s, nil | ||
} | ||
|
||
// Initialize arbitrum rpc interface | ||
func (b *ArbitrumRPC) Initialize() error { | ||
b.OpenRPC = eth.OpenRPC | ||
|
||
rc, ec, err := b.OpenRPC(b.ChainConfig.RPCURL) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// set chain specific | ||
b.Client = ec | ||
b.RPC = rc | ||
b.NewBlock = eth.NewEthereumNewBlock() | ||
b.NewTx = eth.NewEthereumNewTx() | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), b.Timeout) | ||
defer cancel() | ||
|
||
id, err := b.Client.NetworkID(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// parameters for getInfo request | ||
switch eth.Network(id.Uint64()) { | ||
case ArbitrumOneMainNet: | ||
b.MainNetChainID = ArbitrumOneMainNet | ||
b.Testnet = false | ||
b.Network = "livenet" | ||
case ArbitrumNovaMainNet: | ||
b.MainNetChainID = ArbitrumNovaMainNet | ||
b.Testnet = false | ||
b.Network = "livenet" | ||
default: | ||
return errors.Errorf("Unknown network id %v", id) | ||
} | ||
|
||
glog.Info("rpc: block chain ", b.Network) | ||
|
||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,16 @@ RUN apt-get update && \ | |
apt-get install -y devscripts debhelper make dh-exec zstd && \ | ||
apt-get clean | ||
|
||
# install docker cli | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Install docker cli to enable binary via docker image |
||
ARG DOCKER_VERSION | ||
|
||
RUN if [ -z "$DOCKER_VERSION" ]; then echo "DOCKER_VERSION is a required build arg" && exit 1; fi | ||
|
||
RUN wget -O docker.tgz "https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz" && \ | ||
tar -xzf docker.tgz --strip 1 -C /usr/local/bin/ && \ | ||
rm docker.tgz && \ | ||
docker --version | ||
|
||
ADD gpg-keys /tmp/gpg-keys | ||
RUN gpg --batch --import /tmp/gpg-keys/* | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,16 @@ | |
ARCHIVE := $(shell basename {{.Backend.BinaryURL}}) | ||
|
||
all: | ||
mkdir backend | ||
{{- if ne .Backend.DockerImage "" }} | ||
docker container inspect extract > /dev/null 2>&1 && docker rm extract || true | ||
docker create --name extract {{.Backend.DockerImage}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create docker extraction image to allow copying of pre-built contents directly from the official docker image |
||
{{- if eq .Backend.VerificationType "docker"}} | ||
[ "$$(docker inspect --format='{{`{{index .RepoDigests 0}}`}}' {{.Backend.DockerImage}} | sed 's/.*@sha256://')" = "{{.Backend.VerificationSource}}" ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. docker verification type will validate the hash of the specified docker image |
||
{{- end}} | ||
{{.Backend.ExtractCommand}} | ||
docker rm extract | ||
{{- else }} | ||
wget {{.Backend.BinaryURL}} | ||
{{- if eq .Backend.VerificationType "gpg"}} | ||
wget {{.Backend.VerificationSource}} -O checksum | ||
|
@@ -13,8 +23,8 @@ all: | |
{{- else if eq .Backend.VerificationType "sha256"}} | ||
[ "$$(sha256sum ${ARCHIVE} | cut -d ' ' -f 1)" = "{{.Backend.VerificationSource}}" ] | ||
{{- end}} | ||
mkdir backend | ||
{{.Backend.ExtractCommand}} ${ARCHIVE} | ||
{{- end}} | ||
{{- if .Backend.ExcludeFiles}} | ||
# generated from exclude_files | ||
{{- range $index, $name := .Backend.ExcludeFiles}} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
|
||
{{define "main" -}} | ||
|
||
set -e | ||
|
||
INSTALL_DIR={{.Env.BackendInstallPath}}/{{.Coin.Alias}} | ||
DATA_DIR={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend | ||
|
||
NITRO_BIN=$INSTALL_DIR/nitro | ||
|
||
$NITRO_BIN \ | ||
--chain.name arb1 \ | ||
--init.url https://snapshot.arbitrum.foundation/arb1/nitro-pruned.tar \ | ||
--init.download-path $DATA_DIR/tmp \ | ||
--auth.jwtsecret $DATA_DIR/jwtsecret \ | ||
--persistent.chain $DATA_DIR \ | ||
--parent-chain.connection.url http://127.0.0.1:8136 \ | ||
--parent-chain.blob-client.beacon-url http://127.0.0.1:7536 \ | ||
--http.addr 127.0.0.1 \ | ||
--http.port {{.Ports.BackendHttp}} \ | ||
--http.api eth,net,web3,debug,txpool,arb \ | ||
--http.vhosts '*' \ | ||
--http.corsdomain '*' \ | ||
--ws.addr 127.0.0.1 \ | ||
--ws.api eth,net,web3,debug,txpool,arb \ | ||
--ws.port {{.Ports.BackendRPC}} \ | ||
--ws.origins '*' \ | ||
--file-logging.enable='false' \ | ||
--node.staker.enable='false' \ | ||
--execution.tx-lookup-limit 0 \ | ||
--validation.wasm.allowed-wasm-module-roots "$INSTALL_DIR/nitro-legacy/machines,$INSTALL_DIR/target/machines" | ||
|
||
{{end}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
|
||
{{define "main" -}} | ||
|
||
set -e | ||
|
||
INSTALL_DIR={{.Env.BackendInstallPath}}/{{.Coin.Alias}} | ||
DATA_DIR={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend | ||
|
||
NITRO_BIN=$INSTALL_DIR/nitro | ||
|
||
$NITRO_BIN \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have found that running this script demands write access to |
||
--chain.name arb1 \ | ||
--init.url https://snapshot.arbitrum.foundation/arb1/nitro-archive.tar \ | ||
--init.download-path $DATA_DIR/tmp \ | ||
--auth.jwtsecret $DATA_DIR/jwtsecret \ | ||
--persistent.chain $DATA_DIR \ | ||
--parent-chain.connection.url http://127.0.0.1:8136 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the |
||
--parent-chain.blob-client.beacon-url http://127.0.0.1:7536 \ | ||
--http.addr 127.0.0.1 \ | ||
--http.port {{.Ports.BackendHttp}} \ | ||
--http.api eth,net,web3,debug,txpool,arb \ | ||
--http.vhosts '*' \ | ||
--http.corsdomain '*' \ | ||
--ws.addr 127.0.0.1 \ | ||
--ws.api eth,net,web3,debug,txpool,arb \ | ||
--ws.port {{.Ports.BackendRPC}} \ | ||
--ws.origins '*' \ | ||
--file-logging.enable='false' \ | ||
--node.staker.enable='false' \ | ||
--execution.caching.archive \ | ||
--execution.tx-lookup-limit 0 \ | ||
--validation.wasm.allowed-wasm-module-roots "$INSTALL_DIR/nitro-legacy/machines,$INSTALL_DIR/target/machines" | ||
|
||
{{end}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
|
||
{{define "main" -}} | ||
|
||
set -e | ||
|
||
INSTALL_DIR={{.Env.BackendInstallPath}}/{{.Coin.Alias}} | ||
DATA_DIR={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend | ||
|
||
NITRO_BIN=$INSTALL_DIR/nitro | ||
|
||
$NITRO_BIN \ | ||
--chain.name nova \ | ||
--init.url https://snapshot.arbitrum.foundation/nova/nitro-pruned.tar \ | ||
--init.download-path $DATA_DIR/tmp \ | ||
--auth.jwtsecret $DATA_DIR/jwtsecret \ | ||
--persistent.chain $DATA_DIR \ | ||
--parent-chain.connection.url http://127.0.0.1:8136 \ | ||
--parent-chain.blob-client.beacon-url http://127.0.0.1:7536 \ | ||
--http.addr 127.0.0.1 \ | ||
--http.port {{.Ports.BackendHttp}} \ | ||
--http.api eth,net,web3,debug,txpool,arb \ | ||
--http.vhosts '*' \ | ||
--http.corsdomain '*' \ | ||
--ws.addr 127.0.0.1 \ | ||
--ws.api eth,net,web3,debug,txpool,arb \ | ||
--ws.port {{.Ports.BackendRPC}} \ | ||
--ws.origins '*' \ | ||
--file-logging.enable='false' \ | ||
--node.staker.enable='false' \ | ||
--execution.tx-lookup-limit 0 \ | ||
--validation.wasm.allowed-wasm-module-roots "$INSTALL_DIR/nitro-legacy/machines,$INSTALL_DIR/target/machines" | ||
|
||
{{end}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
|
||
{{define "main" -}} | ||
|
||
set -e | ||
|
||
INSTALL_DIR={{.Env.BackendInstallPath}}/{{.Coin.Alias}} | ||
DATA_DIR={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend | ||
|
||
NITRO_BIN=$INSTALL_DIR/nitro | ||
|
||
$NITRO_BIN \ | ||
--chain.name nova \ | ||
--init.url https://snapshot.arbitrum.foundation/nova/nitro-archive.tar \ | ||
--init.download-path $DATA_DIR/tmp \ | ||
--auth.jwtsecret $DATA_DIR/jwtsecret \ | ||
--persistent.chain $DATA_DIR \ | ||
--parent-chain.connection.url http://127.0.0.1:8136 \ | ||
--parent-chain.blob-client.beacon-url http://127.0.0.1:7536 \ | ||
--http.addr 127.0.0.1 \ | ||
--http.port {{.Ports.BackendHttp}} \ | ||
--http.api eth,net,web3,debug,txpool,arb \ | ||
--http.vhosts '*' \ | ||
--http.corsdomain '*' \ | ||
--ws.addr 127.0.0.1 \ | ||
--ws.api eth,net,web3,debug,txpool,arb \ | ||
--ws.port {{.Ports.BackendRPC}} \ | ||
--ws.origins '*' \ | ||
--file-logging.enable='false' \ | ||
--node.staker.enable='false' \ | ||
--execution.caching.archive \ | ||
--execution.tx-lookup-limit 0 \ | ||
--validation.wasm.allowed-wasm-module-roots "$INSTALL_DIR/nitro-legacy/machines,$INSTALL_DIR/target/machines" | ||
|
||
{{end}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"coin": { | ||
"name": "Arbitrum", | ||
"shortcut": "ETH", | ||
"label": "Arbitrum", | ||
"alias": "arbitrum" | ||
}, | ||
"ports": { | ||
"backend_rpc": 8205, | ||
"backend_p2p": 38405, | ||
"backend_http": 8305, | ||
"blockbook_internal": 9205, | ||
"blockbook_public": 9305 | ||
}, | ||
"ipc": { | ||
"rpc_url_template": "ws://127.0.0.1:{{.Ports.BackendRPC}}", | ||
"rpc_timeout": 25 | ||
}, | ||
"backend": { | ||
"package_name": "backend-arbitrum", | ||
"package_revision": "satoshilabs-1", | ||
"system_user": "arbitrum", | ||
"version": "3.0.3", | ||
"docker_image": "offchainlabs/nitro-node:v3.0.3-3ecd01e", | ||
"verification_type": "docker", | ||
"verification_source": "6bfb702e99d66db88658e712ed0d8691abe03797afe436eaab60a6f31e627e0d", | ||
"extract_command": "docker cp extract:/home/user/target backend/target; docker cp extract:/home/user/nitro-legacy backend/nitro-legacy; docker cp extract:/usr/local/bin/nitro backend/nitro", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. example of docker extract command. copy the nitro binary and associated wasm modules |
||
"exclude_files": [], | ||
"exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/arbitrum_exec.sh 2>> {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'", | ||
"exec_script": "arbitrum.sh", | ||
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log", | ||
"postinst_script_template": "openssl rand -hex 32 > {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/jwtsecret", | ||
"service_type": "simple", | ||
"service_additional_params_template": "", | ||
"protect_memory": true, | ||
"mainnet": true, | ||
"server_config_file": "", | ||
"client_config_file": "" | ||
}, | ||
"blockbook": { | ||
"package_name": "blockbook-arbitrum", | ||
"system_user": "blockbook-arbitrum", | ||
"internal_binding_template": ":{{.Ports.BlockbookInternal}}", | ||
"public_binding_template": ":{{.Ports.BlockbookPublic}}", | ||
"explorer_url": "", | ||
"additional_params": "", | ||
"block_chain": { | ||
"parse": true, | ||
"mempool_workers": 8, | ||
"mempool_sub_workers": 2, | ||
"block_addresses_to_keep": 300, | ||
"additional_params": { | ||
"mempoolTxTimeoutHours": 48, | ||
"queryBackendOnMempoolResync": false, | ||
"fiat_rates": "coingecko", | ||
"fiat_rates_vs_currencies": "AED,ARS,AUD,BDT,BHD,BMD,BRL,CAD,CHF,CLP,CNY,CZK,DKK,EUR,GBP,HKD,HUF,IDR,ILS,INR,JPY,KRW,KWD,LKR,MMK,MXN,MYR,NGN,NOK,NZD,PHP,PKR,PLN,RUB,SAR,SEK,SGD,THB,TRY,TWD,UAH,USD,VEF,VND,ZAR,BTC,ETH", | ||
"fiat_rates_params": "{\"url\": \"https://api.coingecko.com/api/v3\", \"coin\": \"ethereum\",\"platformIdentifier\": \"ethereum\",\"platformVsCurrency\": \"eth\",\"periodSeconds\": 900}" | ||
} | ||
} | ||
}, | ||
"meta": { | ||
"package_maintainer": "IT", | ||
"package_maintainer_email": "[email protected]" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the same docker version installed on host machine for deb image for safety