EExcel 丞燕快速查詢2

EExcel 丞燕快速查詢2
EExcel 丞燕快速查詢2 https://sandk.ffbizs.com/

ethereum 交易 驗證

https://www.blocktempo.com/blockchain-technical-overview-structure-of-blockchain-ethereum/

3. 以私鑰簽署交易。
4. 廣播「加上簽名的交易封包」至鄰近的以太坊節點們。


https://ithelp.ithome.com.tw/m/articles/10215095

總而言之在區塊鏈接納這筆交易前,先試著用地址反推回原本的公鑰,再用公鑰解密當初這筆交易紀錄的簽章看看,如果公鑰解的開就可以代表是公鑰持有人本人所簽核的,這便是剛剛提到的"數位簽章"。
注意:這段比較像是一般加解密的方式,好像不是ethereum


https://ethereum.stackexchange.com/questions/13778/get-public-key-of-any-ethereum-account

ethereum 簽完的東西 可以 找出 public key
有public key 就可以知道是誰發出這個交易


https://zhuanlan.zhihu.com/p/30481292

签名完成了,我们如何验证某些签名后的数据是哪个账户签名的呢?在web3.js 发布1.0版本以前,验证签名只能通过智能合约的ecrecover函数来实现。新版的web3.js提供了web3.eth.accounts.recover函数用于验证签名。这里我们仍然使用传统的智能合约ecrecover方式。

ecrecover接收数据的哈希值以及r/s/v等参数作为输入,返回实施该签名的账户地址。因此我们只需要通过合约拿到实施签名的地址,和我们真正的地址进行对比,如果地址一致,就说明验证通过了。


這也是ethereum private key和address比較重要的原因了


https://learnblockchain.cn/books/geth/part3/sign-and-valid.html

linux .bashrc


# General Aliases
    alias apk='apk --progress'
    alias ll="ls -ltan"

    alias hosts='cat /etc/hosts'
    alias ..="cd .."
    alias ...="cd ../.."
    alias ....="cd ../../.."
    alias untar="tar xzvkf"
    alias mv="mv -nv"
    alias cp="cp -i"
    alias ip4="ip -4 addr"
    alias ip6="ip -6 addr"

    COL_YEL="\[\e[1;33m\]"
    COL_GRA="\[\e[0;37m\]"
    COL_WHI="\[\e[1;37m\]"
    COL_GRE="\[\e[1;32m\]"
    COL_RED="\[\e[1;31m\]"

    # Bash Prompt
    if test "$UID" -eq 0 ; then
        _COL_USER=$COL_RED
        _p=" #"
    else
        _COL_USER=$COL_GRE 
        _p=">"
    fi
    COLORIZED_PROMPT="${_COL_USER}\u${COL_WHI}@${COL_YEL}\h${COL_WHI}:\w${_p} \[\e[m\]"
    case $TERM in
        *term | rxvt | screen )
            PS1="${COLORIZED_PROMPT}\[\e]0;\u@\h:\w\007\]" ;;
        linux )
            PS1="${COLORIZED_PROMPT}" ;;
        * ) 
            PS1="\u@\h:\w${_p} " ;;
    esac

存股

https://www.youtube.com/watch?v=uqlUFvkyEUg

1. 折舊長 不能折舊短 代表長期經營
2. 能控制供應 多或少,像蘋果 有強大的控制供應能力,需求多不見得
3. 產品周期長

hyperledger leader peer endorsing peer committing peer

leader peer 是peer之間動態選舉選出的

endorsing peer 預設為每個peer都是,安裝chaincode後,實例化設定policy可以有變化

committing peer 預設為每個peer都是

https://medium.com/@kctheservant/transactions-in-hyperledger-fabric-50e068dda8a9
https://stackoverflow.com/questions/52893818/difference-between-endorsing-peer-and-committing-peer-in-hyperledger-fabric/52894994

kubernetes K3s Failed!

Failed reason: Node port range can't fixed!


K3s


##### install #####
curl -sfL https://get.k3s.io | sh -


##### login https://192.168.99.119:6443/ get username/password #####
more /etc/rancher/k3s/k3s.yaml


##### change node-port range #####
k3s server --kube-apiserver-arg --service-node-port-range=1-65535


