diff --git a/CHANGELOG.md b/CHANGELOG.md index ee85feb6ef..e1b1661320 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,19 @@ # Changelog +## v1.1.22 +FEATURE +* [\#1361](https://github.com/bnb-chain/bsc/pull/1361) cmd/faucet: merge ipfaucet2 branch to develop + +IMPROVEMENT +* [\#1412](https://github.com/bnb-chain/bsc/pull/1412) fix: init-network with config.toml without setting TimeFormat +* [\#1401](https://github.com/bnb-chain/bsc/pull/1401) log: support custom time format configuration +* [\#1382](https://github.com/bnb-chain/bsc/pull/1382) consnesus/parlia: abort sealing when block in the same height has updated +* [\#1383](https://github.com/bnb-chain/bsc/pull/1383) miner: no need to broadcast sidechain header mined by this validator + +BUGFIX +* [\#1379](https://github.com/bnb-chain/bsc/pull/1379) UT: fix some flaky tests +* [\#1403](https://github.com/bnb-chain/bsc/pull/1403) Makefile: fix devtools install error +* [\#1381](https://github.com/bnb-chain/bsc/pull/1381) fix: snapshot generation issue after chain reinit from a freezer + ## v1.1.21 FEATURE * [\#1389](https://github.com/bnb-chain/bsc/pull/1389) upgrade: update the fork height of planck upgrade on mainnet diff --git a/Makefile b/Makefile index b35a4a9e4d..c18cdddea9 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ clean: devtools: env GOBIN= go install golang.org/x/tools/cmd/stringer@latest - env GOBIN= go install github.com/kevinburke/go-bindata/go-bindata@latest + env GOBIN= go install github.com/kevinburke/go-bindata@latest env GOBIN= go install github.com/fjl/gencodec@latest env GOBIN= go install github.com/golang/protobuf/protoc-gen-go@latest env GOBIN= go install ./cmd/abigen diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go index 639be86159..989b2234b8 100644 --- a/cmd/faucet/faucet.go +++ b/cmd/faucet/faucet.go @@ -90,9 +90,6 @@ var ( fixGasPrice = flag.Int64("faucet.fixedprice", 0, "Will use fixed gas price if specified") twitterTokenFlag = flag.String("twitter.token", "", "Bearer token to authenticate with the v2 Twitter API") twitterTokenV1Flag = flag.String("twitter.token.v1", "", "Bearer token to authenticate with the v1.1 Twitter API") - - goerliFlag = flag.Bool("goerli", false, "Initializes the faucet with Görli network config") - rinkebyFlag = flag.Bool("rinkeby", false, "Initializes the faucet with Rinkeby network config") ) var ( @@ -115,7 +112,7 @@ func main() { for i := 0; i < *tiersFlag; i++ { // Calculate the amount for the next tier and format it amount := float64(*payoutFlag) * math.Pow(2.5, float64(i)) - amounts[i] = fmt.Sprintf("%s BNBs", strconv.FormatFloat(amount, 'f', -1, 64)) + amounts[i] = fmt.Sprintf("0.%s BNBs", strconv.FormatFloat(amount, 'f', -1, 64)) if amount == 1 { amounts[i] = strings.TrimSuffix(amounts[i], "s") } @@ -170,9 +167,13 @@ func main() { log.Crit("Failed to render the faucet template", "err", err) } // Load and parse the genesis block requested by the user - genesis, err := getGenesis(genesisFlag, *goerliFlag, *rinkebyFlag) + blob, err := ioutil.ReadFile(*genesisFlag) if err != nil { - log.Crit("Failed to parse genesis config", "err", err) + log.Crit("Failed to read genesis block contents", "genesis", *genesisFlag, "err", err) + } + genesis := new(core.Genesis) + if err = json.Unmarshal(blob, genesis); err != nil { + log.Crit("Failed to parse genesis block json", "err", err) } // Convert the bootnodes to internal enode representations var enodes []*enode.Node @@ -184,13 +185,13 @@ func main() { } } // Load up the account key and decrypt its password - blob, err := ioutil.ReadFile(*accPassFlag) + blob, err = ioutil.ReadFile(*accPassFlag) if err != nil { log.Crit("Failed to read account password contents", "file", *accPassFlag, "err", err) } pass := strings.TrimSuffix(string(blob), "\n") - ks := keystore.NewKeyStore(filepath.Join(os.Getenv("HOME"), ".faucet", "keys"), keystore.StandardScryptN, keystore.StandardScryptP) + ks := keystore.NewKeyStore(filepath.Join(os.Getenv("HOME"), ".faucet", "keys_2"), keystore.StandardScryptN, keystore.StandardScryptP) if blob, err = ioutil.ReadFile(*accJSONFlag); err != nil { log.Crit("Failed to read account key contents", "file", *accJSONFlag, "err", err) } @@ -364,6 +365,11 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) { // Start tracking the connection and drop at the end defer conn.Close() + ipsStr := r.Header.Get("X-Forwarded-For") + ips := strings.Split(ipsStr, ",") + if len(ips) < 2 { + return + } f.lock.Lock() wsconn := &wsConn{conn: conn} @@ -460,7 +466,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) { form.Add("secret", *captchaSecret) form.Add("response", msg.Captcha) - res, err := http.PostForm("https://www.google.com/recaptcha/api/siteverify", form) + res, err := http.PostForm("https://hcaptcha.com/siteverify", form) if err != nil { if err = sendError(wsconn, err); err != nil { log.Warn("Failed to send captcha post error to client", "err", err) @@ -499,6 +505,19 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) { address common.Address ) switch { + case strings.HasPrefix(msg.URL, "https://gist.github.com/"): + if err = sendError(wsconn, errors.New("GitHub authentication discontinued at the official request of GitHub")); err != nil { + log.Warn("Failed to send GitHub deprecation to client", "err", err) + return + } + continue + case strings.HasPrefix(msg.URL, "https://plus.google.com/"): + //lint:ignore ST1005 Google is a company name and should be capitalized. + if err = sendError(wsconn, errors.New("Google+ authentication discontinued as the service was sunset")); err != nil { + log.Warn("Failed to send Google+ deprecation to client", "err", err) + return + } + continue case strings.HasPrefix(msg.URL, "https://twitter.com/"): id, username, avatar, address, err = authTwitter(msg.URL, *twitterTokenV1Flag, *twitterTokenFlag) case strings.HasPrefix(msg.URL, "https://www.facebook.com/"): @@ -526,11 +545,20 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) { fund bool timeout time.Time ) + + if ipTimeout := f.timeouts[ips[len(ips)-2]]; time.Now().Before(ipTimeout) { + if err = sendError(wsconn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(time.Until(ipTimeout)))); err != nil { // nolint: gosimple + log.Warn("Failed to send funding error to client", "err", err) + } + f.lock.Unlock() + continue + } + if timeout = f.timeouts[id]; time.Now().After(timeout) { var tx *types.Transaction if msg.Symbol == "BNB" { // User wasn't funded recently, create the funding transaction - amount := new(big.Int).Mul(big.NewInt(int64(*payoutFlag)), ether) + amount := new(big.Int).Div(new(big.Int).Mul(big.NewInt(int64(*payoutFlag)), ether), big.NewInt(10)) amount = new(big.Int).Mul(amount, new(big.Int).Exp(big.NewInt(5), big.NewInt(int64(msg.Tier)), nil)) amount = new(big.Int).Div(amount, new(big.Int).Exp(big.NewInt(2), big.NewInt(int64(msg.Tier)), nil)) @@ -578,6 +606,7 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) { grace := timeout / 288 // 24h timeout => 5m grace f.timeouts[id] = time.Now().Add(timeout - grace) + f.timeouts[ips[len(ips)-2]] = time.Now().Add(timeout - grace) fund = true } f.lock.Unlock() @@ -799,7 +828,7 @@ func authTwitter(url string, tokenV1, tokenV2 string) (string, string, string, c address := common.HexToAddress(string(regexp.MustCompile("0x[0-9a-fA-F]{40}").Find(body))) if address == (common.Address{}) { //lint:ignore ST1005 This error is to be displayed in the browser - return "", "", "", common.Address{}, errors.New("No Binance Smart Chain address found to fund") + return "", "", "", common.Address{}, errors.New("No BNB Smart Chain address found to fund") } var avatar string if parts = regexp.MustCompile(`src="([^"]+twimg\.com/profile_images[^"]+)"`).FindStringSubmatch(string(body)); len(parts) == 2 { @@ -925,7 +954,7 @@ func authFacebook(url string) (string, string, common.Address, error) { address := common.HexToAddress(string(regexp.MustCompile("0x[0-9a-fA-F]{40}").Find(body))) if address == (common.Address{}) { //lint:ignore ST1005 This error is to be displayed in the browser - return "", "", common.Address{}, errors.New("No Binance Smart Chain address found to fund") + return "", "", common.Address{}, errors.New("No BNB Smart Chain address found to fund") } var avatar string if parts = regexp.MustCompile(`src="([^"]+fbcdn\.net[^"]+)"`).FindStringSubmatch(string(body)); len(parts) == 2 { @@ -941,19 +970,7 @@ func authNoAuth(url string) (string, string, common.Address, error) { address := common.HexToAddress(regexp.MustCompile("0x[0-9a-fA-F]{40}").FindString(url)) if address == (common.Address{}) { //lint:ignore ST1005 This error is to be displayed in the browser - return "", "", common.Address{}, errors.New("No Binance Smart Chain address found to fund") + return "", "", common.Address{}, errors.New("No BNB Smart Chain address found to fund") } return address.Hex() + "@noauth", "", address, nil } - -// getGenesis returns a genesis based on input args -func getGenesis(genesisFlag *string, goerliFlag bool, rinkebyFlag bool) (*core.Genesis, error) { - switch { - case genesisFlag != nil: - var genesis core.Genesis - err := common.LoadJSON(*genesisFlag, &genesis) - return &genesis, err - default: - return nil, fmt.Errorf("no genesis flag provided") - } -} diff --git a/cmd/faucet/faucet.html b/cmd/faucet/faucet.html index 849145a60d..4f299857ca 100644 --- a/cmd/faucet/faucet.html +++ b/cmd/faucet/faucet.html @@ -1,220 +1,249 @@ -
- - - - -