Add an option to run LES on Ropsten as an experimental feature.

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
Igor Mandrigin 2018-09-26 12:06:07 +02:00
parent 1c9a3e38b3
commit 851a3db9ee
No known key found for this signature in database
GPG Key ID: 4A0EDDE26E66BC8B
8 changed files with 104 additions and 8 deletions

2
.env
View File

@ -1,6 +1,6 @@
TESTFAIRY_ENABLED=0
ETHEREUM_DEV_CLUSTER=1
RPC_NETWORKS_ONLY=1
RPC_NETWORKS_ONLY=0
LOG_LEVEL=debug
LOG_LEVEL_STATUS_GO=info
FLEET=eth.beta

View File

@ -1,4 +1,5 @@
TESTFAIRY_ENABLED=1
RPC_NETWORKS_ONLY=0
ETHEREUM_DEV_CLUSTER=1
LOG_LEVEL=debug
LOG_LEVEL_STATUS_GO=info

View File

@ -0,0 +1,49 @@
{
"fleets": {
"les.dev.ropsten": {
"boot": {
"node-01.do-ams3.les-rops.misc": "enode://a6ccec097ec4a82ff6e9fd9d0fbc51bf93b0ee963ff2878a667b5f58dfbc53d918c87c8b08a6fe02a016dcef5181eef1fe6bfaf955e23cfbdf1d6222666ab82e@104.248.199.52:30303",
"node-02.do-ams3.les-rops.misc": "enode://696cdb3532189d8d7333383c9b019a1f81570852a7cf61bbb90c38e09aefb4f06930babdaa65d4f1fc351f6cd8b07c3301f934b3da6116b7f2fcd14119228fd9@104.248.199.213:30303",
"node-03.do-ams3.les-rops.misc": "enode://710831f965fdc8c6a6d8dc04e40e4b75690babafd9cf60d1a7706726716d03df713200d8da788384fdf28461072517c87977c7daf5709751f78cbc74db9d1638@104.248.199.160:30303"
},
"mail": {
"mail-01.ac-cn-hongkong-c.eth.beta": "enode://da61e9eff86a56633b635f887d8b91e0ff5236bbc05b8169834292e92afb92929dcf6efdbf373a37903da8fe0384d5a0a8247e83f1ce211aa429200b6d28c548@47.91.156.93:30504",
"mail-01.do-ams3.eth.beta": "enode://c42f368a23fa98ee546fd247220759062323249ef657d26d357a777443aec04db1b29a3a22ef3e7c548e18493ddaf51a31b0aed6079bd6ebe5ae838fcfaf3a49@206.189.243.162:30504",
"mail-01.gc-us-central1-a.eth.beta": "enode://7de99e4cb1b3523bd26ca212369540646607c721ad4f3e5c821ed9148150ce6ce2e72631723002210fac1fd52dfa8bbdf3555e05379af79515e1179da37cc3db@35.188.19.210:30504",
"mail-02.ac-cn-hongkong-c.eth.beta": "enode://744098ab6d3308af5cd03920aea60c46d16b2cd3d33bf367cbaf1d01c2fcd066ff8878576d0967897cd7dbb0e63f873cc0b4f7e4b0f1d7222e6b3451a78d9bda@47.89.20.15:30504",
"mail-02.do-ams3.eth.beta": "enode://7aa648d6e855950b2e3d3bf220c496e0cae4adfddef3e1e6062e6b177aec93bc6cdcf1282cb40d1656932ebfdd565729da440368d7c4da7dbd4d004b1ac02bf8@206.189.243.169:30504",
"mail-02.gc-us-central1-a.eth.beta": "enode://015e22f6cd2b44c8a51bd7a23555e271e0759c7d7f52432719665a74966f2da456d28e154e836bee6092b4d686fe67e331655586c57b718be3997c1629d24167@35.226.21.19:30504",
"mail-03.ac-cn-hongkong-c.eth.beta": "enode://74957e361ab290e6af45a124536bc9adee39fbd2f995a77ace6ed7d05d9a1c7c98b78b2df5f8071c439b9c0afe4a69893ede4ad633473f96bc195ddf33f6ce00@47.52.255.195:30504",
"mail-03.do-ams3.eth.beta": "enode://8a64b3c349a2e0ef4a32ea49609ed6eb3364be1110253c20adc17a3cebbc39a219e5d3e13b151c0eee5d8e0f9a8ba2cd026014e67b41a4ab7d1d5dd67ca27427@206.189.243.168:30504",
"mail-03.gc-us-central1-a.eth.beta": "enode://531e252ec966b7e83f5538c19bf1cde7381cc7949026a6e499b6e998e695751aadf26d4c98d5a4eabfb7cefd31c3c88d600a775f14ed5781520a88ecd25da3c6@35.225.227.79:30504"
},
"whisper": {
"node-01.ac-cn-hongkong-c.eth.beta": "enode://9c2b82304d988cd78bf290a09b6f81c6ae89e71f9c0f69c41d21bd5cabbd1019522d5d73d7771ea933adf0727de5e847c89e751bd807ba1f7f6fc3a0cd88d997@47.52.91.239:30305",
"node-01.do-ams3.eth.beta": "enode://66ba15600cda86009689354c3a77bdf1a97f4f4fb3ab50ffe34dbc904fac561040496828397be18d9744c75881ffc6ac53729ddbd2cdbdadc5f45c400e2622f7@206.189.243.176:30305",
"node-01.gc-us-central1-a.eth.beta": "enode://0440117a5bc67c2908fad94ba29c7b7f2c1536e96a9df950f3265a9566bf3a7306ea8ab5a1f9794a0a641dcb1e4951ce7c093c61c0d255f4ed5d2ed02c8fce23@35.224.15.65:30305",
"node-02.ac-cn-hongkong-c.eth.beta": "enode://a80eb084f6bf3f98bf6a492fd6ba3db636986b17643695f67f543115d93d69920fb72e349e0c617a01544764f09375bb85f452b9c750a892d01d0e627d9c251e@47.89.16.125:30305",
"node-02.do-ams3.eth.beta": "enode://4ea35352702027984a13274f241a56a47854a7fd4b3ba674a596cff917d3c825506431cf149f9f2312a293bb7c2b1cca55db742027090916d01529fe0729643b@206.189.243.178:30305",
"node-02.gc-us-central1-a.eth.beta": "enode://552942cc4858073102a6bcd0df9fe4de6d9fc52ddf7363e8e0746eba21b0f98fb37e8270bc629f72cfe29e0b3522afaf51e309a05998736e2c0dad5288991148@130.211.215.133:30305",
"node-03.ac-cn-hongkong-c.eth.beta": "enode://aa97756bc147d74be6d07adfc465266e17756339d3d18591f4be9d1b2e80b86baf314aed79adbe8142bcb42bc7bc40e83ee3bbd0b82548e595bf855d548906a1@47.52.188.241:30305",
"node-03.do-ams3.eth.beta": "enode://ce559a37a9c344d7109bd4907802dd690008381d51f658c43056ec36ac043338bd92f1ac6043e645b64953b06f27202d679756a9c7cf62fdefa01b2e6ac5098e@206.189.243.179:30305",
"node-03.gc-us-central1-a.eth.beta": "enode://b33dc678589931713a085d29f9dc0efee1783dacce1d13696eb5d3a546293198470d97822c40b187336062b39fd3464e9807858109752767d486ea699a6ab3de@35.193.151.184:30305",
"node-04.ac-cn-hongkong-c.eth.beta": "enode://f34451823b173dc5f2ac0eec1668fdb13dba9452b174249a7e0272d6dce16fb811a01e623300d1b7a67c240ae052a462bff3f60e4a05e4c4bd23cc27dea57051@47.52.173.66:30305",
"node-04.do-ams3.eth.beta": "enode://4e0a8db9b73403c9339a2077e911851750fc955db1fc1e09f81a4a56725946884dd5e4d11258eac961f9078a393c45bcab78dd0e3bc74e37ce773b3471d2e29c@206.189.243.171:30305",
"node-04.gc-us-central1-a.eth.beta": "enode://eb4cc33c1948b1f4b9cb8157757645d78acd731cc8f9468ad91cef8a7023e9c9c62b91ddab107043aabc483742ac15cb4372107b23962d3bfa617b05583f2260@146.148.66.209:30305",
"node-05.ac-cn-hongkong-c.eth.beta": "enode://7c80e37f324bbc767d890e6381854ef9985d33940285413311e8b5927bf47702afa40cd5d34be9aa6183ac467009b9545e24b0d0bc54ef2b773547bb8c274192@47.91.155.62:30305",
"node-05.do-ams3.eth.beta": "enode://a8bddfa24e1e92a82609b390766faa56cf7a5eef85b22a2b51e79b333c8aaeec84f7b4267e432edd1cf45b63a3ad0fc7d6c3a16f046aa6bc07ebe50e80b63b8c@206.189.243.172:30305",
"node-05.gc-us-central1-a.eth.beta": "enode://c7e00e5a333527c009a9b8f75659d9e40af8d8d896ebaa5dbdd46f2c58fc010e4583813bc7fc6da98fcf4f9ca7687d37ced8390330ef570d30b5793692875083@35.192.123.253:30305",
"node-06.ac-cn-hongkong-c.eth.beta": "enode://4b2530d045b1d9e0e45afa7c008292744fe77675462090b4001f85faf03b87aa79259c8a3d6d64f815520ac76944e795cbf32ff9e2ce9ba38f57af00d1cc0568@47.90.29.122:30305",
"node-06.do-ams3.eth.beta": "enode://887cbd92d95afc2c5f1e227356314a53d3d18855880ac0509e0c0870362aee03939d4074e6ad31365915af41d34320b5094bfcc12a67c381788cd7298d06c875@206.189.243.177:30305",
"node-06.gc-us-central1-a.eth.beta": "enode://2af8f4f7a0b5aabaf49eb72b9b59474b1b4a576f99a869e00f8455928fa242725864c86bdff95638a8b17657040b21771a7588d18b0f351377875f5b46426594@35.232.187.4:30305",
"node-07.ac-cn-hongkong-c.eth.beta": "enode://76ee16566fb45ca7644c8dec7ac74cadba3bfa0b92c566ad07bcb73298b0ffe1315fd787e1f829e90dba5cd3f4e0916e069f14e50e9cbec148bead397ac8122d@47.91.226.75:30305",
"node-07.do-ams3.eth.beta": "enode://2b01955d7e11e29dce07343b456e4e96c081760022d1652b1c4b641eaf320e3747871870fa682e9e9cfb85b819ce94ed2fee1ac458904d54fd0b97d33ba2c4a4@206.189.240.70:30305",
"node-07.gc-us-central1-a.eth.beta": "enode://19872f94b1e776da3a13e25afa71b47dfa99e658afd6427ea8d6e03c22a99f13590205a8826443e95a37eee1d815fc433af7a8ca9a8d0df7943d1f55684045b7@35.238.60.236:30305"
}
}
},
"meta": {
"hostname": "bots-01.gc-us-central1-a.eth.test",
"timestamp": "2018-09-03T18:10:52.315172"
}
}