##### install dashboard #####
k3s kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml --insecure-skip-tls-verify

k3s kubectl create secret generic kubernetes-dashboard-certs --from-file=certs -n kube-system

k3s kubectl apply -f dashboard-ClusterRoleBinding.yaml
k3s kubectl apply -f dashboard-adminuser.yaml
k3s kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

Find admin-user-token

https://192.168.99.119:30393/


##### kill all #####
k3s-killall.sh
k3s-uninstall.sh

##### start k3s service #####
service k3s status ## check k3s is stop
service k3s start

Replace uglifyjs-webpack-plugin with terser-webpack-plugin

https://github.com/vuejs/vue-cli/issues/2245

https://github.com/webpack-contrib/terser-webpack-plugin

https://stackoverflow.com/questions/57360588/how-to-use-terser-with-webpack

https://juejin.im/post/5cbc40ea6fb9a068b65e2aa6


npm install npm install terser-webpack-plugin

vue.config.js


const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
    chainWebpack: process.env.NODE_ENV === 'production'
    ? config => {
        config.module.rules.delete('eslint');
        config.optimization.minimizer([
            new TerserPlugin({
                terserOptions: {
                    parse: {
                      ecma: 8
                    },
                    compress: {
                      ecma       : 5,
                      warnings   : false,
                      comparisons: false,
                      inline     : 2
                    },
                    mangle: {
                      reserved: ["BigInteger","ECPair","Point"],
                      safari10: true
                    },
                    output: {
                      ecma      : 5,
                      comments  : false,
                      ascii_only: true
                    }
                },
                cache: true,
                parallel: true,
                sourceMap: false, // false 可以減少一半的js大小,sourceMap為除錯使用
            })
        ]);
    }
    : config => {
        config.module.rules.delete('eslint');
    },
    devServer: {
        host: '0.0.0.0',
        port: '80',
        //public: '0.0.0.0:80',  //無效
        disableHostCheck: true,
    }
}

[轉]Kubernetes 调整 nodePort 端口范围

https://qhh.me/2019/08/pod 文件定义在 /etc/kubernetes/manifests/kube-apiserver.yaml15/Kubernetes-%E8%B0%83%E6%95%B4-nodePort-%E7%AB%AF%E5%8F%A3%E8%8C%83%E5%9B%B4/

在 command 下添加 --service-node-port-range=1-65535 参数,修改后会自动生效,无需其他操作:



apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    component: kube-apiserver
    tier: control-plane
  name: kube-apiserver
  namespace: kube-system
spec:
  containers:
  - command:
    - kube-apiserver
    - --service-node-port-range=1-65535
    - --advertise-address=192.168.26.10
    - --allow-privileged=true
    - --authorization-mode=Node,RBAC
    - --client-ca-file=/etc/kubernetes/pki/ca.crt
    - --enable-admission-plugins=NodeRestriction
    - --enable-bootstrap-token-auth=true
    - --etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt
    - --etcd-certfile=/etc/kubernetes/pki/apiserver-etcd-client.crt
    - --etcd-keyfile=/etc/kubernetes/pki/apiserver-etcd-client.key
    - --etcd-servers=https://127.0.0.1:2379
    - --insecure-port=0
    - --kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt
    - --kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key
    - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
    - --proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt
    - --proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key
    - --requestheader-allowed-names=front-proxy-client
    - --requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt
    - --requestheader-extra-headers-prefix=X-Remote-Extra-
    - --requestheader-group-headers=X-Remote-Group
    - --requestheader-username-headers=X-Remote-User
    - --secure-port=6443
    - --service-account-key-file=/etc/kubernetes/pki/sa.pub
    - --service-cluster-ip-range=10.96.0.0/12
    - --tls-cert-file=/etc/kubernetes/pki/apiserver.crt
    - --tls-private-key-file=/etc/kubernetes/pki/apiserver.key
    image: registry.aliyuncs.com/google_containers/kube-apiserver:v1.15.2
    imagePullPolicy: IfNotPresent
    livenessProbe:
      failureThreshold: 8
      httpGet:
        host: 192.168.26.10
        path: /healthz
        port: 6443
        scheme: HTTPS
      initialDelaySeconds: 15
      timeoutSeconds: 15
    name: kube-apiserver
    resources:
      requests:
        cpu: 250m
    volumeMounts:
    - mountPath: /etc/ssl/certs
      name: ca-certs
      readOnly: true
    - mountPath: /etc/pki
      name: etc-pki
      readOnly: true
    - mountPath: /etc/kubernetes/pki
      name: k8s-certs
      readOnly: true
  hostNetwork: true
  priorityClassName: system-cluster-critical
  volumes:
  - hostPath:
      path: /etc/ssl/certs
      type: DirectoryOrCreate
    name: ca-certs
  - hostPath:
      path: /etc/pki
      type: DirectoryOrCreate
    name: etc-pki
  - hostPath:
      path: /etc/kubernetes/pki
      type: DirectoryOrCreate
    name: k8s-certs
