Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bchain/coins/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import (
"github.com/trezor/blockbook/bchain/coins/qtum"
"github.com/trezor/blockbook/bchain/coins/ravencoin"
"github.com/trezor/blockbook/bchain/coins/ritocoin"
"github.com/trezor/blockbook/bchain/coins/robinhood"
"github.com/trezor/blockbook/bchain/coins/snowgem"
"github.com/trezor/blockbook/bchain/coins/trezarcoin"
"github.com/trezor/blockbook/bchain/coins/tron"
Expand Down Expand Up @@ -153,6 +154,8 @@ func init() {
BlockChainFactories["Arbitrum Nova Archive"] = arbitrum.NewArbitrumRPC
BlockChainFactories["Base"] = base.NewBaseRPC
BlockChainFactories["Base Archive"] = base.NewBaseRPC
BlockChainFactories["Robinhood Archive"] = robinhood.NewRobinhoodRPC
BlockChainFactories["Robinhood Testnet"] = robinhood.NewRobinhoodRPC
BlockChainFactories["Tron"] = tron.NewTronRPC
BlockChainFactories["Tron Testnet Nile"] = tron.NewTronRPC
}
Expand Down
87 changes: 87 additions & 0 deletions bchain/coins/robinhood/robinhoodrpc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package robinhood

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 (
// MainNet is the chain ID of Robinhood Chain mainnet
MainNet eth.Network = 4663
// TestNet is the chain ID of Robinhood Chain testnet (settles to Sepolia)
TestNet eth.Network = 46630
)

// RobinhoodRPC is an interface to JSON-RPC robinhood service.
type RobinhoodRPC struct {
*eth.EthereumRPC
}

// NewRobinhoodRPC returns new RobinhoodRPC instance.
func NewRobinhoodRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
c, err := eth.NewEthereumRPC(config, pushHandler)
if err != nil {
return nil, err
}

s := &RobinhoodRPC{
EthereumRPC: c.(*eth.EthereumRPC),
}

return s, nil
}

// Initialize robinhood rpc interface
func (b *RobinhoodRPC) Initialize() error {
b.OpenRPC = eth.OpenRPC

rc, ec, err := b.OpenRPC(b.ChainConfig.RPCURL, b.ChainConfig.RPCURLWS)
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 MainNet:
b.MainNetChainID = MainNet
b.Testnet = false
b.Network = "livenet"
case TestNet:
b.MainNetChainID = MainNet
b.Testnet = true
b.Network = "testnet"
default:
return errors.Errorf("Unknown network id %v", id)
}

if err = b.InitAlternativeProviders(); err != nil {
return err
}

glog.Info("rpc: block chain ", b.Network)

return nil
}

func (b *RobinhoodRPC) ResolveENS(name string) (*bchain.ENSResolution, error) {
return b.EthereumRPC.ResolveENS(name)
}
269 changes: 269 additions & 0 deletions build/templates/backend/config/robinhood_genesis.json

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions build/templates/backend/scripts/robinhood_archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

{{define "main" -}}

set -e

