Skip to content

Commit

Permalink
drop les
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
  • Loading branch information
flexsurfer committed Oct 15, 2019
1 parent 2ddfcd4 commit da4d95d
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 255 deletions.
54 changes: 0 additions & 54 deletions resources/config/fleets-les.json

This file was deleted.

48 changes: 5 additions & 43 deletions src/status_im/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
#{content-type-text content-type-emoji content-type-status})

(def min-password-length 6)
(def max-chat-name-length 20)
(def max-group-chat-participants 10)
(def response-suggesstion-resize-duration 100)
(def default-number-of-messages 20)
(def blocks-per-hour 120)
(def one-earth-day 86400)
Expand All @@ -34,12 +32,7 @@
(def system "system")

(def mainnet-networks
{"mainnet" {:id "mainnet",
:name "Mainnet",
:config {:NetworkId (ethereum/chain-keyword->chain-id :mainnet)
:DataDir "/ethereum/mainnet"
:LightEthConfig {:Enabled true}}}
"mainnet_rpc" {:id "mainnet_rpc",
{"mainnet_rpc" {:id "mainnet_rpc",
:name "Mainnet with upstream RPC",
:config {:NetworkId (ethereum/chain-keyword->chain-id :mainnet)
:DataDir "/ethereum/mainnet_rpc"
Expand All @@ -61,63 +54,32 @@
:URL "https://core.poa.network"}}}})

(def testnet-networks
{"testnet" {:id "testnet",
:name "Ropsten",
:config {:NetworkId (ethereum/chain-keyword->chain-id :testnet)
:DataDir "/ethereum/testnet"
:LightEthConfig {:Enabled true}}}
"testnet_ulc" {:id "testnet_ulc",
:name "Ropsten ULC",
:config {:NetworkId (ethereum/chain-keyword->chain-id :testnet)
:DataDir "/ethereum/testnet_ulc"
:LightEthConfig {:Enabled true :ULC true}}}
"testnet_rpc" {:id "testnet_rpc",
{"testnet_rpc" {:id "testnet_rpc",
:name "Ropsten with upstream RPC",
:config {:NetworkId (ethereum/chain-keyword->chain-id :testnet)
:DataDir "/ethereum/testnet_rpc"
:UpstreamConfig {:Enabled true
:URL "https://ropsten.infura.io/v3/f315575765b14720b32382a61a89341a"}}}
"rinkeby" {:id "rinkeby",
:name "Rinkeby",
:config {:NetworkId (ethereum/chain-keyword->chain-id :rinkeby)
:DataDir "/ethereum/rinkeby"
:LightEthConfig {:Enabled true}}}
"rinkeby_rpc" {:id "rinkeby_rpc",
:name "Rinkeby with upstream RPC",
:config {:NetworkId (ethereum/chain-keyword->chain-id :rinkeby)
:DataDir "/ethereum/rinkeby_rpc"
:UpstreamConfig {:Enabled true
:URL "https://rinkeby.infura.io/v3/f315575765b14720b32382a61a89341a"}}}
"goerli" {:id "goerli",
:name "Goerli",
:config {:NetworkId (ethereum/chain-keyword->chain-id :goerli)
:DataDir "/ethereum/goerli"
:LightEthConfig {:Enabled true}}}
"goerli_rpc" {:id "goerli_rpc",
:name "Goerli with upstream RPC",
:config {:NetworkId (ethereum/chain-keyword->chain-id :goerli)
:DataDir "/ethereum/goerli_rpc"
:UpstreamConfig {:Enabled true
:URL "https://goerli.blockscout.com/"}}}})

(defn network-enabled? [network]
(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?
(merge testnet-networks mainnet-networks sidechain-networks))))
(merge testnet-networks mainnet-networks sidechain-networks))

(def default-multiaccount-settings
{:web3-opt-in? true
{:web3-opt-in? true
:preview-privacy? false
:wallet {:visible-tokens {}}})
:wallet {:visible-tokens {}}})