status: {}

k8s kubernetes Lesson 8 Error

Error: User "system:serviceaccount:kube-system:default" cannot get resource "namespaces"


https://github.com/fnproject/fn-helm/issues/21#issuecomment-545317241


kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
helm init --upgrade --service-account tiller

docker registry Other Way


On root home

openssl req -nodes -newkey rsa:4096 -keyout certs/docker-registry.key -out certs/docker-registry.csr -subj "/C=/ST=/L=/O=/OU=/CN=docker-registry"
openssl x509 -req -sha256 -days 365 -in certs/docker-registry.csr -signkey certs/docker-registry.key -out certs/docker-registry.crt


docker run -dp 5000:5000 --name registry -v "$(pwd)"/certs:/certs \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/docker-registry.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/docker-registry.key \
registry


nano /etc/hosts 
> 192.168.99.118 docker-registry

cd /etc/docker
mkdir certs.d
cd certs.d
mkdir docker-registry:5000
cd docker-registry:5000
cp ~/certs/docker-registry.crt ca.crt

===== check registry is working
docker image pull busybox
docker image tag busybox docker-registry:5000/mybusybox
docker image push docker-registry:5000/mybusybox
docker run --rm docker-registry:5000/mybusybox echo "Hello from busybox"

//
docker rmi busybox docker-registry:5000/mybusybox
docker run --rm docker-registry:5000/mybusybox echo "Hello from busybox"

===== remove registry
docker container stop registry && docker container rm -v registry



https://jkzhao.github.io/2017/09/01/Registry%E7%A7%81%E6%9C%89%E4%BB%93%E5%BA%93%E6%90%AD%E5%BB%BA%E5%8F%8A%E8%AE%A4%E8%AF%81/

列出私有仓库中的所有镜像

curl -k -X GET https://docker-registry:5000/v2/_catalog  >> {"repositories":["mybusybox"]}

curl --cacert certs/docker-registry.crt https://docker-registry:5000/v2/_catalog

curl -k https://docker-registry:5000/v2/_catalog

Hyperledger Hurley is the development environment toolset

https://github.com/worldsibu/hurley#readme

[轉]covalent hyperledger code sample

https://docs.covalentx.com/article/73-code-samples

[轉]Hyperledger Composer is deprecated

https://hackernoon.com/hyperledger-composer-is-deprecated-kuzqu31cb

ethereum seth

https://github.com/dapphub/dapptools/tree/master/src/seth

Hyperledger KC Tam

https://medium.com/@kctheservant

http://www.ledgertech.biz/kcarticles.html


===========
https://hyperledger-fabric.readthedocs.io/en/release-1.4/tutorials.html

參考 [轉] Hyperledger Fabric 1.2系列 -- 将组织添加进通道: 手动执行

https://www.jianshu.com/p/09c67924da90

[轉]Hyperledger Fabric BYFN之配置進階篇

https://www.itread01.com/content/1550412200.html

1. byfn.sh up down會清理所有容器映象,生成的配置檔案和證書,現實場景應該可以停止或恢復區塊鏈網路,該如何處理?


byfn.sh down會呼叫networkdDown去銷燬整個網路和已生成的配置。byfn.sh restart則不會清理。

...........

注意

docker-compose down會停止和刪除容器,網路,映象和對映的卷。

只是停止服務的話的會最好使用docker-compose stop。

docker-compose up則是建立和啟動容器服務, 這裡用於啟動。