View File

@ -69,9 +69,14 @@
:URL "https://rinkeby.infura.io/z6GCTmjdP3FETEJmMBI4"}}}})
(defn network-enabled? [network]
(if config/rpc-networks-only?
(get-in (val network) [:config :UpstreamConfig :Enabled])
true))
(let [rpc-network? (get-in (val network) [:config :UpstreamConfig :Enabled])
ropsten? (= (ethereum/chain-keyword->chain-id :testnet)
(get-in (val network) [:config :NetworkId]))]
(if rpc-network?
true
(if config/rpc-networks-only?
false
ropsten?)))) ;; limit LES networks to Ropsten for now.
(def default-networks
(into {} (filter network-enabled?

View File

@ -337,6 +337,11 @@
(fn [cofx [_ network]]
(network/delete cofx {:network network})))
(handlers/register-handler-fx
:network.ui/network-entry-pressed
(fn [cofx [_ network]]
(network/open-network-details cofx network)))
(handlers/register-handler-fx
:network/connection-status-changed
(fn [{db :db :as cofx} [_ is-connected?]]

View File

@ -17,8 +17,16 @@
(get-in db [:account/account :settings :fleet]))
config/fleet))))
(def fleets-with-les
[:les.dev.ropsten :les.dev.mainnet])
(defn fleet-supports-les? [fleet]
(not (nil? (some #(= fleet %) fleets-with-les))))
(def fleets
(:fleets (types/json->clj (slurp "resources/config/fleets.json"))))
(reduce merge (map #(:fleets (types/json->clj %))
[(slurp "resources/config/fleets.json")
(slurp "resources/config/fleets-les.json")])))
(defn format-wnode
[wnode address]

View File

@ -7,6 +7,8 @@
[status-im.network.net-info :as net-info]
[status-im.transport.inbox :as inbox]
[status-im.utils.ethereum.core :as ethereum]
[status-im.ui.screens.navigation :as navigation]
[status-im.fleet.core :as fleet-core]
[status-im.utils.fx :as fx]))
(def url-regex
@ -157,6 +159,31 @@
{:db (assoc db :network-status (if is-connected? :online :offline))}
(inbox/request-messages)))
(defn- navigate-to-network-details
[cofx network show-warning?]
(fx/merge cofx
(when show-warning?
{:utils/show-popup {:title "LES support is experimental!"
:content "Use at your own risk!"}})
(navigation/navigate-to-cofx :network-details {:networks/selected-network network})))
(defn- not-supported-warning [fleet]
(str (name fleet) " does not support LES!\n"
"Please, select one of the supported fleets:"
(map name fleet-core/fleets-with-les)))
(fx/defn open-network-details
[cofx network]
(let [db (:db cofx)
rpc-network? (get-in network [:config :UpstreamConfig :Enabled] false)
fleet (fleet-core/current-fleet db nil)
fleet-supports-les? (fleet-core/fleet-supports-les? fleet)]
(if (or rpc-network? fleet-supports-les?)
(navigate-to-network-details cofx network (not rpc-network?))
;; Otherwise, we show an explanation dialog to a user if the current fleet does not suport LES
{:utils/show-popup {:title "LES not supported"
:content (not-supported-warning fleet)}})))
(fx/defn handle-network-status-change
[cofx data]
{:network/notify-status-go data})

View File

@ -30,17 +30,18 @@
#{"mainnet" "mainnet_rpc"})
(defn navigate-to-network [network]
(re-frame/dispatch [:navigate-to :network-details {:networks/selected-network network}]))
(re-frame/dispatch [:network.ui/network-entry-pressed network]))
(defn render-network [current-network]
(fn [{:keys [id name] :as network}]
(let [connected? (= id current-network)]
(let [connected? (= id current-network)
rpc? (get-in network [:config :UpstreamConfig :Enabled] false)]
[list/touchable-item #(navigate-to-network network)
[react/view styles/network-item
[network-icon connected? 40]
[react/view {:padding-horizontal 16}
[react/text {:style styles/network-item-name-text}
name]
(if rpc? name (str name " " "(LES)"))]
(when connected?
[react/text {:style styles/network-item-connected-text
:accessibility-label :connected-text}