INSTALL_DIR={{.Env.BackendInstallPath}}/{{.Coin.Alias}}
DATA_DIR={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend

NITRO_BIN=$INSTALL_DIR/nitro

# Robinhood Chain is an Arbitrum Orbit chain whose definition is not embedded in the
# nitro binary. Keep this chain info aligned with Robinhood's published mainnet file;
# the genesis state is supplied separately via the packaged {{.Coin.Alias}}.conf.
CHAIN_INFO='[{"chain-id":4663,"parent-chain-id":1,"parent-chain-is-arbitrum":false,"chain-name":"Robinhood Chain","chain-config":{"chainId":4663,"homesteadBlock":0,"daoForkBlock":null,"daoForkSupport":true,"eip150Block":0,"eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000","eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"berlinBlock":0,"londonBlock":0,"clique":{"period":0,"epoch":0},"arbitrum":{"EnableArbOS":true,"AllowDebugPrecompiles":false,"DataAvailabilityCommittee":false,"InitialArbOSVersion":51,"InitialChainOwner":"0xc8451c5DE260E7ea1b879e7994967077e71230Ca","GenesisBlockNum":0,"MaxCodeSize":98304,"MaxInitCodeSize":196608}},"rollup":{"bridge":"0xDf8755334ce7A73cCF6b581C02eA649AE3E864b3","inbox":"0x1A07cc4BD17E0118BdB54D70990D2158AbAD7a2D","sequencer-inbox":"0xBd0D173EEb87D57A09521c24388a12789F33ba96","rollup":"0x23A19d23e89166adedbDcB432518AB01e4272D94","validator-utils":"0x0000000000000000000000000000000000000000","validator-wallet-creator":"0xB7FE37712e46F28C8f22Ec4bAA33A09fb8B52BD0","stake-token":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","deployed-at":24994238}}]'

# Bind RPC endpoints based on BB_RPC_BIND_HOST_* so defaults remain local unless explicitly overridden.
$NITRO_BIN \
--chain.id 4663 \
--chain.info-json "$CHAIN_INFO" \
--init.genesis-json-file $INSTALL_DIR/{{.Coin.Alias}}.conf \
--init.download-path $DATA_DIR/tmp \
--auth.jwtsecret $DATA_DIR/jwtsecret \
--persistent.global-config $DATA_DIR \
--persistent.chain $DATA_DIR \
--parent-chain.connection.url http://127.0.0.1:8016 \
--parent-chain.blob-client.beacon-url http://127.0.0.1:7516 \
--node.feed.input.url wss://feed.mainnet.chain.robinhood.com \
--execution.forwarding-target https://sequencer.mainnet.chain.robinhood.com \
--http.addr {{.Env.RPCBindHost}} \
--http.port {{.Ports.BackendHttp}} \
--http.api eth,net,web3,debug,txpool,arb \
--http.vhosts '*' \
--http.corsdomain '*' \
--ws.addr {{.Env.RPCBindHost}} \
--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.caching.state-scheme path \
--execution.caching.state-history 0 \
--execution.tx-indexer.tx-lookup-limit 0 \
--validation.wasm.allowed-wasm-module-roots "$INSTALL_DIR/target/machines"

{{end}}
47 changes: 47 additions & 0 deletions build/templates/backend/scripts/robinhood_testnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

{{define "main" -}}

set -e

INSTALL_DIR={{.Env.BackendInstallPath}}/{{.Coin.Alias}}
DATA_DIR={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend

NITRO_BIN=$INSTALL_DIR/nitro

# Chain info taken verbatim from the official node config published at
# https://cdn.robinhood.com/assets/generated_assets/hoodchain_docsite/chain-node-configs/robinhood-chain-testnet-config.json
# (parent chain is Ethereum Sepolia).
CHAIN_INFO='[{"chain-id":46630,"parent-chain-id":11155111,"parent-chain-is-arbitrum":false,"chain-name":"Robinhood Chain Sepolia","chain-config":{"chainId":46630,"homesteadBlock":0,"daoForkBlock":null,"daoForkSupport":true,"eip150Block":0,"eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000","eip155Block":0,"eip158Block":0,"byzantiumBlock":0,"constantinopleBlock":0,"petersburgBlock":0,"istanbulBlock":0,"muirGlacierBlock":0,"berlinBlock":0,"londonBlock":0,"clique":{"period":0,"epoch":0},"arbitrum":{"EnableArbOS":true,"AllowDebugPrecompiles":false,"DataAvailabilityCommittee":false,"InitialArbOSVersion":51,"InitialChainOwner":"0x7131b1c28Df46d845Ee044f2f79AC19Ba14526a8","GenesisBlockNum":0,"MaxCodeSize":98304,"MaxInitCodeSize":196608}},"rollup":{"bridge":"0x96295BDad104eaD97cC08797b3dC68efF59CcF30","inbox":"0xF2939afA86F6f933A3CE17fCAB007907B6b0B7a4","sequencer-inbox":"0xA0D9dB3DC9791D54b5183C1C1866eFe1eCA7D414","rollup":"0xdc5F8E399DBd8a9F5F87AeC4C23Beb12431b386D","validator-utils":"0x0000000000000000000000000000000000000000","validator-wallet-creator":"0xB7FE37712e46F28C8f22Ec4bAA33A09fb8B52BD0","stake-token":"0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9","deployed-at":10204516}}]'

# Robinhood does not publish a testnet genesis file; the testnet genesis state is
# empty (verified: mainnet-preallocated contracts have no code at testnet block 0),
# so a fresh database is initialized with --init.empty.
# Bind RPC endpoints based on BB_RPC_BIND_HOST_* so defaults remain local unless explicitly overridden.
$NITRO_BIN \
--chain.id 46630 \
--chain.info-json "$CHAIN_INFO" \
--init.empty \
--init.download-path $DATA_DIR/tmp \
--auth.jwtsecret $DATA_DIR/jwtsecret \
--persistent.chain $DATA_DIR \
--parent-chain.connection.url http://127.0.0.1:18176 \
--parent-chain.blob-client.beacon-url http://127.0.0.1:17576 \
--node.feed.input.url wss://feed.testnet.chain.robinhood.com \
--execution.forwarding-target https://sequencer.testnet.chain.robinhood.com \
--http.addr {{.Env.RPCBindHost}} \
--http.port {{.Ports.BackendHttp}} \
--http.api eth,net,web3,debug,txpool,arb \
--http.vhosts '*' \
--http.corsdomain '*' \
--ws.addr {{.Env.RPCBindHost}} \
--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-indexer.tx-lookup-limit 0 \
--validation.wasm.allowed-wasm-module-roots "$INSTALL_DIR/target/machines"

{{end}}
2 changes: 1 addition & 1 deletion configs/coins/ethereum_archive_consensus.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"verification_source": "6efcd238124e000783f55a4430f0962b324a32599cf33219415f7f6dece8363f",
"extract_command": "mv ${ARCHIVE} backend/beacon-chain && chmod +x backend/beacon-chain && echo",
"exclude_files": [],
"exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/beacon-chain --mainnet --accept-terms-of-use --execution-endpoint=http://localhost:{{.Ports.BackendAuthRpc}} --grpc-gateway-port=7516 --rpc-port=7517 --monitoring-port=7518 --p2p-tcp-port=3516 --p2p-udp-port=2516 --datadir={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend --jwt-secret={{.Env.BackendDataPath}}/ethereum_archive/backend/erigon/jwt.hex 2>>{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'",
"exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/beacon-chain --mainnet --accept-terms-of-use --semi-supernode --execution-endpoint=http://localhost:{{.Ports.BackendAuthRpc}} --grpc-gateway-port=7516 --rpc-port=7517 --monitoring-port=7518 --p2p-tcp-port=3516 --p2p-udp-port=2516 --datadir={{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend --jwt-secret={{.Env.BackendDataPath}}/ethereum_archive/backend/erigon/jwt.hex 2>>{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'",
"logrotate_files_template": "{{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log",
"postinst_script_template": "",
"service_type": "simple",
Expand Down
79 changes: 79 additions & 0 deletions configs/coins/robinhood_archive.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"coin": {
"name": "Robinhood Archive",
"shortcut": "ETH",
"network": "RHC",
"label": "Robinhood Chain",
"alias": "robinhood_archive"
},
"ports": {
"backend_rpc": 8213,
"backend_p2p": 38413,
"backend_http": 8313,
"blockbook_internal": 9213,
"blockbook_public": 9313
},
"ipc": {
"rpc_url_template": "http://127.0.0.1:{{.Ports.BackendHttp}}",
"rpc_url_ws_template": "ws://127.0.0.1:{{.Ports.BackendRPC}}",
"rpc_timeout": 25
},
"backend": {
"package_name": "backend-robinhood-archive",
"package_revision": "satoshilabs-1",
"system_user": "robinhood",
"version": "3.11.2",
"docker_image": "offchainlabs/nitro-node:v3.11.2-3599aca",
"verification_type": "docker",
"verification_source": "ebc985e3b105980734630744981e1542001c22d74cba57509fe0d5ed8bb84c14",
"extract_command": "docker cp extract:/home/user/target backend/target; docker cp extract:/usr/local/bin/nitro backend/nitro",
"exclude_files": [],
"exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/robinhood_archive_exec.sh 2>> {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'",
"exec_script": "robinhood_archive.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": "robinhood_genesis.json",
"client_config_file": ""
},
"blockbook": {
"package_name": "blockbook-robinhood-archive",
"system_user": "blockbook-robinhood",
"internal_binding_template": ":{{.Ports.BlockbookInternal}}",
"public_binding_template": ":{{.Ports.BlockbookPublic}}",
"explorer_url": "",
"additional_params": "-workers=16 -resyncindexdebounce=509",
"block_chain": {
"parse": true,
"mempool_workers": 8,
"mempool_sub_workers": 2,
"block_addresses_to_keep": 4500,
"additional_params": {
"averageBlockTimeMs": 100,
"missingBlockRetry": {
"retryDelayMs": 1000,
"recheckThreshold": 10,
"tipRecheckThreshold": 3,
"maxStallMs": 60000
},
"eip1559Fees": true,
"mempoolTxTimeoutHours": 12,
"processInternalTransactions": true,
"trace_timeout": "10s",
"queryBackendOnMempoolResync": false,
"disableMempoolSync": true,
"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": "{\"coin\": \"ethereum\",\"platformIdentifier\": \"robinhood\",\"platformVsCurrency\": \"usd\",\"periodSeconds\": 900}",
"fourByteSignatures": "https://www.4byte.directory/api/v1/signatures/"
}
}
},
"meta": {
"package_maintainer": "IT",
"package_maintainer_email": "it@satoshilabs.com"
}
}
76 changes: 76 additions & 0 deletions configs/coins/robinhood_testnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"coin": {
"name": "Robinhood Testnet",
"shortcut": "tETH",
"network": "tRHC",
"label": "Robinhood Chain Testnet",
"alias": "robinhood_testnet"
},
"ports": {
"backend_rpc": 18077,
"backend_p2p": 48377,
"backend_http": 18177,
"blockbook_internal": 19077,
"blockbook_public": 19177
},
"ipc": {
"rpc_url_template": "http://127.0.0.1:{{.Ports.BackendRPC}}",
"rpc_url_ws_template": "ws://127.0.0.1:{{.Ports.BackendRPC}}",
"rpc_timeout": 25
},
"backend": {
"package_name": "backend-robinhood-testnet",
"package_revision": "satoshilabs-1",
"system_user": "robinhood",
"version": "3.11.2",
"docker_image": "offchainlabs/nitro-node:v3.11.2-3599aca",
"verification_type": "docker",
"verification_source": "ebc985e3b105980734630744981e1542001c22d74cba57509fe0d5ed8bb84c14",
"extract_command": "docker cp extract:/home/user/target backend/target; docker cp extract:/usr/local/bin/nitro backend/nitro",
"exclude_files": [],
"exec_command_template": "/bin/sh -c '{{.Env.BackendInstallPath}}/{{.Coin.Alias}}/robinhood_testnet_exec.sh 2>> {{.Env.BackendDataPath}}/{{.Coin.Alias}}/backend/{{.Coin.Alias}}.log'",
"exec_script": "robinhood_testnet.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": false,
"server_config_file": "",
"client_config_file": ""
},
"blockbook": {
"package_name": "blockbook-robinhood-testnet",
"system_user": "blockbook-robinhood",
"internal_binding_template": ":{{.Ports.BlockbookInternal}}",
"public_binding_template": ":{{.Ports.BlockbookPublic}}",
"explorer_url": "",
"additional_params": "-workers=16 -resyncindexdebounce=509",
"block_chain": {
"parse": true,
"mempool_workers": 8,
"mempool_sub_workers": 2,
"block_addresses_to_keep": 1800,
"additional_params": {
"averageBlockTimeMs": 250,
"missingBlockRetry": {
"retryDelayMs": 1000,
"recheckThreshold": 10,
"tipRecheckThreshold": 3,
"maxStallMs": 60000
},
"eip1559Fees": true,
"mempoolTxTimeoutHours": 12,
"processInternalTransactions": true,
"trace_timeout": "10s",
"queryBackendOnMempoolResync": false,
"disableMempoolSync": true,
"fourByteSignatures": "https://www.4byte.directory/api/v1/signatures/"
}
}
},
"meta": {
"package_maintainer": "IT",
"package_maintainer_email": "it@satoshilabs.com"
}
}
Loading
Loading