我們也可以參考例子fabric-samples/fabcar, 它會重用fabric-samples/basic-network中的start.sh, stop.sh允許停止和重啟。


2. byfn.sh還是fabcar兩個例子即使重啟區塊鏈網路,通道需要創新建立,節點需要重新加入通道,鏈碼也要全要重新安裝,如果節點多維護起來就麻煩且費時,重啟的時候能讓通道,節點,鏈碼,State DB自動恢復?



這自然是有的,但是必須開啟orderer, peer等的持久化配置。

...........


  orderer.example.com:
  ...
 - /mnt/hyperledger/orderer:/var/hyperledger/production/orderer


  peer0.org1.example.com:
  ...
  - /mnt/hyperledger/org1/peer0:/var/hyperledger/production


  couchdb:
  ...
  - /mnt/hyperledger/couchdb:/opt/couchdb/data




4. Peer節點我們配置了兩個埠,配置用來做什麼?



ports:

      - 7051:7051

      - 7053:7053

7051是Peer啟動的gRPC, 一般是客戶端應用接入。

7053是事件埠(Peer Event)

..........

Fabric 1.1之後peer event做了完全不同的設計,訊息的監聽不在peer節點了,而是基於channel,這樣設計提供了對Peer資料更細粒度的採訪控制和提供了接收訊息的可靠性。(官方文件是這麼扯,我也有點疑惑) 主要提供兩種服務,Deliver(通知提交到記賬本的整個區塊內容) 和DeliverFiltered(過濾一些區塊減少訊息通知返回的區塊大小)

Docker 本身DNS是不穩定的

再分享早上碰到docker穩定度問題,docker內到外網是靠本機的iptables做Nat出去,早上就發現運行很久的docker container,突然不送資料到ELK,一查發現DNS掛了,這之前也碰到幾次了,基本上不是中心DNS掛了,而且Docker本身架構的DNS掛了,基本上只要重啟docker service後就正常,無需對主機重啟,而重啟docker service是一件很嚴重的事情,因為上面所有的服務都會一併被下線,之後還要在把運行的服務全部重新上線…


也許我的理解是錯誤,但只能以目前的情況來判斷,也許是iptables nat轉換的問題,但本機沒有重開機,理論上就沒有這個問題才是。

[轉]What's New in Ethereum Serenity (2.0)

http://kimiwublog.blogspot.com/2018/12/whats-new-in-ethereum-serenity-20.html

需注意,時間是2018/12/06 內容肯不會是最正確的

[DIY] HyperLedger

1. Use docker-machine crate docker vm.

And install docker-compose.

2. https://github.com/hyperledger/fabric-samples



# Fetch bootstrap.sh from fabric repository using
curl -sS https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh -o ./scripts/bootstrap.sh

# Change file mode to executable
chmod +x ./scripts/bootstrap.sh

# Download binaries and docker images
#./scripts/bootstrap.sh [version] [ca version] [thirdparty_version]

./scripts/bootstrap.sh

Here use all default value.


3. https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html


# Start Run

cd fabric-samples/first-network  
./byfn.sh generate
./byfn.sh up

4. Hope you see

===================== Query successful on peer1.org2 on channel 'mychannel' =====================

========= All GOOD, BYFN execution completed ===========

5. check docker ps Need like this




PS:


1. See Error

2019-11-06 02:22:34.819 UTC [main] InitCmd -> ERRO 001 Cannot run peer because cannot init crypto, folder "/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" does not exist
!!!!!!!!!!!!!!! Channel creation failed !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========

How to Fix


cd fabric-samples/first-network  
./byfn.sh down
./byfn.sh generate  #This maybe don't need
./byfn.sh up


6. How to querying chaincode again

https://learnblockchain.cn/2019/07/03/chaincode-run/


docker exec -it cli bash

root@73e65944cade:/opt/gopath/src/github.com/hyperledger/fabric/peer>


root@73e65944cade:/opt/gopath/src/github.com/hyperledger/fabric/peer>  peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'

# peer chaincode query This command come from e2etest that you first time See This message:
========= All GOOD, BYFN execution completed =========== 
Then just find screen up, can see "peer chaincode query ooxxooxxooxx". Please copy it then use in here.