geth, jail: embed static resources, closes #131
This commit is contained in:
parent
1b31a5ca86
commit
21344af199
3
Makefile
3
Makefile
|
@ -52,6 +52,9 @@ ci:
|
|||
build/env.sh go test -v -cover ./geth/jail
|
||||
build/env.sh go test -v -cover ./extkeys
|
||||
|
||||
generate:
|
||||
build/env.sh go generate ./static
|
||||
|
||||
test:
|
||||
@build/env.sh echo "mode: set" > coverage-all.out
|
||||
build/env.sh go test -coverprofile=coverage.out -covermode=set ./geth
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#cloud-config
|
||||
|
||||
coreos:
|
||||
etcd2:
|
||||
# generate a new token for each unique cluster from https://discovery.etcd.io/new:
|
||||
discovery: https://discovery.etcd.io/d2df3f02e6129624ad96f1bdb4a5ba05
|
||||
# multi-region deployments, multi-cloud deployments, and Droplets without
|
||||
# private networking need to use $public_ipv4:
|
||||
advertise-client-urls: http://$private_ipv4:2379,http://$private_ipv4:4001
|
||||
initial-advertise-peer-urls: http://$private_ipv4:2380
|
||||
# listen on the official ports 2379, 2380 and one legacy port 4001:
|
||||
listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
|
||||
listen-peer-urls: http://$private_ipv4:2380
|
||||
fleet:
|
||||
public-ip: $private_ipv4 # used for fleetctl ssh command
|
||||
metadata: "region=sgp,size=2048"
|
||||
units:
|
||||
- name: etcd2.service
|
||||
command: start
|
||||
- name: fleet.service
|
||||
command: start
|
|
@ -1,19 +0,0 @@
|
|||
[Unit]
|
||||
Description=GetNode
|
||||
After=docker.service
|
||||
Requires=docker.service
|
||||
|
||||
[Service]
|
||||
TimeoutStartSec=0
|
||||
ExecStartPre=-/usr/bin/docker kill geth
|
||||
ExecStartPre=-/usr/bin/docker rm geth
|
||||
ExecStartPre=/usr/bin/docker pull farazdagi/geth
|
||||
ExecStart=/usr/bin/docker run --name geth -v /home/core/data:/root/.ethereum -p 30303:30303 farazdagi/geth --lightkdf --shh
|
||||
ExecStop=/usr/bin/docker stop geth
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[X-Fleet]
|
||||
Global=true
|
||||
MachineMetadata=size=2048
|
|
@ -1 +0,0 @@
|
|||
{"address":"89b50b2b26947ccad43accaef76c21d175ad85f4","crypto":{"cipher":"aes-128-ctr","ciphertext":"cc8f600a59f8c5ac3d6ab849722a6602f61de0adc5c9617a1cd014d3d9638a95","cipherparams":{"iv":"836bb6b5df64c29a84f95e7628510e71"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"4cc1f86eaa707ee37dc3b686712f09be49b7175a2046c63cfd1d7a3e7ebee8ab"},"mac":"164f2e53c67b5c85267b79e4fc8b2f9117a66b5e0546933403d85d52fffa1f52"},"id":"3ade037d-722b-467a-ad8e-2bcae28b9642","version":3,"whisperenabled":true}
|
|
@ -1,13 +0,0 @@
|
|||
[
|
||||
"enode://8e4440f36e97b12f320dd3312c6b21c78ba72afd36d4b3202cf363f3b82311dd2c2c883ffadf3374941486db82c45f975dff491f639da39f9e3eec4f142a4f53@139.59.147.137:30303",
|
||||
"enode://d29febbcd9ac8b163a2b5b080aa16497faec2cf115cdc57cea2e5a8055fecda702ebfe1b3118b88e24efd7a2e6ff865f5d088553ab69b1c88e3cd5344e069ff4@139.59.208.103:30303",
|
||||
"enode://1263b51754fc03be5800469078218318c43a07dfa53405794d12f77ee72a0ff49b48c86ebae501ef239d4a9253cc8dc6a889acdbb33176bc3e1bd4a499d4bc48@139.59.214.200:30303",
|
||||
"enode://47df3738d17e7d6d1ae059cf73ee3deade7436d7c33e2547d1524a6afd9735dd90dfe505e08ad26cd2d0473d0c62a34b3d317da92be3ac4ddb9faa8bd28dc660@139.59.209.169:30303",
|
||||
"enode://5f00ae7bc7191550e523069c87dbd0e1d7ac4771b98dc7663f55eed22d5fc9b0b108c7962694a1e7827a4747a10e1fe3706fb46ea5e26851b3f384bcfe5ca533@139.59.209.170:30303",
|
||||
|
||||
"enode://57a9b08555e0dee42b6cbe9b7817782703d4923a7214f6549ae799ec060c8205a4784c0e46c36ddee4ffbaeea31f8d8368860760753895157f224321202d7747@188.166.212.8:30303",
|
||||
"enode://a63de242582d75060d0b2300e70558fe2fbbba99a1e6a5cadbead6af0e651d86e4db69f171a75e9f67d6e434a73c89360693d354b46d8563a419821d257c14c0@188.166.212.238:30303",
|
||||
"enode://f98a1e0ee1507ed4b9e222bf0f1a995633ac8e36ea47e642e7f73a5f88422497e16b207bb399a64415a3472dd69ec0b2a0f9d58a7bc70542db34c8f2bb782c7a@188.166.220.39:30303",
|
||||
"enode://6337e9c29693525466fa240831d0e92e6b627111794cef3b4fb710f3c2bbb870767a39d50553491072f3b2459911b981d036237234f9cf6f8ee9a6ffe1a2b4f2@188.166.220.183:30303",
|
||||
"enode://9eb901eb9c96a5a56ac5d493d5cd9522edac067e9c7549608056f5ffdb5453e77848c445d07b9b806ab9880e7d595e62705f4dcf3e7fc2af64a0c33bde961031@188.166.210.253:30303"
|
||||
]
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/robertkrimen/otto"
|
||||
"github.com/status-im/status-go/geth"
|
||||
"github.com/status-im/status-go/static"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -37,6 +38,7 @@ type JailedRuntime struct {
|
|||
sem *semaphore.Semaphore
|
||||
}
|
||||
|
||||
var Web3_JS = static.MustAsset("scripts/web3.js")
|
||||
var jailInstance *Jail
|
||||
var once sync.Once
|
||||
|
||||
|
@ -95,7 +97,7 @@ func (jail *Jail) Parse(chatId string, js string) string {
|
|||
localStorage, _ := vm.Get("localStorage")
|
||||
localStorage.Object().Set("set", makeLocalStorageSetHandler(chatId))
|
||||
|
||||
jjs := Web3_JS + `
|
||||
jjs := string(Web3_JS) + `
|
||||
var Web3 = require('web3');
|
||||
var web3 = new Web3(jeth);
|
||||
var Bignumber = require("bignumber.js");
|
||||
|
|
15977
geth/jail/web3.go
15977
geth/jail/web3.go
File diff suppressed because it is too large
Load Diff
|
@ -10,6 +10,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -22,12 +23,12 @@ import (
|
|||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/logger/glog"
|
||||
"github.com/status-im/status-go/geth/params"
|
||||
"github.com/status-im/status-go/static"
|
||||
)
|
||||
|
||||
var (
|
||||
muPrepareTestNode sync.Mutex
|
||||
RootDir string
|
||||
DataDir string
|
||||
TestDataDir string
|
||||
)
|
||||
|
||||
|
@ -44,7 +45,6 @@ func init() {
|
|||
}
|
||||
|
||||
// setup auxiliary directories
|
||||
DataDir = filepath.Join(RootDir, "data")
|
||||
TestDataDir = filepath.Join(RootDir, ".ethereumtest")
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ type TestConfig struct {
|
|||
func LoadTestConfig() (*TestConfig, error) {
|
||||
var testConfig TestConfig
|
||||
|
||||
configData := LoadFromFile(filepath.Join(DataDir, "test-data.json"))
|
||||
configData := string(static.MustAsset("config/test-data.json"))
|
||||
if err := json.Unmarshal([]byte(configData), &testConfig); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ func PrepareTestNode() (err error) {
|
|||
importTestAccount := func(accountFile string) error {
|
||||
dst := filepath.Join(TestDataDir, "keystore", accountFile)
|
||||
if _, err := os.Stat(dst); os.IsNotExist(err) {
|
||||
err = CopyFile(dst, filepath.Join(RootDir, "data", accountFile))
|
||||
err = ioutil.WriteFile(dst, static.MustAsset("keys/"+accountFile), 0644)
|
||||
if err != nil {
|
||||
glog.V(logger.Warn).Infof("cannot copy test account PK: %v", err)
|
||||
return err
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,4 @@
|
|||
// Package static embeds static (JS, HTML) resources right into the binaries
|
||||
package static
|
||||
|
||||
//go:generate go-bindata -pkg static -o bindata.go scripts/ config/ keys/
|
Loading…
Reference in New Issue