(def currencies
{:aed {:id :aed :code "AED" :display-name (i18n/label :t/currency-display-name-aed) :symbol "د.إ"}
Expand Down
7 changes: 0 additions & 7 deletions src/status_im/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@
(fn [cofx _]
(init/start-app cofx)))

;; home screen

(handlers/register-handler-fx
:home.ui/sync-info-pressed
(fn [cofx _]
(node/display-les-debug-info cofx)))

;; multiaccounts module
(handlers/register-handler-fx
:multiaccounts.update.callback/published
Expand Down
10 changes: 1 addition & 9 deletions src/status_im/fleet/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,10 @@
(keyword (or (get 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 default-fleets (slurp "resources/config/fleets.json"))
(def default-les-fleets (slurp "resources/config/fleets-les.json"))

(defn fleets [{:keys [custom-fleets]}]
(as-> [(default-fleets)
(default-les-fleets)] $
(as-> [(default-fleets)] $
(mapv #(:fleets (types/json->clj %)) $)
(conj $ custom-fleets)
(reduce merge $)))
Expand Down
24 changes: 1 addition & 23 deletions src/status_im/network/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[re-frame.core :as re-frame]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.fleet.core :as fleet-core]
[status-im.i18n :as i18n]
[status-im.node.core :as node]
[status-im.ui.screens.navigation :as navigation]
Expand Down Expand Up @@ -190,28 +189,7 @@
{:ui/show-error "chain-id already defined"}))
{:ui/show-error "invalid network parameters"}))

(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
{:events [::network-entry-pressed]}
[cofx network]
(let [db (:db cofx)
rpc-network? (get-in network [:config :UpstreamConfig :Enabled] false)
fleet (fleet-core/current-fleet db)
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)}})))
(navigation/navigate-to-cofx cofx :network-details {:networks/selected-network network}))
13 changes: 4 additions & 9 deletions src/status_im/network/ui/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,14 @@
(def mainnet?
#{"mainnet" "mainnet_rpc"})

(defn navigate-to-network [network]
(re-frame/dispatch [::network/network-entry-pressed network]))

(defn render-network [current-network]
(fn [{:keys [id name] :as network}]
(let [connected? (= id current-network)
rpc? (get-in network [:config :UpstreamConfig :Enabled] false)]
[list/touchable-item #(navigate-to-network network)
(let [connected? (= id current-network)]
[list/touchable-item #(re-frame/dispatch [::network/network-entry-pressed network])
[react/view styles/network-item
[network-icon connected? 40]
[react/view {:padding-horizontal 16}
[react/text {:style styles/network-item-name-text}
(if rpc? name (str name " " "(LES)"))]
[react/text {:style styles/network-item-name-text} name]
(when connected?
[react/text {:style styles/network-item-connected-text
:accessibility-label :connected-text}
Expand Down Expand Up @@ -69,4 +64,4 @@
:data (:custom networks)}]
:key-fn :id
:default-separator? true
:render-fn (render-network current-network)}]]]))
:render-fn (render-network current-network)}]]]))
60 changes: 2 additions & 58 deletions src/status_im/node/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
[status-im.utils.config :as config]
[status-im.utils.fx :as fx]
[status-im.utils.platform :as utils.platform]
[status-im.utils.types :as types]
[status-im.utils.utils :as utils]))
[status-im.utils.types :as types]))

(defn- add-custom-bootnodes [config network all-bootnodes]
(let [bootnodes (as-> all-bootnodes $
Expand Down Expand Up @@ -75,16 +74,6 @@
(if utils.platform/desktop? ""
config/log-level-status-go)))

(defn- ulc-network? [config]
(get-in config [:LightEthConfig :ULC] false))

(defn- add-ulc-trusted-nodes [config trusted-nodes]
(if (ulc-network? config)
(-> config
(assoc-in [:LightEthConfig :TrustedNodes] trusted-nodes)
(assoc-in [:LightEthConfig :MinTrustedFraction] 50))
config))

(defn- get-multiaccount-node-config
[{:keys [multiaccount :networks/networks :networks/current-network]
:or {current-network config/default-network
Expand Down Expand Up @@ -139,31 +128,9 @@
use-custom-bootnodes)
(add-custom-bootnodes current-network bootnodes)

:always
(add-ulc-trusted-nodes (vals (:static current-fleet)))

:always
(add-log-level log-level))))

(defn get-verify-multiaccount-config
"Is used when the node has to be started before
`VerifyAccountPassword` call."
[db network]
(-> (get-in (:networks/networks db) [network :config])
(get-base-node-config)

(assoc :ShhextConfig {:BackupDisabledDataDir (utils.platform/no-backup-directory)})
(assoc :PFSEnabled false
:NoDiscovery true)
(add-log-level config/log-level-status-go)))

(fx/defn update-sync-state
[{:keys [db]} error sync-state]
{:db (assoc db :node/chain-sync-state
(if error
{:error error}
(when sync-state (js->clj sync-state :keywordize-keys true))))})

(defn get-new-config
[db]
(types/clj->json (get-multiaccount-node-config db)))
Expand All @@ -188,27 +155,4 @@
(re-frame/reg-fx
::prepare-new-config
(fn [[config callback]]
(status/prepare-dir-and-update-config config callback)))

(re-frame/reg-fx
:node/les-show-debug-info
(fn [[multiaccount]]
#_(.getBalance
(.-eth eb3)
(:address multiaccount)
(fn [error-balance balance]
(.getBlockNumber
(.-eth eb3)
(fn
[error-block block]
(utils/show-popup
"LES sync status"
(str
"* multiaccount=" (:address multiaccount) "\n"
"* latest block=" (or error-block block) "\n"
"* balance=" (or error-balance balance) "\n"
"* eth_getSyncing=" (or chain-sync-state "false")))))))))

(defn display-les-debug-info
[{{:keys [multiaccount]} :db}]
{:node/les-show-debug-info [multiaccount]})
(status/prepare-dir-and-update-config config callback)))
Loading

0 comments on commit da4d95d

Please sign in to comment.