Compare commits
24 Commits
v1.4.13
...
pascal-har
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9579134117 | ||
|
|
ca566b4491 | ||
|
|
10c15c997e | ||
|
|
20147c351e | ||
|
|
5c72898a0b | ||
|
|
df4dc499c7 | ||
|
|
7de27ca9e9 | ||
|
|
e7e5d508b5 | ||
|
|
1bcdad851f | ||
|
|
5c4096fffa | ||
|
|
f85d19aa8f | ||
|
|
0dab664d98 | ||
|
|
094519d058 | ||
|
|
d3450f13c9 | ||
|
|
959850218c | ||
|
|
af0204bd68 | ||
|
|
ec2d7e0228 | ||
|
|
c46d7e8bd8 | ||
|
|
6cb4be4ebf | ||
|
|
3bd9a2395c | ||
|
|
5d19f2182b | ||
|
|
99a2dd5ed9 | ||
|
|
3adcfabb41 | ||
|
|
b1f0a3c79b |
8
.github/workflows/pre-release.yml
vendored
8
.github/workflows/pre-release.yml
vendored
@@ -125,25 +125,25 @@ jobs:
|
|||||||
# ==============================
|
# ==============================
|
||||||
|
|
||||||
- name: Download Artifacts
|
- name: Download Artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4.1.7
|
||||||
with:
|
with:
|
||||||
name: linux
|
name: linux
|
||||||
path: ./linux
|
path: ./linux
|
||||||
|
|
||||||
- name: Download Artifacts
|
- name: Download Artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4.1.7
|
||||||
with:
|
with:
|
||||||
name: macos
|
name: macos
|
||||||
path: ./macos
|
path: ./macos
|
||||||
|
|
||||||
- name: Download Artifacts
|
- name: Download Artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4.1.7
|
||||||
with:
|
with:
|
||||||
name: windows
|
name: windows
|
||||||
path: ./windows
|
path: ./windows
|
||||||
|
|
||||||
- name: Download Artifacts
|
- name: Download Artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4.1.7
|
||||||
with:
|
with:
|
||||||
name: arm64
|
name: arm64
|
||||||
path: ./arm64
|
path: ./arm64
|
||||||
|
|||||||
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -124,25 +124,25 @@ jobs:
|
|||||||
# ==============================
|
# ==============================
|
||||||
|
|
||||||
- name: Download Artifacts
|
- name: Download Artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4.1.7
|
||||||
with:
|
with:
|
||||||
name: linux
|
name: linux
|
||||||
path: ./linux
|
path: ./linux
|
||||||
|
|
||||||
- name: Download Artifacts
|
- name: Download Artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4.1.7
|
||||||
with:
|
with:
|
||||||
name: macos
|
name: macos
|
||||||
path: ./macos
|
path: ./macos
|
||||||
|
|
||||||
- name: Download Artifacts
|
- name: Download Artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4.1.7
|
||||||
with:
|
with:
|
||||||
name: windows
|
name: windows
|
||||||
path: ./windows
|
path: ./windows
|
||||||
|
|
||||||
- name: Download Artifacts
|
- name: Download Artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4.1.7
|
||||||
with:
|
with:
|
||||||
name: arm64
|
name: arm64
|
||||||
path: ./arm64
|
path: ./arm64
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
CVE-2024-34478 # "CWE-754: Improper Check for Unusual or Exceptional Conditions." This vulnerability is BTC only, BSC does not have the issue.
|
CVE-2024-34478 # "CWE-754: Improper Check for Unusual or Exceptional Conditions." This vulnerability is BTC only, BSC does not have the issue.
|
||||||
CVE-2024-6104 # "CWE-532: Information Exposure Through Log Files" This is caused by the vulnerabilities go-retryablehttp@v0.7.4, it is only used in cmd devp2p, impact is limited. will upgrade to v0.7.7 later
|
CVE-2024-6104 # "CWE-532: Information Exposure Through Log Files" This is caused by the vulnerabilities go-retryablehttp@v0.7.4, it is only used in cmd devp2p, impact is limited. will upgrade to v0.7.7 later
|
||||||
|
CVE-2024-8421 # "CWE-400: Uncontrolled Resource Consumption (Resource Exhaustion)" This vulnerability is caused by issues in the golang.org/x/net package. Even the latest version(v0.29.0) has not yet addressed it, but we will continue to monitor updates closely.
|
||||||
17
CHANGELOG.md
17
CHANGELOG.md
@@ -1,4 +1,21 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
## v1.4.14
|
||||||
|
|
||||||
|
### BUGFIX
|
||||||
|
* [\#2643](https://github.com/bnb-chain/bsc/pull/2643)core: fix cache for receipts
|
||||||
|
* [\#2656](https://github.com/bnb-chain/bsc/pull/2656)ethclient: fix BlobSidecars api
|
||||||
|
* [\#2657](https://github.com/bnb-chain/bsc/pull/2657)fix: update prunefreezer’s offset when pruneancient and the dataset has pruned block
|
||||||
|
|
||||||
|
### FEATURE
|
||||||
|
* [\#2661](https://github.com/bnb-chain/bsc/pull/2661)config: setup Mainnet 2 hardfork date: HaberFix & Bohr
|
||||||
|
|
||||||
|
### IMPROVEMENT
|
||||||
|
* [\#2578](https://github.com/bnb-chain/bsc/pull/2578)core/systemcontracts: use vm.StateDB in UpgradeBuildInSystemContract
|
||||||
|
* [\#2649](https://github.com/bnb-chain/bsc/pull/2649)internal/debug: remove memsize
|
||||||
|
* [\#2655](https://github.com/bnb-chain/bsc/pull/2655)internal/ethapi: make GetFinalizedHeader monotonically increasing
|
||||||
|
* [\#2658](https://github.com/bnb-chain/bsc/pull/2658)core: improve readability of the fork choice logic
|
||||||
|
* [\#2665](https://github.com/bnb-chain/bsc/pull/2665)faucet: bump and resend faucet transaction if it has been pending for a while
|
||||||
|
|
||||||
## v1.4.13
|
## v1.4.13
|
||||||
|
|
||||||
### BUGFIX
|
### BUGFIX
|
||||||
|
|||||||
5
Makefile
5
Makefile
@@ -17,6 +17,11 @@ geth:
|
|||||||
@echo "Done building."
|
@echo "Done building."
|
||||||
@echo "Run \"$(GOBIN)/geth\" to launch geth."
|
@echo "Run \"$(GOBIN)/geth\" to launch geth."
|
||||||
|
|
||||||
|
#? faucet: Build faucet
|
||||||
|
faucet:
|
||||||
|
$(GORUN) build/ci.go install ./cmd/faucet
|
||||||
|
@echo "Done building faucet"
|
||||||
|
|
||||||
#? all: Build all packages and executables
|
#? all: Build all packages and executables
|
||||||
all:
|
all:
|
||||||
$(GORUN) build/ci.go install
|
$(GORUN) build/ci.go install
|
||||||
|
|||||||
87
beacon/fakebeacon/api_func.go
Normal file
87
beacon/fakebeacon/api_func.go
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
package fakebeacon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"sort"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto/kzg4844"
|
||||||
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BlobSidecar struct {
|
||||||
|
Blob kzg4844.Blob `json:"blob"`
|
||||||
|
Index int `json:"index"`
|
||||||
|
KZGCommitment kzg4844.Commitment `json:"kzg_commitment"`
|
||||||
|
KZGProof kzg4844.Proof `json:"kzg_proof"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type APIGetBlobSidecarsResponse struct {
|
||||||
|
Data []*BlobSidecar `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReducedGenesisData struct {
|
||||||
|
GenesisTime string `json:"genesis_time"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type APIGenesisResponse struct {
|
||||||
|
Data ReducedGenesisData `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReducedConfigData struct {
|
||||||
|
SecondsPerSlot string `json:"SECONDS_PER_SLOT"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type IndexedBlobHash struct {
|
||||||
|
Index int // absolute index in the block, a.k.a. position in sidecar blobs array
|
||||||
|
Hash common.Hash // hash of the blob, used for consistency checks
|
||||||
|
}
|
||||||
|
|
||||||
|
func configSpec() ReducedConfigData {
|
||||||
|
return ReducedConfigData{SecondsPerSlot: "1"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func beaconGenesis() APIGenesisResponse {
|
||||||
|
return APIGenesisResponse{Data: ReducedGenesisData{GenesisTime: "0"}}
|
||||||
|
}
|
||||||
|
|
||||||
|
func beaconBlobSidecars(ctx context.Context, backend ethapi.Backend, slot uint64, indices []int) (APIGetBlobSidecarsResponse, error) {
|
||||||
|
var blockNrOrHash rpc.BlockNumberOrHash
|
||||||
|
header, err := fetchBlockNumberByTime(ctx, int64(slot), backend)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Error fetching block number", "slot", slot, "indices", indices)
|
||||||
|
return APIGetBlobSidecarsResponse{}, err
|
||||||
|
}
|
||||||
|
sideCars, err := backend.GetBlobSidecars(ctx, header.Hash())
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Error fetching Sidecars", "blockNrOrHash", blockNrOrHash, "err", err)
|
||||||
|
return APIGetBlobSidecarsResponse{}, err
|
||||||
|
}
|
||||||
|
sort.Ints(indices)
|
||||||
|
fullBlob := len(indices) == 0
|
||||||
|
res := APIGetBlobSidecarsResponse{}
|
||||||
|
idx := 0
|
||||||
|
curIdx := 0
|
||||||
|
for _, sideCar := range sideCars {
|
||||||
|
for i := 0; i < len(sideCar.Blobs); i++ {
|
||||||
|
//hash := kZGToVersionedHash(sideCar.Commitments[i])
|
||||||
|
if !fullBlob && curIdx >= len(indices) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if fullBlob || idx == indices[curIdx] {
|
||||||
|
res.Data = append(res.Data, &BlobSidecar{
|
||||||
|
Index: idx,
|
||||||
|
Blob: sideCar.Blobs[i],
|
||||||
|
KZGCommitment: sideCar.Commitments[i],
|
||||||
|
KZGProof: sideCar.Proofs[i],
|
||||||
|
})
|
||||||
|
curIdx++
|
||||||
|
}
|
||||||
|
idx++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
88
beacon/fakebeacon/handlers.go
Normal file
88
beacon/fakebeacon/handlers.go
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
package fakebeacon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/prysmaticlabs/prysm/v5/api/server/structs"
|
||||||
|
field_params "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
||||||
|
"github.com/prysmaticlabs/prysm/v5/network/httputil"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
versionMethod = "/eth/v1/node/version"
|
||||||
|
specMethod = "/eth/v1/config/spec"
|
||||||
|
genesisMethod = "/eth/v1/beacon/genesis"
|
||||||
|
sidecarsMethodPrefix = "/eth/v1/beacon/blob_sidecars/{slot}"
|
||||||
|
)
|
||||||
|
|
||||||
|
func VersionMethod(w http.ResponseWriter, r *http.Request) {
|
||||||
|
resp := &structs.GetVersionResponse{
|
||||||
|
Data: &structs.Version{
|
||||||
|
Version: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
httputil.WriteJson(w, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SpecMethod(w http.ResponseWriter, r *http.Request) {
|
||||||
|
httputil.WriteJson(w, &structs.GetSpecResponse{Data: configSpec()})
|
||||||
|
}
|
||||||
|
|
||||||
|
func GenesisMethod(w http.ResponseWriter, r *http.Request) {
|
||||||
|
httputil.WriteJson(w, beaconGenesis())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Service) SidecarsMethod(w http.ResponseWriter, r *http.Request) {
|
||||||
|
indices, err := parseIndices(r.URL)
|
||||||
|
if err != nil {
|
||||||
|
httputil.HandleError(w, err.Error(), http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
segments := strings.Split(r.URL.Path, "/")
|
||||||
|
slot, err := strconv.ParseUint(segments[len(segments)-1], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
httputil.HandleError(w, "not a valid slot(timestamp)", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := beaconBlobSidecars(r.Context(), s.backend, slot, indices)
|
||||||
|
if err != nil {
|
||||||
|
httputil.HandleError(w, err.Error(), http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
httputil.WriteJson(w, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// parseIndices filters out invalid and duplicate blob indices
|
||||||
|
func parseIndices(url *url.URL) ([]int, error) {
|
||||||
|
rawIndices := url.Query()["indices"]
|
||||||
|
indices := make([]int, 0, field_params.MaxBlobsPerBlock)
|
||||||
|
invalidIndices := make([]string, 0)
|
||||||
|
loop:
|
||||||
|
for _, raw := range rawIndices {
|
||||||
|
ix, err := strconv.Atoi(raw)
|
||||||
|
if err != nil {
|
||||||
|
invalidIndices = append(invalidIndices, raw)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if ix >= field_params.MaxBlobsPerBlock {
|
||||||
|
invalidIndices = append(invalidIndices, raw)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for i := range indices {
|
||||||
|
if ix == indices[i] {
|
||||||
|
continue loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
indices = append(indices, ix)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(invalidIndices) > 0 {
|
||||||
|
return nil, fmt.Errorf("requested blob indices %v are invalid", invalidIndices)
|
||||||
|
}
|
||||||
|
return indices, nil
|
||||||
|
}
|
||||||
97
beacon/fakebeacon/server.go
Normal file
97
beacon/fakebeacon/server.go
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
package fakebeacon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/prysmaticlabs/prysm/v5/api/server"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultAddr = "localhost"
|
||||||
|
DefaultPort = 8686
|
||||||
|
)
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
Enable bool
|
||||||
|
Addr string
|
||||||
|
Port int
|
||||||
|
}
|
||||||
|
|
||||||
|
func defaultConfig() *Config {
|
||||||
|
return &Config{
|
||||||
|
Enable: false,
|
||||||
|
Addr: DefaultAddr,
|
||||||
|
Port: DefaultPort,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Service struct {
|
||||||
|
cfg *Config
|
||||||
|
router *mux.Router
|
||||||
|
backend ethapi.Backend
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewService(cfg *Config, backend ethapi.Backend) *Service {
|
||||||
|
cfgs := defaultConfig()
|
||||||
|
if cfg.Addr != "" {
|
||||||
|
cfgs.Addr = cfg.Addr
|
||||||
|
}
|
||||||
|
if cfg.Port > 0 {
|
||||||
|
cfgs.Port = cfg.Port
|
||||||
|
}
|
||||||
|
|
||||||
|
s := &Service{
|
||||||
|
cfg: cfgs,
|
||||||
|
backend: backend,
|
||||||
|
}
|
||||||
|
router := s.newRouter()
|
||||||
|
s.router = router
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Service) Run() {
|
||||||
|
_ = http.ListenAndServe(s.cfg.Addr+":"+strconv.Itoa(s.cfg.Port), s.router)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Service) newRouter() *mux.Router {
|
||||||
|
r := mux.NewRouter()
|
||||||
|
r.Use(server.NormalizeQueryValuesHandler)
|
||||||
|
for _, e := range s.endpoints() {
|
||||||
|
r.HandleFunc(e.path, e.handler).Methods(e.methods...)
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
type endpoint struct {
|
||||||
|
path string
|
||||||
|
handler http.HandlerFunc
|
||||||
|
methods []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Service) endpoints() []endpoint {
|
||||||
|
return []endpoint{
|
||||||
|
{
|
||||||
|
path: versionMethod,
|
||||||
|
handler: VersionMethod,
|
||||||
|
methods: []string{http.MethodGet},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: specMethod,
|
||||||
|
handler: SpecMethod,
|
||||||
|
methods: []string{http.MethodGet},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: genesisMethod,
|
||||||
|
handler: GenesisMethod,
|
||||||
|
methods: []string{http.MethodGet},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: sidecarsMethodPrefix,
|
||||||
|
handler: s.SidecarsMethod,
|
||||||
|
methods: []string{http.MethodGet},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
90
beacon/fakebeacon/server_test.go
Normal file
90
beacon/fakebeacon/server_test.go
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package fakebeacon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
//
|
||||||
|
//func TestFetchBlockNumberByTime(t *testing.T) {
|
||||||
|
// blockNum, err := fetchBlockNumberByTime(context.Background(), 1724052941, client)
|
||||||
|
// assert.Nil(t, err)
|
||||||
|
// assert.Equal(t, uint64(41493946), blockNum)
|
||||||
|
//
|
||||||
|
// blockNum, err = fetchBlockNumberByTime(context.Background(), 1734052941, client)
|
||||||
|
// assert.Equal(t, err, errors.New("time too large"))
|
||||||
|
//
|
||||||
|
// blockNum, err = fetchBlockNumberByTime(context.Background(), 1600153618, client)
|
||||||
|
// assert.Nil(t, err)
|
||||||
|
// assert.Equal(t, uint64(493946), blockNum)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func TestBeaconBlobSidecars(t *testing.T) {
|
||||||
|
// indexBlobHash := []IndexedBlobHash{
|
||||||
|
// {Hash: common.HexToHash("0x01231952ecbaede62f8d0398b656072c072db36982c9ef106fbbc39ce14f983c"), Index: 0},
|
||||||
|
// {Hash: common.HexToHash("0x012c21a8284d2d707bb5318e874d2e1b97a53d028e96abb702b284a2cbb0f79c"), Index: 1},
|
||||||
|
// {Hash: common.HexToHash("0x011196c8d02536ede0382aa6e9fdba6c460169c0711b5f97fcd701bd8997aee3"), Index: 2},
|
||||||
|
// {Hash: common.HexToHash("0x019c86b46b27401fb978fd175d1eb7dadf4976d6919501b0c5280d13a5bab57b"), Index: 3},
|
||||||
|
// {Hash: common.HexToHash("0x01e00db7ee99176b3fd50aab45b4fae953292334bbf013707aac58c455d98596"), Index: 4},
|
||||||
|
// {Hash: common.HexToHash("0x0117d23b68123d578a98b3e1aa029661e0abda821a98444c21992eb1e5b7208f"), Index: 5},
|
||||||
|
// //{Hash: common.HexToHash("0x01e00db7ee99176b3fd50aab45b4fae953292334bbf013707aac58c455d98596"), Index: 1},
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// resp, err := beaconBlobSidecars(context.Background(), 1724055046, []int{0, 1, 2, 3, 4, 5}) // block: 41494647
|
||||||
|
// assert.Nil(t, err)
|
||||||
|
// assert.NotNil(t, resp)
|
||||||
|
// assert.NotEmpty(t, resp.Data)
|
||||||
|
// for i, sideCar := range resp.Data {
|
||||||
|
// assert.Equal(t, indexBlobHash[i].Index, sideCar.Index)
|
||||||
|
// assert.Equal(t, indexBlobHash[i].Hash, kZGToVersionedHash(sideCar.KZGCommitment))
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// apiscs := make([]*BlobSidecar, 0, len(indexBlobHash))
|
||||||
|
// // filter and order by hashes
|
||||||
|
// for _, h := range indexBlobHash {
|
||||||
|
// for _, apisc := range resp.Data {
|
||||||
|
// if h.Index == int(apisc.Index) {
|
||||||
|
// apiscs = append(apiscs, apisc)
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// assert.Equal(t, len(apiscs), len(resp.Data))
|
||||||
|
// assert.Equal(t, len(apiscs), len(indexBlobHash))
|
||||||
|
//}
|
||||||
|
|
||||||
|
type TimeToSlotFn func(timestamp uint64) (uint64, error)
|
||||||
|
|
||||||
|
// GetTimeToSlotFn returns a function that converts a timestamp to a slot number.
|
||||||
|
func GetTimeToSlotFn(ctx context.Context) (TimeToSlotFn, error) {
|
||||||
|
genesis := beaconGenesis()
|
||||||
|
config := configSpec()
|
||||||
|
|
||||||
|
genesisTime, _ := strconv.ParseUint(genesis.Data.GenesisTime, 10, 64)
|
||||||
|
secondsPerSlot, _ := strconv.ParseUint(config.SecondsPerSlot, 10, 64)
|
||||||
|
if secondsPerSlot == 0 {
|
||||||
|
return nil, fmt.Errorf("got bad value for seconds per slot: %v", config.SecondsPerSlot)
|
||||||
|
}
|
||||||
|
timeToSlotFn := func(timestamp uint64) (uint64, error) {
|
||||||
|
if timestamp < genesisTime {
|
||||||
|
return 0, fmt.Errorf("provided timestamp (%v) precedes genesis time (%v)", timestamp, genesisTime)
|
||||||
|
}
|
||||||
|
return (timestamp - genesisTime) / secondsPerSlot, nil
|
||||||
|
}
|
||||||
|
return timeToSlotFn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAPI(t *testing.T) {
|
||||||
|
slotFn, err := GetTimeToSlotFn(context.Background())
|
||||||
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
expTx := uint64(123151345)
|
||||||
|
gotTx, err := slotFn(expTx)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, expTx, gotTx)
|
||||||
|
}
|
||||||
65
beacon/fakebeacon/utils.go
Normal file
65
beacon/fakebeacon/utils.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package fakebeacon
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func fetchBlockNumberByTime(ctx context.Context, ts int64, backend ethapi.Backend) (*types.Header, error) {
|
||||||
|
// calc the block number of the ts.
|
||||||
|
currentHeader := backend.CurrentHeader()
|
||||||
|
blockTime := int64(currentHeader.Time)
|
||||||
|
if ts > blockTime {
|
||||||
|
return nil, errors.New("time too large")
|
||||||
|
}
|
||||||
|
blockNum := currentHeader.Number.Uint64()
|
||||||
|
estimateEndNumber := int64(blockNum) - (blockTime-ts)/3
|
||||||
|
// find the end number
|
||||||
|
for {
|
||||||
|
header, err := backend.HeaderByNumber(ctx, rpc.BlockNumber(estimateEndNumber))
|
||||||
|
if err != nil {
|
||||||
|
time.Sleep(time.Duration(rand.Int()%180) * time.Millisecond)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if header == nil {
|
||||||
|
estimateEndNumber -= 1
|
||||||
|
time.Sleep(time.Duration(rand.Int()%180) * time.Millisecond)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
headerTime := int64(header.Time)
|
||||||
|
if headerTime == ts {
|
||||||
|
return header, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// let the estimateEndNumber a little bigger than real value
|
||||||
|
if headerTime > ts+8 {
|
||||||
|
estimateEndNumber -= (headerTime - ts) / 3
|
||||||
|
} else if headerTime < ts {
|
||||||
|
estimateEndNumber += (ts-headerTime)/3 + 1
|
||||||
|
} else {
|
||||||
|
// search one by one
|
||||||
|
for headerTime >= ts {
|
||||||
|
header, err = backend.HeaderByNumber(ctx, rpc.BlockNumber(estimateEndNumber-1))
|
||||||
|
if err != nil {
|
||||||
|
time.Sleep(time.Duration(rand.Int()%180) * time.Millisecond)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
headerTime = int64(header.Time)
|
||||||
|
if headerTime == ts {
|
||||||
|
return header, nil
|
||||||
|
}
|
||||||
|
estimateEndNumber -= 1
|
||||||
|
if headerTime < ts { //found the real endNumber
|
||||||
|
return nil, fmt.Errorf("block not found by time %d", ts)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,9 +53,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
genesisFlag = flag.String("genesis", "", "Genesis json file to seed the chain with")
|
genesisFlag = flag.String("genesis", "", "Genesis json file to seed the chain with")
|
||||||
apiPortFlag = flag.Int("apiport", 8080, "Listener port for the HTTP API connection")
|
apiPortFlag = flag.Int("apiport", 8080, "Listener port for the HTTP API connection")
|
||||||
wsEndpoint = flag.String("ws", "http://127.0.0.1:7777/", "Url to ws endpoint")
|
wsEndpoint = flag.String("ws", "http://127.0.0.1:7777/", "Url to ws endpoint")
|
||||||
|
wsEndpointMainnet = flag.String("ws.mainnet", "", "Url to ws endpoint of BSC mainnet")
|
||||||
|
|
||||||
netnameFlag = flag.String("faucet.name", "", "Network name to assign to the faucet")
|
netnameFlag = flag.String("faucet.name", "", "Network name to assign to the faucet")
|
||||||
payoutFlag = flag.Int("faucet.amount", 1, "Number of Ethers to pay out per user request")
|
payoutFlag = flag.Int("faucet.amount", 1, "Number of Ethers to pay out per user request")
|
||||||
@@ -77,6 +78,12 @@ var (
|
|||||||
fixGasPrice = flag.Int64("faucet.fixedprice", 0, "Will use fixed gas price if specified")
|
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")
|
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")
|
twitterTokenV1Flag = flag.String("twitter.token.v1", "", "Bearer token to authenticate with the v1.1 Twitter API")
|
||||||
|
|
||||||
|
resendInterval = 15 * time.Second
|
||||||
|
resendBatchSize = 3
|
||||||
|
resendMaxGasPrice = big.NewInt(50 * params.GWei)
|
||||||
|
wsReadTimeout = 5 * time.Minute
|
||||||
|
minMainnetBalance = big.NewInt(2 * 1e6 * params.GWei) // 0.002 bnb
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -87,11 +94,17 @@ var (
|
|||||||
//go:embed faucet.html
|
//go:embed faucet.html
|
||||||
var websiteTmpl string
|
var websiteTmpl string
|
||||||
|
|
||||||
|
func weiToEtherStringFx(wei *big.Int, prec int) string {
|
||||||
|
etherValue := new(big.Float).Quo(new(big.Float).SetInt(wei), big.NewFloat(params.Ether))
|
||||||
|
// Format the big.Float directly to a string with the specified precision
|
||||||
|
return etherValue.Text('f', prec)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Parse the flags and set up the logger to print everything requested
|
// Parse the flags and set up the logger to print everything requested
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.FromLegacyLevel(*logFlag), true)))
|
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.FromLegacyLevel(*logFlag), false)))
|
||||||
|
log.Info("faucet started")
|
||||||
// Construct the payout tiers
|
// Construct the payout tiers
|
||||||
amounts := make([]string, *tiersFlag)
|
amounts := make([]string, *tiersFlag)
|
||||||
for i := 0; i < *tiersFlag; i++ {
|
for i := 0; i < *tiersFlag; i++ {
|
||||||
@@ -170,7 +183,7 @@ func main() {
|
|||||||
log.Crit("Failed to unlock faucet signer account", "err", err)
|
log.Crit("Failed to unlock faucet signer account", "err", err)
|
||||||
}
|
}
|
||||||
// Assemble and start the faucet light service
|
// Assemble and start the faucet light service
|
||||||
faucet, err := newFaucet(genesis, *wsEndpoint, ks, website.Bytes(), bep2eInfos)
|
faucet, err := newFaucet(genesis, *wsEndpoint, *wsEndpointMainnet, ks, website.Bytes(), bep2eInfos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Crit("Failed to start faucet", "err", err)
|
log.Crit("Failed to start faucet", "err", err)
|
||||||
}
|
}
|
||||||
@@ -197,9 +210,10 @@ type bep2eInfo struct {
|
|||||||
|
|
||||||
// faucet represents a crypto faucet backed by an Ethereum light client.
|
// faucet represents a crypto faucet backed by an Ethereum light client.
|
||||||
type faucet struct {
|
type faucet struct {
|
||||||
config *params.ChainConfig // Chain configurations for signing
|
config *params.ChainConfig // Chain configurations for signing
|
||||||
client *ethclient.Client // Client connection to the Ethereum chain
|
client *ethclient.Client // Client connection to the Ethereum chain
|
||||||
index []byte // Index page to serve up on the web
|
clientMainnet *ethclient.Client // Client connection to BSC mainnet for balance check
|
||||||
|
index []byte // Index page to serve up on the web
|
||||||
|
|
||||||
keystore *keystore.KeyStore // Keystore containing the single signer
|
keystore *keystore.KeyStore // Keystore containing the single signer
|
||||||
account accounts.Account // Account funding user faucet requests
|
account accounts.Account // Account funding user faucet requests
|
||||||
@@ -228,7 +242,7 @@ type wsConn struct {
|
|||||||
wlock sync.Mutex
|
wlock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFaucet(genesis *core.Genesis, url string, ks *keystore.KeyStore, index []byte, bep2eInfos map[string]bep2eInfo) (*faucet, error) {
|
func newFaucet(genesis *core.Genesis, url string, mainnetUrl string, ks *keystore.KeyStore, index []byte, bep2eInfos map[string]bep2eInfo) (*faucet, error) {
|
||||||
bep2eAbi, err := abi.JSON(strings.NewReader(bep2eAbiJson))
|
bep2eAbi, err := abi.JSON(strings.NewReader(bep2eAbiJson))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -237,6 +251,11 @@ func newFaucet(genesis *core.Genesis, url string, ks *keystore.KeyStore, index [
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
clientMainnet, err := ethclient.Dial(mainnetUrl)
|
||||||
|
if err != nil {
|
||||||
|
// skip mainnet balance check if it there is no available mainnet endpoint
|
||||||
|
log.Warn("dail mainnet endpoint failed", "mainnetUrl", mainnetUrl, "err", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Allow 1 request per minute with burst of 5, and cache up to 1000 IPs
|
// Allow 1 request per minute with burst of 5, and cache up to 1000 IPs
|
||||||
limiter, err := NewIPRateLimiter(rate.Limit(1.0), 5, 1000)
|
limiter, err := NewIPRateLimiter(rate.Limit(1.0), 5, 1000)
|
||||||
@@ -245,16 +264,17 @@ func newFaucet(genesis *core.Genesis, url string, ks *keystore.KeyStore, index [
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &faucet{
|
return &faucet{
|
||||||
config: genesis.Config,
|
config: genesis.Config,
|
||||||
client: client,
|
client: client,
|
||||||
index: index,
|
clientMainnet: clientMainnet,
|
||||||
keystore: ks,
|
index: index,
|
||||||
account: ks.Accounts()[0],
|
keystore: ks,
|
||||||
timeouts: make(map[string]time.Time),
|
account: ks.Accounts()[0],
|
||||||
update: make(chan struct{}, 1),
|
timeouts: make(map[string]time.Time),
|
||||||
bep2eInfos: bep2eInfos,
|
update: make(chan struct{}, 1),
|
||||||
bep2eAbi: bep2eAbi,
|
bep2eInfos: bep2eInfos,
|
||||||
limiter: limiter,
|
bep2eAbi: bep2eAbi,
|
||||||
|
limiter: limiter,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,7 +398,11 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
Captcha string `json:"captcha"`
|
Captcha string `json:"captcha"`
|
||||||
Symbol string `json:"symbol"`
|
Symbol string `json:"symbol"`
|
||||||
}
|
}
|
||||||
|
// not sure if it helps or not, but set a read deadline could help prevent resource leakage
|
||||||
|
// if user did not give response for too long, then the routine will be stuck.
|
||||||
|
conn.SetReadDeadline(time.Now().Add(wsReadTimeout))
|
||||||
if err = conn.ReadJSON(&msg); err != nil {
|
if err = conn.ReadJSON(&msg); err != nil {
|
||||||
|
log.Debug("read json message failed", "err", err, "ip", ip)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !*noauthFlag && !strings.HasPrefix(msg.URL, "https://twitter.com/") && !strings.HasPrefix(msg.URL, "https://www.facebook.com/") {
|
if !*noauthFlag && !strings.HasPrefix(msg.URL, "https://twitter.com/") && !strings.HasPrefix(msg.URL, "https://www.facebook.com/") {
|
||||||
@@ -396,9 +420,9 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Info("Faucet funds requested", "url", msg.URL, "tier", msg.Tier)
|
log.Info("Faucet funds requested", "url", msg.URL, "tier", msg.Tier, "ip", ip)
|
||||||
|
|
||||||
// If captcha verifications are enabled, make sure we're not dealing with a robot
|
// check #1: captcha verifications to exclude robot
|
||||||
if *captchaToken != "" {
|
if *captchaToken != "" {
|
||||||
form := url.Values{}
|
form := url.Values{}
|
||||||
form.Add("secret", *captchaSecret)
|
form.Add("secret", *captchaSecret)
|
||||||
@@ -475,88 +499,108 @@ func (f *faucet) apiHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Info("Faucet request valid", "url", msg.URL, "tier", msg.Tier, "user", username, "address", address)
|
|
||||||
|
|
||||||
// Ensure the user didn't request funds too recently
|
// check #2: check IP and ID(address) to ensure the user didn't request funds too recently,
|
||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
var (
|
|
||||||
fund bool
|
|
||||||
timeout time.Time
|
|
||||||
)
|
|
||||||
|
|
||||||
if ipTimeout := f.timeouts[ips[len(ips)-2]]; time.Now().Before(ipTimeout) {
|
if ipTimeout := f.timeouts[ips[len(ips)-2]]; time.Now().Before(ipTimeout) {
|
||||||
|
f.lock.Unlock()
|
||||||
if err = sendError(wsconn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(time.Until(ipTimeout)))); err != nil { // nolint: gosimple
|
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)
|
log.Warn("Failed to send funding error to client", "err", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
f.lock.Unlock()
|
log.Info("too frequent funding(ip)", "TimeLeft", common.PrettyDuration(time.Until(ipTimeout)), "ip", ips[len(ips)-2], "ipsStr", ipsStr)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if idTimeout := f.timeouts[id]; time.Now().Before(idTimeout) {
|
||||||
if timeout = f.timeouts[id]; time.Now().After(timeout) {
|
f.lock.Unlock()
|
||||||
var tx *types.Transaction
|
// Send an error if too frequent funding, otherwise a success
|
||||||
if msg.Symbol == "BNB" {
|
if err = sendError(wsconn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(time.Until(idTimeout)))); err != nil { // nolint: gosimple
|
||||||
// User wasn't funded recently, create the funding transaction
|
log.Warn("Failed to send funding error to client", "err", err)
|
||||||
amount := new(big.Int).Div(new(big.Int).Mul(big.NewInt(int64(*payoutFlag)), ether), big.NewInt(10))
|
return
|
||||||
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))
|
|
||||||
|
|
||||||
tx = types.NewTransaction(f.nonce+uint64(len(f.reqs)), address, amount, 21000, f.price, nil)
|
|
||||||
} else {
|
|
||||||
tokenInfo, ok := f.bep2eInfos[msg.Symbol]
|
|
||||||
if !ok {
|
|
||||||
f.lock.Unlock()
|
|
||||||
log.Warn("Failed to find symbol", "symbol", msg.Symbol)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
input, err := f.bep2eAbi.Pack("transfer", address, &tokenInfo.Amount)
|
|
||||||
if err != nil {
|
|
||||||
f.lock.Unlock()
|
|
||||||
log.Warn("Failed to pack transfer transaction", "err", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
tx = types.NewTransaction(f.nonce+uint64(len(f.reqs)), tokenInfo.Contract, nil, 420000, f.price, input)
|
|
||||||
}
|
}
|
||||||
signed, err := f.keystore.SignTx(f.account, tx, f.config.ChainID)
|
log.Info("too frequent funding(id)", "TimeLeft", common.PrettyDuration(time.Until(idTimeout)), "id", id)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// check #3: minimum mainnet balance check, internal error will bypass the check to avoid blocking the faucet service
|
||||||
|
if f.clientMainnet != nil {
|
||||||
|
mainnetAddr := address
|
||||||
|
balanceMainnet, err := f.clientMainnet.BalanceAt(context.Background(), mainnetAddr, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("check balance failed, call BalanceAt", "err", err)
|
||||||
|
} else if balanceMainnet == nil {
|
||||||
|
log.Warn("check balance failed, balanceMainnet is nil")
|
||||||
|
} else {
|
||||||
|
if balanceMainnet.Cmp(minMainnetBalance) < 0 {
|
||||||
|
f.lock.Unlock()
|
||||||
|
log.Warn("insufficient BNB on BSC mainnet", "address", mainnetAddr,
|
||||||
|
"balanceMainnet", balanceMainnet, "minMainnetBalance", minMainnetBalance)
|
||||||
|
// Send an error if failed to meet the minimum balance requirement
|
||||||
|
if err = sendError(wsconn, fmt.Errorf("insufficient BNB on BSC mainnet (require >=%sBNB)",
|
||||||
|
weiToEtherStringFx(minMainnetBalance, 3))); err != nil {
|
||||||
|
log.Warn("Failed to send mainnet minimum balance error to client", "err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Info("Faucet request valid", "url", msg.URL, "tier", msg.Tier, "user", username, "address", address, "ip", ip)
|
||||||
|
|
||||||
|
// now, it is ok to send tBNB or other tokens
|
||||||
|
var tx *types.Transaction
|
||||||
|
if msg.Symbol == "BNB" {
|
||||||
|
// User wasn't funded recently, create the funding transaction
|
||||||
|
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))
|
||||||
|
|
||||||
|
tx = types.NewTransaction(f.nonce+uint64(len(f.reqs)), address, amount, 21000, f.price, nil)
|
||||||
|
} else {
|
||||||
|
tokenInfo, ok := f.bep2eInfos[msg.Symbol]
|
||||||
|
if !ok {
|
||||||
|
f.lock.Unlock()
|
||||||
|
log.Warn("Failed to find symbol", "symbol", msg.Symbol)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
input, err := f.bep2eAbi.Pack("transfer", address, &tokenInfo.Amount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
f.lock.Unlock()
|
f.lock.Unlock()
|
||||||
if err = sendError(wsconn, err); err != nil {
|
log.Warn("Failed to pack transfer transaction", "err", err)
|
||||||
log.Warn("Failed to send transaction creation error to client", "err", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Submit the transaction and mark as funded if successful
|
tx = types.NewTransaction(f.nonce+uint64(len(f.reqs)), tokenInfo.Contract, nil, 420000, f.price, input)
|
||||||
if err := f.client.SendTransaction(context.Background(), signed); err != nil {
|
|
||||||
f.lock.Unlock()
|
|
||||||
if err = sendError(wsconn, err); err != nil {
|
|
||||||
log.Warn("Failed to send transaction transmission error to client", "err", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
f.reqs = append(f.reqs, &request{
|
|
||||||
Avatar: avatar,
|
|
||||||
Account: address,
|
|
||||||
Time: time.Now(),
|
|
||||||
Tx: signed,
|
|
||||||
})
|
|
||||||
timeout := time.Duration(*minutesFlag*int(math.Pow(3, float64(msg.Tier)))) * time.Minute
|
|
||||||
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()
|
signed, err := f.keystore.SignTx(f.account, tx, f.config.ChainID)
|
||||||
|
if err != nil {
|
||||||
// Send an error if too frequent funding, otherwise a success
|
f.lock.Unlock()
|
||||||
if !fund {
|
if err = sendError(wsconn, err); err != nil {
|
||||||
if err = sendError(wsconn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(time.Until(timeout)))); err != nil { // nolint: gosimple
|
log.Warn("Failed to send transaction creation error to client", "err", err)
|
||||||
log.Warn("Failed to send funding error to client", "err", err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// Submit the transaction and mark as funded if successful
|
||||||
|
if err := f.client.SendTransaction(context.Background(), signed); err != nil {
|
||||||
|
f.lock.Unlock()
|
||||||
|
if err = sendError(wsconn, err); err != nil {
|
||||||
|
log.Warn("Failed to send transaction transmission error to client", "err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
f.reqs = append(f.reqs, &request{
|
||||||
|
Avatar: avatar,
|
||||||
|
Account: address,
|
||||||
|
Time: time.Now(),
|
||||||
|
Tx: signed,
|
||||||
|
})
|
||||||
|
timeoutInt64 := time.Duration(*minutesFlag*int(math.Pow(3, float64(msg.Tier)))) * time.Minute
|
||||||
|
grace := timeoutInt64 / 288 // 24h timeout => 5m grace
|
||||||
|
|
||||||
|
f.timeouts[id] = time.Now().Add(timeoutInt64 - grace)
|
||||||
|
f.timeouts[ips[len(ips)-2]] = time.Now().Add(timeoutInt64 - grace)
|
||||||
|
f.lock.Unlock()
|
||||||
if err = sendSuccess(wsconn, fmt.Sprintf("Funding request accepted for %s into %s", username, address.Hex())); err != nil {
|
if err = sendSuccess(wsconn, fmt.Sprintf("Funding request accepted for %s into %s", username, address.Hex())); err != nil {
|
||||||
log.Warn("Failed to send funding success to client", "err", err)
|
log.Warn("Failed to send funding success to client", "err", err)
|
||||||
return
|
return
|
||||||
@@ -605,9 +649,52 @@ func (f *faucet) refresh(head *types.Header) error {
|
|||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
f.head, f.balance = head, balance
|
f.head, f.balance = head, balance
|
||||||
f.price, f.nonce = price, nonce
|
f.price, f.nonce = price, nonce
|
||||||
if len(f.reqs) > 0 && f.reqs[0].Tx.Nonce() > f.nonce {
|
if len(f.reqs) == 0 {
|
||||||
|
log.Debug("refresh len(f.reqs) == 0", "f.nonce", f.nonce)
|
||||||
|
f.lock.Unlock()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if f.reqs[0].Tx.Nonce() == f.nonce {
|
||||||
|
// if the next Tx failed to be included for a certain time(resendInterval), try to
|
||||||
|
// resend it with higher gasPrice, as it could be discarded in the network.
|
||||||
|
// Also resend extra following txs, as they could be discarded as well.
|
||||||
|
if time.Now().After(f.reqs[0].Time.Add(resendInterval)) {
|
||||||
|
for i, req := range f.reqs {
|
||||||
|
if i >= resendBatchSize {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
prePrice := req.Tx.GasPrice()
|
||||||
|
// bump gas price 20% to replace the previous tx
|
||||||
|
newPrice := new(big.Int).Add(prePrice, new(big.Int).Div(prePrice, big.NewInt(5)))
|
||||||
|
if newPrice.Cmp(resendMaxGasPrice) >= 0 {
|
||||||
|
log.Info("resendMaxGasPrice reached", "newPrice", newPrice, "resendMaxGasPrice", resendMaxGasPrice, "nonce", req.Tx.Nonce())
|
||||||
|
break
|
||||||
|
}
|
||||||
|
newTx := types.NewTransaction(req.Tx.Nonce(), *req.Tx.To(), req.Tx.Value(), req.Tx.Gas(), newPrice, req.Tx.Data())
|
||||||
|
newSigned, err := f.keystore.SignTx(f.account, newTx, f.config.ChainID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("resend sign tx failed", "err", err)
|
||||||
|
}
|
||||||
|
log.Info("reqs[0] Tx has been stuck for a while, trigger resend",
|
||||||
|
"resendInterval", resendInterval, "resendTxSize", resendBatchSize,
|
||||||
|
"preHash", req.Tx.Hash().Hex(), "newHash", newSigned.Hash().Hex(),
|
||||||
|
"newPrice", newPrice, "nonce", req.Tx.Nonce(), "req.Tx.Gas()", req.Tx.Gas())
|
||||||
|
if err := f.client.SendTransaction(context.Background(), newSigned); err != nil {
|
||||||
|
log.Warn("resend tx failed", "err", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
req.Tx = newSigned
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// it is abnormal that reqs[0] has larger nonce than next expected nonce.
|
||||||
|
// could be caused by reorg? reset it
|
||||||
|
if f.reqs[0].Tx.Nonce() > f.nonce {
|
||||||
|
log.Warn("reset due to nonce gap", "f.nonce", f.nonce, "f.reqs[0].Tx.Nonce()", f.reqs[0].Tx.Nonce())
|
||||||
f.reqs = f.reqs[:0]
|
f.reqs = f.reqs[:0]
|
||||||
}
|
}
|
||||||
|
// remove the reqs if they have smaller nonce, which means it is no longer valid,
|
||||||
|
// either has been accepted or replaced.
|
||||||
for len(f.reqs) > 0 && f.reqs[0].Tx.Nonce() < f.nonce {
|
for len(f.reqs) > 0 && f.reqs[0].Tx.Nonce() < f.nonce {
|
||||||
f.reqs = f.reqs[1:]
|
f.reqs = f.reqs[1:]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ var (
|
|||||||
utils.CachePreimagesFlag,
|
utils.CachePreimagesFlag,
|
||||||
utils.OverridePassedForkTime,
|
utils.OverridePassedForkTime,
|
||||||
utils.OverrideBohr,
|
utils.OverrideBohr,
|
||||||
|
utils.OverridePascal,
|
||||||
utils.OverrideVerkle,
|
utils.OverrideVerkle,
|
||||||
utils.MultiDataBaseFlag,
|
utils.MultiDataBaseFlag,
|
||||||
}, utils.DatabaseFlags),
|
}, utils.DatabaseFlags),
|
||||||
@@ -262,6 +263,10 @@ func initGenesis(ctx *cli.Context) error {
|
|||||||
v := ctx.Uint64(utils.OverrideBohr.Name)
|
v := ctx.Uint64(utils.OverrideBohr.Name)
|
||||||
overrides.OverrideBohr = &v
|
overrides.OverrideBohr = &v
|
||||||
}
|
}
|
||||||
|
if ctx.IsSet(utils.OverridePascal.Name) {
|
||||||
|
v := ctx.Uint64(utils.OverridePascal.Name)
|
||||||
|
overrides.OverridePascal = &v
|
||||||
|
}
|
||||||
if ctx.IsSet(utils.OverrideVerkle.Name) {
|
if ctx.IsSet(utils.OverrideVerkle.Name) {
|
||||||
v := ctx.Uint64(utils.OverrideVerkle.Name)
|
v := ctx.Uint64(utils.OverrideVerkle.Name)
|
||||||
overrides.OverrideVerkle = &v
|
overrides.OverrideVerkle = &v
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||||
"github.com/ethereum/go-ethereum/accounts/scwallet"
|
"github.com/ethereum/go-ethereum/accounts/scwallet"
|
||||||
"github.com/ethereum/go-ethereum/accounts/usbwallet"
|
"github.com/ethereum/go-ethereum/accounts/usbwallet"
|
||||||
|
"github.com/ethereum/go-ethereum/beacon/fakebeacon"
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
@@ -92,10 +93,11 @@ type ethstatsConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type gethConfig struct {
|
type gethConfig struct {
|
||||||
Eth ethconfig.Config
|
Eth ethconfig.Config
|
||||||
Node node.Config
|
Node node.Config
|
||||||
Ethstats ethstatsConfig
|
Ethstats ethstatsConfig
|
||||||
Metrics metrics.Config
|
Metrics metrics.Config
|
||||||
|
FakeBeacon fakebeacon.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfig(file string, cfg *gethConfig) error {
|
func loadConfig(file string, cfg *gethConfig) error {
|
||||||
@@ -193,6 +195,10 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
|
|||||||
v := ctx.Uint64(utils.OverrideBohr.Name)
|
v := ctx.Uint64(utils.OverrideBohr.Name)
|
||||||
cfg.Eth.OverrideBohr = &v
|
cfg.Eth.OverrideBohr = &v
|
||||||
}
|
}
|
||||||
|
if ctx.IsSet(utils.OverridePascal.Name) {
|
||||||
|
v := ctx.Uint64(utils.OverridePascal.Name)
|
||||||
|
cfg.Eth.OverridePascal = &v
|
||||||
|
}
|
||||||
if ctx.IsSet(utils.OverrideVerkle.Name) {
|
if ctx.IsSet(utils.OverrideVerkle.Name) {
|
||||||
v := ctx.Uint64(utils.OverrideVerkle.Name)
|
v := ctx.Uint64(utils.OverrideVerkle.Name)
|
||||||
cfg.Eth.OverrideVerkle = &v
|
cfg.Eth.OverrideVerkle = &v
|
||||||
@@ -242,11 +248,22 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
|
|||||||
utils.RegisterEthStatsService(stack, backend, cfg.Ethstats.URL)
|
utils.RegisterEthStatsService(stack, backend, cfg.Ethstats.URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.IsSet(utils.FakeBeaconAddrFlag.Name) {
|
||||||
|
cfg.FakeBeacon.Addr = ctx.String(utils.FakeBeaconAddrFlag.Name)
|
||||||
|
}
|
||||||
|
if ctx.IsSet(utils.FakeBeaconPortFlag.Name) {
|
||||||
|
cfg.FakeBeacon.Port = ctx.Int(utils.FakeBeaconPortFlag.Name)
|
||||||
|
}
|
||||||
|
if cfg.FakeBeacon.Enable || ctx.IsSet(utils.FakeBeaconEnabledFlag.Name) {
|
||||||
|
go fakebeacon.NewService(&cfg.FakeBeacon, backend).Run()
|
||||||
|
}
|
||||||
|
|
||||||
git, _ := version.VCS()
|
git, _ := version.VCS()
|
||||||
utils.SetupMetrics(ctx,
|
utils.SetupMetrics(ctx,
|
||||||
utils.EnableBuildInfo(git.Commit, git.Date),
|
utils.EnableBuildInfo(git.Commit, git.Date),
|
||||||
utils.EnableMinerInfo(ctx, &cfg.Eth.Miner),
|
utils.EnableMinerInfo(ctx, &cfg.Eth.Miner),
|
||||||
utils.EnableNodeInfo(&cfg.Eth.TxPool, stack.Server().NodeInfo()),
|
utils.EnableNodeInfo(&cfg.Eth.TxPool, stack.Server().NodeInfo()),
|
||||||
|
utils.EnableNodeTrack(ctx, &cfg.Eth, stack),
|
||||||
)
|
)
|
||||||
return stack, backend
|
return stack, backend
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ var (
|
|||||||
utils.RialtoHash,
|
utils.RialtoHash,
|
||||||
utils.OverridePassedForkTime,
|
utils.OverridePassedForkTime,
|
||||||
utils.OverrideBohr,
|
utils.OverrideBohr,
|
||||||
|
utils.OverridePascal,
|
||||||
utils.OverrideVerkle,
|
utils.OverrideVerkle,
|
||||||
utils.OverrideFullImmutabilityThreshold,
|
utils.OverrideFullImmutabilityThreshold,
|
||||||
utils.OverrideMinBlocksForBlobRequests,
|
utils.OverrideMinBlocksForBlobRequests,
|
||||||
@@ -232,6 +233,12 @@ var (
|
|||||||
utils.MetricsInfluxDBBucketFlag,
|
utils.MetricsInfluxDBBucketFlag,
|
||||||
utils.MetricsInfluxDBOrganizationFlag,
|
utils.MetricsInfluxDBOrganizationFlag,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fakeBeaconFlags = []cli.Flag{
|
||||||
|
utils.FakeBeaconEnabledFlag,
|
||||||
|
utils.FakeBeaconAddrFlag,
|
||||||
|
utils.FakeBeaconPortFlag,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
var app = flags.NewApp("the go-ethereum command line interface")
|
var app = flags.NewApp("the go-ethereum command line interface")
|
||||||
@@ -286,6 +293,7 @@ func init() {
|
|||||||
consoleFlags,
|
consoleFlags,
|
||||||
debug.Flags,
|
debug.Flags,
|
||||||
metricsFlags,
|
metricsFlags,
|
||||||
|
fakeBeaconFlags,
|
||||||
)
|
)
|
||||||
flags.AutoEnvVars(app.Flags, "GETH")
|
flags.AutoEnvVars(app.Flags, "GETH")
|
||||||
|
|
||||||
@@ -371,8 +379,6 @@ func geth(ctx *cli.Context) error {
|
|||||||
// it unlocks any requested accounts, and starts the RPC/IPC interfaces and the
|
// it unlocks any requested accounts, and starts the RPC/IPC interfaces and the
|
||||||
// miner.
|
// miner.
|
||||||
func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, isConsole bool) {
|
func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, isConsole bool) {
|
||||||
debug.Memsize.Add("node", stack)
|
|
||||||
|
|
||||||
// Start up the node itself
|
// Start up the node itself
|
||||||
utils.StartNode(ctx, stack, isConsole)
|
utils.StartNode(ctx, stack, isConsole)
|
||||||
|
|
||||||
@@ -445,22 +451,23 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, isCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start auxiliary services if enabled
|
// Start auxiliary services if enabled
|
||||||
|
ethBackend, ok := backend.(*eth.EthAPIBackend)
|
||||||
|
gasCeil := ethBackend.Miner().GasCeil()
|
||||||
|
if gasCeil > params.SystemTxsGas {
|
||||||
|
ethBackend.TxPool().SetMaxGas(gasCeil - params.SystemTxsGas)
|
||||||
|
}
|
||||||
if ctx.Bool(utils.MiningEnabledFlag.Name) {
|
if ctx.Bool(utils.MiningEnabledFlag.Name) {
|
||||||
// Mining only makes sense if a full Ethereum node is running
|
// Mining only makes sense if a full Ethereum node is running
|
||||||
if ctx.String(utils.SyncModeFlag.Name) == "light" {
|
if ctx.String(utils.SyncModeFlag.Name) == "light" {
|
||||||
utils.Fatalf("Light clients do not support mining")
|
utils.Fatalf("Light clients do not support mining")
|
||||||
}
|
}
|
||||||
ethBackend, ok := backend.(*eth.EthAPIBackend)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
utils.Fatalf("Ethereum service not running")
|
utils.Fatalf("Ethereum service not running")
|
||||||
}
|
}
|
||||||
// Set the gas price to the limits from the CLI and start mining
|
// Set the gas price to the limits from the CLI and start mining
|
||||||
gasprice := flags.GlobalBig(ctx, utils.MinerGasPriceFlag.Name)
|
gasprice := flags.GlobalBig(ctx, utils.MinerGasPriceFlag.Name)
|
||||||
ethBackend.TxPool().SetGasTip(gasprice)
|
ethBackend.TxPool().SetGasTip(gasprice)
|
||||||
gasCeil := ethBackend.Miner().GasCeil()
|
|
||||||
if gasCeil > params.SystemTxsGas {
|
|
||||||
ethBackend.TxPool().SetMaxGas(gasCeil - params.SystemTxsGas)
|
|
||||||
}
|
|
||||||
if err := ethBackend.StartMining(); err != nil {
|
if err := ethBackend.StartMining(); err != nil {
|
||||||
utils.Fatalf("Failed to start mining: %v", err)
|
utils.Fatalf("Failed to start mining: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/internal/version"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||||
|
"github.com/ethereum/go-ethereum/beacon/fakebeacon"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/fdlimit"
|
"github.com/ethereum/go-ethereum/common/fdlimit"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
@@ -307,7 +310,7 @@ var (
|
|||||||
}
|
}
|
||||||
OverridePassedForkTime = &cli.Uint64Flag{
|
OverridePassedForkTime = &cli.Uint64Flag{
|
||||||
Name: "override.passedforktime",
|
Name: "override.passedforktime",
|
||||||
Usage: "Manually specify the hard fork timestamp except the last one, overriding the bundled setting",
|
Usage: "Manually specify the hard fork timestamps which have passed on the mainnet, overriding the bundled setting",
|
||||||
Category: flags.EthCategory,
|
Category: flags.EthCategory,
|
||||||
}
|
}
|
||||||
OverrideBohr = &cli.Uint64Flag{
|
OverrideBohr = &cli.Uint64Flag{
|
||||||
@@ -315,6 +318,11 @@ var (
|
|||||||
Usage: "Manually specify the Bohr fork timestamp, overriding the bundled setting",
|
Usage: "Manually specify the Bohr fork timestamp, overriding the bundled setting",
|
||||||
Category: flags.EthCategory,
|
Category: flags.EthCategory,
|
||||||
}
|
}
|
||||||
|
OverridePascal = &cli.Uint64Flag{
|
||||||
|
Name: "override.pascal",
|
||||||
|
Usage: "Manually specify the Pascal fork timestamp, overriding the bundled setting",
|
||||||
|
Category: flags.EthCategory,
|
||||||
|
}
|
||||||
OverrideVerkle = &cli.Uint64Flag{
|
OverrideVerkle = &cli.Uint64Flag{
|
||||||
Name: "override.verkle",
|
Name: "override.verkle",
|
||||||
Usage: "Manually specify the Verkle fork timestamp, overriding the bundled setting",
|
Usage: "Manually specify the Verkle fork timestamp, overriding the bundled setting",
|
||||||
@@ -1146,6 +1154,25 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
|
|||||||
Value: params.DefaultExtraReserveForBlobRequests,
|
Value: params.DefaultExtraReserveForBlobRequests,
|
||||||
Category: flags.MiscCategory,
|
Category: flags.MiscCategory,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fake beacon
|
||||||
|
FakeBeaconEnabledFlag = &cli.BoolFlag{
|
||||||
|
Name: "fake-beacon",
|
||||||
|
Usage: "Enable the HTTP-RPC server of fake-beacon",
|
||||||
|
Category: flags.APICategory,
|
||||||
|
}
|
||||||
|
FakeBeaconAddrFlag = &cli.StringFlag{
|
||||||
|
Name: "fake-beacon.addr",
|
||||||
|
Usage: "HTTP-RPC server listening addr of fake-beacon",
|
||||||
|
Value: fakebeacon.DefaultAddr,
|
||||||
|
Category: flags.APICategory,
|
||||||
|
}
|
||||||
|
FakeBeaconPortFlag = &cli.IntFlag{
|
||||||
|
Name: "fake-beacon.port",
|
||||||
|
Usage: "HTTP-RPC server listening port of fake-beacon",
|
||||||
|
Value: fakebeacon.DefaultPort,
|
||||||
|
Category: flags.APICategory,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -2297,6 +2324,67 @@ func EnableNodeInfo(poolConfig *legacypool.Config, nodeInfo *p2p.NodeInfo) Setup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EnableNodeTrack(ctx *cli.Context, cfg *ethconfig.Config, stack *node.Node) SetupMetricsOption {
|
||||||
|
nodeInfo := stack.Server().NodeInfo()
|
||||||
|
return func() {
|
||||||
|
// register node info into metrics
|
||||||
|
metrics.NewRegisteredLabel("node-stats", nil).Mark(map[string]interface{}{
|
||||||
|
"NodeType": parseNodeType(),
|
||||||
|
"ENR": nodeInfo.ENR,
|
||||||
|
"Mining": ctx.Bool(MiningEnabledFlag.Name),
|
||||||
|
"Etherbase": parseEtherbase(cfg),
|
||||||
|
"MiningFeatures": parseMiningFeatures(ctx, cfg),
|
||||||
|
"DBFeatures": parseDBFeatures(cfg, stack),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseEtherbase(cfg *ethconfig.Config) string {
|
||||||
|
if cfg.Miner.Etherbase == (common.Address{}) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return cfg.Miner.Etherbase.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseNodeType() string {
|
||||||
|
git, _ := version.VCS()
|
||||||
|
version := []string{params.VersionWithMeta}
|
||||||
|
if len(git.Commit) >= 7 {
|
||||||
|
version = append(version, git.Commit[:7])
|
||||||
|
}
|
||||||
|
if git.Date != "" {
|
||||||
|
version = append(version, git.Date)
|
||||||
|
}
|
||||||
|
arch := []string{runtime.GOOS, runtime.GOARCH}
|
||||||
|
infos := []string{"BSC", strings.Join(version, "-"), strings.Join(arch, "-"), runtime.Version()}
|
||||||
|
return strings.Join(infos, "/")
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseDBFeatures(cfg *ethconfig.Config, stack *node.Node) string {
|
||||||
|
var features []string
|
||||||
|
if cfg.StateScheme == rawdb.PathScheme {
|
||||||
|
features = append(features, "PBSS")
|
||||||
|
}
|
||||||
|
if stack.CheckIfMultiDataBase() {
|
||||||
|
features = append(features, "MultiDB")
|
||||||
|
}
|
||||||
|
return strings.Join(features, "|")
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseMiningFeatures(ctx *cli.Context, cfg *ethconfig.Config) string {
|
||||||
|
if !ctx.Bool(MiningEnabledFlag.Name) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
var features []string
|
||||||
|
if cfg.Miner.Mev.Enabled {
|
||||||
|
features = append(features, "MEV")
|
||||||
|
}
|
||||||
|
if cfg.Miner.VoteEnable {
|
||||||
|
features = append(features, "FFVoting")
|
||||||
|
}
|
||||||
|
return strings.Join(features, "|")
|
||||||
|
}
|
||||||
|
|
||||||
func SetupMetrics(ctx *cli.Context, options ...SetupMetricsOption) {
|
func SetupMetrics(ctx *cli.Context, options ...SetupMetricsOption) {
|
||||||
if metrics.Enabled {
|
if metrics.Enabled {
|
||||||
log.Info("Enabling metrics collection")
|
log.Info("Enabling metrics collection")
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ var (
|
|||||||
blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil)
|
blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil)
|
||||||
blockReorgDropMeter = metrics.NewRegisteredMeter("chain/reorg/drop", nil)
|
blockReorgDropMeter = metrics.NewRegisteredMeter("chain/reorg/drop", nil)
|
||||||
|
|
||||||
|
blockRecvTimeDiffGauge = metrics.NewRegisteredGauge("chain/block/recvtimediff", nil)
|
||||||
|
|
||||||
errStateRootVerificationFailed = errors.New("state root verification failed")
|
errStateRootVerificationFailed = errors.New("state root verification failed")
|
||||||
errInsertionInterrupted = errors.New("insertion is interrupted")
|
errInsertionInterrupted = errors.New("insertion is interrupted")
|
||||||
errChainStopped = errors.New("blockchain is stopped")
|
errChainStopped = errors.New("blockchain is stopped")
|
||||||
@@ -1803,7 +1805,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
|
|||||||
}
|
}
|
||||||
bc.hc.tdCache.Add(block.Hash(), externTd)
|
bc.hc.tdCache.Add(block.Hash(), externTd)
|
||||||
bc.blockCache.Add(block.Hash(), block)
|
bc.blockCache.Add(block.Hash(), block)
|
||||||
bc.receiptsCache.Add(block.Hash(), receipts)
|
bc.cacheReceipts(block.Hash(), receipts, block)
|
||||||
if bc.chainConfig.IsCancun(block.Number(), block.Time()) {
|
if bc.chainConfig.IsCancun(block.Number(), block.Time()) {
|
||||||
bc.sidecarsCache.Add(block.Hash(), block.Sidecars())
|
bc.sidecarsCache.Add(block.Hash(), block.Sidecars())
|
||||||
}
|
}
|
||||||
@@ -2055,6 +2057,9 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
|
|||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(chain) > 0 {
|
||||||
|
blockRecvTimeDiffGauge.Update(time.Now().Unix() - int64(chain[0].Time()))
|
||||||
|
}
|
||||||
// Start a parallel signature recovery (signer will fluke on fork transition, minimal perf loss)
|
// Start a parallel signature recovery (signer will fluke on fork transition, minimal perf loss)
|
||||||
signer := types.MakeSigner(bc.chainConfig, chain[0].Number(), chain[0].Time())
|
signer := types.MakeSigner(bc.chainConfig, chain[0].Number(), chain[0].Time())
|
||||||
go SenderCacher.RecoverFromBlocks(signer, chain)
|
go SenderCacher.RecoverFromBlocks(signer, chain)
|
||||||
@@ -2320,8 +2325,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
|
|||||||
return it.index, err
|
return it.index, err
|
||||||
}
|
}
|
||||||
|
|
||||||
bc.cacheReceipts(block.Hash(), receipts, block)
|
|
||||||
|
|
||||||
// Update the metrics touched during block commit
|
// Update the metrics touched during block commit
|
||||||
accountCommitTimer.Update(statedb.AccountCommits) // Account commits are complete, we can mark them
|
accountCommitTimer.Update(statedb.AccountCommits) // Account commits are complete, we can mark them
|
||||||
storageCommitTimer.Update(statedb.StorageCommits) // Storage commits are complete, we can mark them
|
storageCommitTimer.Update(statedb.StorageCommits) // Storage commits are complete, we can mark them
|
||||||
|
|||||||
@@ -121,12 +121,19 @@ func (f *ForkChoice) ReorgNeeded(current *types.Header, extern *types.Header) (b
|
|||||||
if f.preserve != nil {
|
if f.preserve != nil {
|
||||||
currentPreserve, externPreserve = f.preserve(current), f.preserve(extern)
|
currentPreserve, externPreserve = f.preserve(current), f.preserve(extern)
|
||||||
}
|
}
|
||||||
doubleSign := (extern.Coinbase == current.Coinbase)
|
choiceRules := func() bool {
|
||||||
reorg = !currentPreserve && (externPreserve ||
|
if extern.Time == current.Time {
|
||||||
extern.Time < current.Time ||
|
doubleSign := (extern.Coinbase == current.Coinbase)
|
||||||
extern.Time == current.Time &&
|
if doubleSign {
|
||||||
((doubleSign && extern.Hash().Cmp(current.Hash()) < 0) ||
|
return extern.Hash().Cmp(current.Hash()) < 0
|
||||||
(!doubleSign && f.rand.Float64() < 0.5)))
|
} else {
|
||||||
|
return f.rand.Float64() < 0.5
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return extern.Time < current.Time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reorg = !currentPreserve && (externPreserve || choiceRules())
|
||||||
}
|
}
|
||||||
return reorg, nil
|
return reorg, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ func (e *GenesisMismatchError) Error() string {
|
|||||||
type ChainOverrides struct {
|
type ChainOverrides struct {
|
||||||
OverridePassedForkTime *uint64
|
OverridePassedForkTime *uint64
|
||||||
OverrideBohr *uint64
|
OverrideBohr *uint64
|
||||||
|
OverridePascal *uint64
|
||||||
OverrideVerkle *uint64
|
OverrideVerkle *uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,6 +257,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
|
|||||||
if overrides != nil && overrides.OverrideBohr != nil {
|
if overrides != nil && overrides.OverrideBohr != nil {
|
||||||
config.BohrTime = overrides.OverrideBohr
|
config.BohrTime = overrides.OverrideBohr
|
||||||
}
|
}
|
||||||
|
if overrides != nil && overrides.OverridePascal != nil {
|
||||||
|
config.PascalTime = overrides.OverridePascal
|
||||||
|
}
|
||||||
if overrides != nil && overrides.OverrideVerkle != nil {
|
if overrides != nil && overrides.OverrideVerkle != nil {
|
||||||
config.VerkleTime = overrides.OverrideVerkle
|
config.VerkleTime = overrides.OverrideVerkle
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ func newPrunedFreezer(datadir string, db ethdb.KeyValueStore, offset uint64) (*p
|
|||||||
|
|
||||||
// repair init frozen , compatible disk-ancientdb and pruner-block-tool.
|
// repair init frozen , compatible disk-ancientdb and pruner-block-tool.
|
||||||
func (f *prunedfreezer) repair(datadir string) error {
|
func (f *prunedfreezer) repair(datadir string) error {
|
||||||
|
offset := atomic.LoadUint64(&f.frozen)
|
||||||
// compatible freezer
|
// compatible freezer
|
||||||
minItems := uint64(math.MaxUint64)
|
minItems := uint64(math.MaxUint64)
|
||||||
for name, disableSnappy := range chainFreezerNoSnappy {
|
for name, disableSnappy := range chainFreezerNoSnappy {
|
||||||
@@ -96,19 +97,14 @@ func (f *prunedfreezer) repair(datadir string) error {
|
|||||||
table.Close()
|
table.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If minItems is non-zero, it indicates that the chain freezer was previously enabled, and we should use minItems as the current frozen value.
|
// If the dataset has undergone a prune block, the offset is a non-zero value, otherwise the offset is a zero value.
|
||||||
// If minItems is zero, it indicates that the pruneAncient was previously enabled, and we should continue using frozen
|
// The minItems is the value relative to offset
|
||||||
// (retrieved from CurrentAncientFreezer) as the current frozen value.
|
offset += minItems
|
||||||
offset := minItems
|
|
||||||
if offset == 0 {
|
|
||||||
// no item in ancientDB, init `offset` to the `f.frozen`
|
|
||||||
offset = atomic.LoadUint64(&f.frozen)
|
|
||||||
}
|
|
||||||
log.Info("Read ancientdb item counts", "items", minItems, "offset", offset)
|
|
||||||
|
|
||||||
// FrozenOfAncientFreezer is the progress of the last prune-freezer freeze.
|
// FrozenOfAncientFreezer is the progress of the last prune-freezer freeze.
|
||||||
frozenInDB := ReadFrozenOfAncientFreezer(f.db)
|
frozenInDB := ReadFrozenOfAncientFreezer(f.db)
|
||||||
maxOffset := max(offset, frozenInDB)
|
maxOffset := max(offset, frozenInDB)
|
||||||
|
log.Info("Read ancient db item counts", "items", minItems, "frozen", maxOffset)
|
||||||
|
|
||||||
atomic.StoreUint64(&f.frozen, maxOffset)
|
atomic.StoreUint64(&f.frozen, maxOffset)
|
||||||
if err := f.Sync(); err != nil {
|
if err := f.Sync(); err != nil {
|
||||||
@@ -161,12 +157,12 @@ func (f *prunedfreezer) AncientOffSet() uint64 {
|
|||||||
|
|
||||||
// MigrateTable processes the entries in a given table in sequence
|
// MigrateTable processes the entries in a given table in sequence
|
||||||
// converting them to a new format if they're of an old format.
|
// converting them to a new format if they're of an old format.
|
||||||
func (db *prunedfreezer) MigrateTable(kind string, convert convertLegacyFn) error {
|
func (f *prunedfreezer) MigrateTable(kind string, convert convertLegacyFn) error {
|
||||||
return errNotSupported
|
return errNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
// AncientDatadir returns an error as we don't have a backing chain freezer.
|
// AncientDatadir returns an error as we don't have a backing chain freezer.
|
||||||
func (db *prunedfreezer) AncientDatadir() (string, error) {
|
func (f *prunedfreezer) AncientDatadir() (string, error) {
|
||||||
return "", errNotSupported
|
return "", errNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
core/systemcontracts/pascal/chapel/CrossChainContract
Normal file
1
core/systemcontracts/pascal/chapel/CrossChainContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/GovHubContract
Normal file
1
core/systemcontracts/pascal/chapel/GovHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/GovTokenContract
Normal file
1
core/systemcontracts/pascal/chapel/GovTokenContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/GovernorContract
Normal file
1
core/systemcontracts/pascal/chapel/GovernorContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/LightClientContract
Normal file
1
core/systemcontracts/pascal/chapel/LightClientContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/RelayerHubContract
Normal file
1
core/systemcontracts/pascal/chapel/RelayerHubContract
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/SlashContract
Normal file
1
core/systemcontracts/pascal/chapel/SlashContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/StakeCreditContract
Normal file
1
core/systemcontracts/pascal/chapel/StakeCreditContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/StakeHubContract
Normal file
1
core/systemcontracts/pascal/chapel/StakeHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/StakingContract
Normal file
1
core/systemcontracts/pascal/chapel/StakingContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/SystemRewardContract
Normal file
1
core/systemcontracts/pascal/chapel/SystemRewardContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/TimelockContract
Normal file
1
core/systemcontracts/pascal/chapel/TimelockContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/TokenHubContract
Normal file
1
core/systemcontracts/pascal/chapel/TokenHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/TokenManagerContract
Normal file
1
core/systemcontracts/pascal/chapel/TokenManagerContract
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/chapel/ValidatorContract
Normal file
1
core/systemcontracts/pascal/chapel/ValidatorContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/CrossChainContract
Normal file
1
core/systemcontracts/pascal/mainnet/CrossChainContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/GovHubContract
Normal file
1
core/systemcontracts/pascal/mainnet/GovHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/GovTokenContract
Normal file
1
core/systemcontracts/pascal/mainnet/GovTokenContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/GovernorContract
Normal file
1
core/systemcontracts/pascal/mainnet/GovernorContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/LightClientContract
Normal file
1
core/systemcontracts/pascal/mainnet/LightClientContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/RelayerHubContract
Normal file
1
core/systemcontracts/pascal/mainnet/RelayerHubContract
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/SlashContract
Normal file
1
core/systemcontracts/pascal/mainnet/SlashContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/StakeCreditContract
Normal file
1
core/systemcontracts/pascal/mainnet/StakeCreditContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/StakeHubContract
Normal file
1
core/systemcontracts/pascal/mainnet/StakeHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/StakingContract
Normal file
1
core/systemcontracts/pascal/mainnet/StakingContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/SystemRewardContract
Normal file
1
core/systemcontracts/pascal/mainnet/SystemRewardContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/TimelockContract
Normal file
1
core/systemcontracts/pascal/mainnet/TimelockContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/TokenHubContract
Normal file
1
core/systemcontracts/pascal/mainnet/TokenHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/TokenManagerContract
Normal file
1
core/systemcontracts/pascal/mainnet/TokenManagerContract
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/mainnet/ValidatorContract
Normal file
1
core/systemcontracts/pascal/mainnet/ValidatorContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/CrossChainContract
Normal file
1
core/systemcontracts/pascal/rialto/CrossChainContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/GovHubContract
Normal file
1
core/systemcontracts/pascal/rialto/GovHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/GovTokenContract
Normal file
1
core/systemcontracts/pascal/rialto/GovTokenContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/GovernorContract
Normal file
1
core/systemcontracts/pascal/rialto/GovernorContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/LightClientContract
Normal file
1
core/systemcontracts/pascal/rialto/LightClientContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/RelayerHubContract
Normal file
1
core/systemcontracts/pascal/rialto/RelayerHubContract
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/SlashContract
Normal file
1
core/systemcontracts/pascal/rialto/SlashContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/StakeCreditContract
Normal file
1
core/systemcontracts/pascal/rialto/StakeCreditContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/StakeHubContract
Normal file
1
core/systemcontracts/pascal/rialto/StakeHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/StakingContract
Normal file
1
core/systemcontracts/pascal/rialto/StakingContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/SystemRewardContract
Normal file
1
core/systemcontracts/pascal/rialto/SystemRewardContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/TimelockContract
Normal file
1
core/systemcontracts/pascal/rialto/TimelockContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/TokenHubContract
Normal file
1
core/systemcontracts/pascal/rialto/TokenHubContract
Normal file
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/TokenManagerContract
Normal file
1
core/systemcontracts/pascal/rialto/TokenManagerContract
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
core/systemcontracts/pascal/rialto/ValidatorContract
Normal file
1
core/systemcontracts/pascal/rialto/ValidatorContract
Normal file
File diff suppressed because one or more lines are too long
168
core/systemcontracts/pascal/types.go
Normal file
168
core/systemcontracts/pascal/types.go
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
package pascal
|
||||||
|
|
||||||
|
import _ "embed"
|
||||||
|
|
||||||
|
// contract codes for Mainnet upgrade
|
||||||
|
var (
|
||||||
|
|
||||||
|
//go:embed mainnet/ValidatorContract
|
||||||
|
MainnetValidatorContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/SlashContract
|
||||||
|
MainnetSlashContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/SystemRewardContract
|
||||||
|
MainnetSystemRewardContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/LightClientContract
|
||||||
|
MainnetLightClientContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/TokenHubContract
|
||||||
|
MainnetTokenHubContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/RelayerIncentivizeContract
|
||||||
|
MainnetRelayerIncentivizeContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/RelayerHubContract
|
||||||
|
MainnetRelayerHubContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/GovHubContract
|
||||||
|
MainnetGovHubContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/TokenManagerContract
|
||||||
|
MainnetTokenManagerContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/CrossChainContract
|
||||||
|
MainnetCrossChainContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/StakingContract
|
||||||
|
MainnetStakingContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/StakeHubContract
|
||||||
|
MainnetStakeHubContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/StakeCreditContract
|
||||||
|
MainnetStakeCreditContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/GovernorContract
|
||||||
|
MainnetGovernorContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/GovTokenContract
|
||||||
|
MainnetGovTokenContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/TimelockContract
|
||||||
|
MainnetTimelockContract string
|
||||||
|
|
||||||
|
//go:embed mainnet/TokenRecoverPortalContract
|
||||||
|
MainnetTokenRecoverPortalContract string
|
||||||
|
)
|
||||||
|
|
||||||
|
// contract codes for Chapel upgrade
|
||||||
|
var (
|
||||||
|
|
||||||
|
//go:embed chapel/ValidatorContract
|
||||||
|
ChapelValidatorContract string
|
||||||
|
|
||||||
|
//go:embed chapel/SlashContract
|
||||||
|
ChapelSlashContract string
|
||||||
|
|
||||||
|
//go:embed chapel/SystemRewardContract
|
||||||
|
ChapelSystemRewardContract string
|
||||||
|
|
||||||
|
//go:embed chapel/LightClientContract
|
||||||
|
ChapelLightClientContract string
|
||||||
|
|
||||||
|
//go:embed chapel/TokenHubContract
|
||||||
|
ChapelTokenHubContract string
|
||||||
|
|
||||||
|
//go:embed chapel/RelayerIncentivizeContract
|
||||||
|
ChapelRelayerIncentivizeContract string
|
||||||
|
|
||||||
|
//go:embed chapel/RelayerHubContract
|
||||||
|
ChapelRelayerHubContract string
|
||||||
|
|
||||||
|
//go:embed chapel/GovHubContract
|
||||||
|
ChapelGovHubContract string
|
||||||
|
|
||||||
|
//go:embed chapel/TokenManagerContract
|
||||||
|
ChapelTokenManagerContract string
|
||||||
|
|
||||||
|
//go:embed chapel/CrossChainContract
|
||||||
|
ChapelCrossChainContract string
|
||||||
|
|
||||||
|
//go:embed chapel/StakingContract
|
||||||
|
ChapelStakingContract string
|
||||||
|
|
||||||
|
//go:embed chapel/StakeHubContract
|
||||||
|
ChapelStakeHubContract string
|
||||||
|
|
||||||
|
//go:embed chapel/StakeCreditContract
|
||||||
|
ChapelStakeCreditContract string
|
||||||
|
|
||||||
|
//go:embed chapel/GovernorContract
|
||||||
|
ChapelGovernorContract string
|
||||||
|
|
||||||
|
//go:embed chapel/GovTokenContract
|
||||||
|
ChapelGovTokenContract string
|
||||||
|
|
||||||
|
//go:embed chapel/TimelockContract
|
||||||
|
ChapelTimelockContract string
|
||||||
|
|
||||||
|
//go:embed chapel/TokenRecoverPortalContract
|
||||||
|
ChapelTokenRecoverPortalContract string
|
||||||
|
)
|
||||||
|
|
||||||
|
// contract codes for Rialto upgrade
|
||||||
|
var (
|
||||||
|
|
||||||
|
//go:embed rialto/ValidatorContract
|
||||||
|
RialtoValidatorContract string
|
||||||
|
|
||||||
|
//go:embed rialto/SlashContract
|
||||||
|
RialtoSlashContract string
|
||||||
|
|
||||||
|
//go:embed rialto/SystemRewardContract
|
||||||
|
RialtoSystemRewardContract string
|
||||||
|
|
||||||
|
//go:embed rialto/LightClientContract
|
||||||
|
RialtoLightClientContract string
|
||||||
|
|
||||||
|
//go:embed rialto/TokenHubContract
|
||||||
|
RialtoTokenHubContract string
|
||||||
|
|
||||||
|
//go:embed rialto/RelayerIncentivizeContract
|
||||||
|
RialtoRelayerIncentivizeContract string
|
||||||
|
|
||||||
|
//go:embed rialto/RelayerHubContract
|
||||||
|
RialtoRelayerHubContract string
|
||||||
|
|
||||||
|
//go:embed rialto/GovHubContract
|
||||||
|
RialtoGovHubContract string
|
||||||
|
|
||||||
|
//go:embed rialto/TokenManagerContract
|
||||||
|
RialtoTokenManagerContract string
|
||||||
|
|
||||||
|
//go:embed rialto/CrossChainContract
|
||||||
|
RialtoCrossChainContract string
|
||||||
|
|
||||||
|
//go:embed rialto/StakingContract
|
||||||
|
RialtoStakingContract string
|
||||||
|
|
||||||
|
//go:embed rialto/StakeHubContract
|
||||||
|
RialtoStakeHubContract string
|
||||||
|
|
||||||
|
//go:embed rialto/StakeCreditContract
|
||||||
|
RialtoStakeCreditContract string
|
||||||
|
|
||||||
|
//go:embed rialto/GovernorContract
|
||||||
|
RialtoGovernorContract string
|
||||||
|
|
||||||
|
//go:embed rialto/GovTokenContract
|
||||||
|
RialtoGovTokenContract string
|
||||||
|
|
||||||
|
//go:embed rialto/TimelockContract
|
||||||
|
RialtoTimelockContract string
|
||||||
|
|
||||||
|
//go:embed rialto/TokenRecoverPortalContract
|
||||||
|
RialtoTokenRecoverPortalContract string
|
||||||
|
)
|
||||||
@@ -4,10 +4,10 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/bohr"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/bohr"
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/bruno"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/bruno"
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/euler"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/euler"
|
||||||
@@ -20,9 +20,11 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/mirror"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/mirror"
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/moran"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/moran"
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/niels"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/niels"
|
||||||
|
"github.com/ethereum/go-ethereum/core/systemcontracts/pascal"
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/planck"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/planck"
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/plato"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/plato"
|
||||||
"github.com/ethereum/go-ethereum/core/systemcontracts/ramanujan"
|
"github.com/ethereum/go-ethereum/core/systemcontracts/ramanujan"
|
||||||
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
@@ -40,7 +42,7 @@ type Upgrade struct {
|
|||||||
Configs []*UpgradeConfig
|
Configs []*UpgradeConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type upgradeHook func(blockNumber *big.Int, contractAddr common.Address, statedb *state.StateDB) error
|
type upgradeHook func(blockNumber *big.Int, contractAddr common.Address, statedb vm.StateDB) error
|
||||||
|
|
||||||
const (
|
const (
|
||||||
mainNet = "Mainnet"
|
mainNet = "Mainnet"
|
||||||
@@ -81,6 +83,8 @@ var (
|
|||||||
haberFixUpgrade = make(map[string]*Upgrade)
|
haberFixUpgrade = make(map[string]*Upgrade)
|
||||||
|
|
||||||
bohrUpgrade = make(map[string]*Upgrade)
|
bohrUpgrade = make(map[string]*Upgrade)
|
||||||
|
|
||||||
|
pascalUpgrade = make(map[string]*Upgrade)
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -787,12 +791,286 @@ func init() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pascalUpgrade[mainNet] = &Upgrade{
|
||||||
|
UpgradeName: "pascal",
|
||||||
|
Configs: []*UpgradeConfig{
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(ValidatorContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetValidatorContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(SlashContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetSlashContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(SystemRewardContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetSystemRewardContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(LightClientContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetLightClientContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetTokenHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(RelayerIncentivizeContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetRelayerIncentivizeContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(RelayerHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetRelayerHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetGovHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenManagerContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetTokenManagerContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(CrossChainContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetCrossChainContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakingContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetStakingContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakeHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetStakeHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakeCreditContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetStakeCreditContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovernorContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetGovernorContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovTokenContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetGovTokenContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TimelockContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetTimelockContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenRecoverPortalContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.MainnetTokenRecoverPortalContract,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
pascalUpgrade[chapelNet] = &Upgrade{
|
||||||
|
UpgradeName: "pascal",
|
||||||
|
Configs: []*UpgradeConfig{
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(ValidatorContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelValidatorContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(SlashContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelSlashContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(SystemRewardContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelSystemRewardContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(LightClientContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelLightClientContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelTokenHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(RelayerIncentivizeContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelRelayerIncentivizeContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(RelayerHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelRelayerHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelGovHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenManagerContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelTokenManagerContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(CrossChainContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelCrossChainContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakingContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelStakingContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakeHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelStakeHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakeCreditContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelStakeCreditContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovernorContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelGovernorContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovTokenContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelGovTokenContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TimelockContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelTimelockContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenRecoverPortalContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.ChapelTokenRecoverPortalContract,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
pascalUpgrade[rialtoNet] = &Upgrade{
|
||||||
|
UpgradeName: "pascal",
|
||||||
|
Configs: []*UpgradeConfig{
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(ValidatorContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoValidatorContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(SlashContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoSlashContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(SystemRewardContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoSystemRewardContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(LightClientContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoLightClientContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoTokenHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(RelayerIncentivizeContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoRelayerIncentivizeContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(RelayerHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoRelayerHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoGovHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenManagerContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoTokenManagerContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(CrossChainContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoCrossChainContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakingContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoStakingContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakeHubContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoStakeHubContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(StakeCreditContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoStakeCreditContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovernorContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoGovernorContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(GovTokenContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoGovTokenContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TimelockContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoTimelockContract,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddr: common.HexToAddress(TokenRecoverPortalContract),
|
||||||
|
CommitUrl: "https://github.com/bnb-chain/bsc-genesis-contract/commit/4c03f8222f8ac13e3b6bd424e1235698282bb28d",
|
||||||
|
Code: pascal.RialtoTokenRecoverPortalContract,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpgradeBuildInSystemContract(config *params.ChainConfig, blockNumber *big.Int, lastBlockTime uint64, blockTime uint64, statedb *state.StateDB) {
|
func UpgradeBuildInSystemContract(config *params.ChainConfig, blockNumber *big.Int, lastBlockTime uint64, blockTime uint64, statedb vm.StateDB) {
|
||||||
if config == nil || blockNumber == nil || statedb == nil {
|
if config == nil || blockNumber == nil || statedb == nil || reflect.ValueOf(statedb).IsNil() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var network string
|
var network string
|
||||||
switch GenesisHash {
|
switch GenesisHash {
|
||||||
/* Add mainnet genesis hash */
|
/* Add mainnet genesis hash */
|
||||||
@@ -871,12 +1149,16 @@ func UpgradeBuildInSystemContract(config *params.ChainConfig, blockNumber *big.I
|
|||||||
applySystemContractUpgrade(bohrUpgrade[network], blockNumber, statedb, logger)
|
applySystemContractUpgrade(bohrUpgrade[network], blockNumber, statedb, logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.IsOnPascal(blockNumber, lastBlockTime, blockTime) {
|
||||||
|
applySystemContractUpgrade(pascalUpgrade[network], blockNumber, statedb, logger)
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
apply other upgrades
|
apply other upgrades
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
func applySystemContractUpgrade(upgrade *Upgrade, blockNumber *big.Int, statedb *state.StateDB, logger log.Logger) {
|
func applySystemContractUpgrade(upgrade *Upgrade, blockNumber *big.Int, statedb vm.StateDB, logger log.Logger) {
|
||||||
if upgrade == nil {
|
if upgrade == nil {
|
||||||
logger.Info("Empty upgrade config", "height", blockNumber.String())
|
logger.Info("Empty upgrade config", "height", blockNumber.String())
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -2,9 +2,13 @@ package systemcontracts
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -39,3 +43,31 @@ func TestAllCodesHash(t *testing.T) {
|
|||||||
allCodeHash := sha256.Sum256(allCodes)
|
allCodeHash := sha256.Sum256(allCodes)
|
||||||
require.Equal(t, allCodeHash[:], common.Hex2Bytes("833cc0fc87c46ad8a223e44ccfdc16a51a7e7383525136441bd0c730f06023df"))
|
require.Equal(t, allCodeHash[:], common.Hex2Bytes("833cc0fc87c46ad8a223e44ccfdc16a51a7e7383525136441bd0c730f06023df"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUpgradeBuildInSystemContractNilInterface(t *testing.T) {
|
||||||
|
var (
|
||||||
|
config = params.BSCChainConfig
|
||||||
|
blockNumber = big.NewInt(37959559)
|
||||||
|
lastBlockTime uint64 = 1713419337
|
||||||
|
blockTime uint64 = 1713419340
|
||||||
|
statedb vm.StateDB
|
||||||
|
)
|
||||||
|
|
||||||
|
GenesisHash = params.BSCGenesisHash
|
||||||
|
|
||||||
|
UpgradeBuildInSystemContract(config, blockNumber, lastBlockTime, blockTime, statedb)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpgradeBuildInSystemContractNilValue(t *testing.T) {
|
||||||
|
var (
|
||||||
|
config = params.BSCChainConfig
|
||||||
|
blockNumber = big.NewInt(37959559)
|
||||||
|
lastBlockTime uint64 = 1713419337
|
||||||
|
blockTime uint64 = 1713419340
|
||||||
|
statedb vm.StateDB = (*state.StateDB)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
GenesisHash = params.BSCGenesisHash
|
||||||
|
|
||||||
|
UpgradeBuildInSystemContract(config, blockNumber, lastBlockTime, blockTime, statedb)
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package types
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -53,3 +55,40 @@ func (s *BlobSidecar) SanityCheck(blockNumber *big.Int, blockHash common.Hash) e
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *BlobSidecar) MarshalJSON() ([]byte, error) {
|
||||||
|
fields := map[string]interface{}{
|
||||||
|
"blockHash": s.BlockHash,
|
||||||
|
"blockNumber": hexutil.EncodeUint64(s.BlockNumber.Uint64()),
|
||||||
|
"txHash": s.TxHash,
|
||||||
|
"txIndex": hexutil.EncodeUint64(s.TxIndex),
|
||||||
|
}
|
||||||
|
fields["blobSidecar"] = s.BlobTxSidecar
|
||||||
|
return json.Marshal(fields)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *BlobSidecar) UnmarshalJSON(input []byte) error {
|
||||||
|
type blobSidecar struct {
|
||||||
|
BlobSidecar BlobTxSidecar `json:"blobSidecar"`
|
||||||
|
BlockNumber *hexutil.Big `json:"blockNumber"`
|
||||||
|
BlockHash common.Hash `json:"blockHash"`
|
||||||
|
TxIndex *hexutil.Big `json:"txIndex"`
|
||||||
|
TxHash common.Hash `json:"txHash"`
|
||||||
|
}
|
||||||
|
var blob blobSidecar
|
||||||
|
if err := json.Unmarshal(input, &blob); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
s.BlobTxSidecar = blob.BlobSidecar
|
||||||
|
if blob.BlockNumber == nil {
|
||||||
|
return errors.New("missing required field 'blockNumber' for BlobSidecar")
|
||||||
|
}
|
||||||
|
s.BlockNumber = blob.BlockNumber.ToInt()
|
||||||
|
s.BlockHash = blob.BlockHash
|
||||||
|
if blob.TxIndex == nil {
|
||||||
|
return errors.New("missing required field 'txIndex' for BlobSidecar")
|
||||||
|
}
|
||||||
|
s.TxIndex = blob.TxIndex.ToInt().Uint64()
|
||||||
|
s.TxHash = blob.TxHash
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -441,14 +441,14 @@ func (b *EthAPIBackend) Engine() consensus.Engine {
|
|||||||
return b.eth.engine
|
return b.eth.engine
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EthAPIBackend) CurrentTurnLength() (turnLength uint8, err error) {
|
func (b *EthAPIBackend) CurrentValidators() ([]common.Address, error) {
|
||||||
if p, ok := b.eth.engine.(*parlia.Parlia); ok {
|
if p, ok := b.eth.engine.(*parlia.Parlia); ok {
|
||||||
service := p.APIs(b.Chain())[0].Service
|
service := p.APIs(b.Chain())[0].Service
|
||||||
currentHead := rpc.LatestBlockNumber
|
currentHead := rpc.LatestBlockNumber
|
||||||
return service.(*parlia.API).GetTurnLength(¤tHead)
|
return service.(*parlia.API).GetValidators(¤tHead)
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1, nil
|
return []common.Address{}, errors.New("not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *EthAPIBackend) CurrentHeader() *types.Header {
|
func (b *EthAPIBackend) CurrentHeader() *types.Header {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ func (api *MinerAPI) SetGasPrice(gasPrice hexutil.Big) bool {
|
|||||||
// SetGasLimit sets the gaslimit to target towards during mining.
|
// SetGasLimit sets the gaslimit to target towards during mining.
|
||||||
func (api *MinerAPI) SetGasLimit(gasLimit hexutil.Uint64) bool {
|
func (api *MinerAPI) SetGasLimit(gasLimit hexutil.Uint64) bool {
|
||||||
api.e.Miner().SetGasCeil(uint64(gasLimit))
|
api.e.Miner().SetGasCeil(uint64(gasLimit))
|
||||||
if api.e.Miner().Mining() && uint64(gasLimit) > params.SystemTxsGas {
|
if uint64(gasLimit) > params.SystemTxsGas {
|
||||||
api.e.TxPool().SetMaxGas(uint64(gasLimit) - params.SystemTxsGas)
|
api.e.TxPool().SetMaxGas(uint64(gasLimit) - params.SystemTxsGas)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -199,6 +199,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||||||
chainConfig.BohrTime = config.OverrideBohr
|
chainConfig.BohrTime = config.OverrideBohr
|
||||||
overrides.OverrideBohr = config.OverrideBohr
|
overrides.OverrideBohr = config.OverrideBohr
|
||||||
}
|
}
|
||||||
|
if config.OverridePascal != nil {
|
||||||
|
chainConfig.PascalTime = config.OverridePascal
|
||||||
|
overrides.OverridePascal = config.OverridePascal
|
||||||
|
}
|
||||||
if config.OverrideVerkle != nil {
|
if config.OverrideVerkle != nil {
|
||||||
chainConfig.VerkleTime = config.OverrideVerkle
|
chainConfig.VerkleTime = config.OverrideVerkle
|
||||||
overrides.OverrideVerkle = config.OverrideVerkle
|
overrides.OverrideVerkle = config.OverrideVerkle
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ func (d *Downloader) UnregisterPeer(id string) error {
|
|||||||
|
|
||||||
// LegacySync tries to sync up our local blockchain with a remote peer, both
|
// LegacySync tries to sync up our local blockchain with a remote peer, both
|
||||||
// adding various sanity checks and wrapping it with various log entries.
|
// adding various sanity checks and wrapping it with various log entries.
|
||||||
func (d *Downloader) LegacySync(id string, head common.Hash, td *big.Int, ttd *big.Int, mode SyncMode) error {
|
func (d *Downloader) LegacySync(id string, head common.Hash, name string, td *big.Int, ttd *big.Int, mode SyncMode) error {
|
||||||
err := d.synchronise(id, head, td, ttd, mode, false, nil)
|
err := d.synchronise(id, head, td, ttd, mode, false, nil)
|
||||||
|
|
||||||
switch err {
|
switch err {
|
||||||
@@ -337,7 +337,7 @@ func (d *Downloader) LegacySync(id string, head common.Hash, td *big.Int, ttd *b
|
|||||||
if errors.Is(err, errInvalidChain) || errors.Is(err, errBadPeer) || errors.Is(err, errTimeout) ||
|
if errors.Is(err, errInvalidChain) || errors.Is(err, errBadPeer) || errors.Is(err, errTimeout) ||
|
||||||
errors.Is(err, errStallingPeer) || errors.Is(err, errUnsyncedPeer) || errors.Is(err, errEmptyHeaderSet) ||
|
errors.Is(err, errStallingPeer) || errors.Is(err, errUnsyncedPeer) || errors.Is(err, errEmptyHeaderSet) ||
|
||||||
errors.Is(err, errPeersUnavailable) || errors.Is(err, errTooOld) || errors.Is(err, errInvalidAncestor) {
|
errors.Is(err, errPeersUnavailable) || errors.Is(err, errTooOld) || errors.Is(err, errInvalidAncestor) {
|
||||||
log.Warn("Synchronisation failed, dropping peer", "peer", id, "err", err)
|
log.Warn("Synchronisation failed, dropping peer", "peer", id, "name", name, "td", td, "err", err)
|
||||||
if d.dropPeer == nil {
|
if d.dropPeer == nil {
|
||||||
// The dropPeer method is nil when `--copydb` is used for a local copy.
|
// The dropPeer method is nil when `--copydb` is used for a local copy.
|
||||||
// Timeouts can occur if e.g. compaction hits at the wrong time, and can be ignored
|
// Timeouts can occur if e.g. compaction hits at the wrong time, and can be ignored
|
||||||
|
|||||||
@@ -902,7 +902,7 @@ func testBlockHeaderAttackerDropping(t *testing.T, protocol uint) {
|
|||||||
// Simulate a synchronisation and check the required result
|
// Simulate a synchronisation and check the required result
|
||||||
tester.downloader.synchroniseMock = func(string, common.Hash) error { return tt.result }
|
tester.downloader.synchroniseMock = func(string, common.Hash) error { return tt.result }
|
||||||
|
|
||||||
tester.downloader.LegacySync(id, tester.chain.Genesis().Hash(), big.NewInt(1000), nil, FullSync)
|
tester.downloader.LegacySync(id, tester.chain.Genesis().Hash(), "", big.NewInt(1000), nil, FullSync)
|
||||||
if _, ok := tester.peers[id]; !ok != tt.drop {
|
if _, ok := tester.peers[id]; !ok != tt.drop {
|
||||||
t.Errorf("test %d: peer drop mismatch for %v: have %v, want %v", i, tt.result, !ok, tt.drop)
|
t.Errorf("test %d: peer drop mismatch for %v: have %v, want %v", i, tt.result, !ok, tt.drop)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,6 +194,9 @@ type Config struct {
|
|||||||
// OverrideBohr (TODO: remove after the fork)
|
// OverrideBohr (TODO: remove after the fork)
|
||||||
OverrideBohr *uint64 `toml:",omitempty"`
|
OverrideBohr *uint64 `toml:",omitempty"`
|
||||||
|
|
||||||
|
// OverridePascal (TODO: remove after the fork)
|
||||||
|
OverridePascal *uint64 `toml:",omitempty"`
|
||||||
|
|
||||||
// OverrideVerkle (TODO: remove after the fork)
|
// OverrideVerkle (TODO: remove after the fork)
|
||||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,9 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||||||
RPCGasCap uint64
|
RPCGasCap uint64
|
||||||
RPCEVMTimeout time.Duration
|
RPCEVMTimeout time.Duration
|
||||||
RPCTxFeeCap float64
|
RPCTxFeeCap float64
|
||||||
OverridePassedForkTime *uint64 `toml:",omitempty"`
|
OverridePassedForkTime *uint64 `toml:",omitempty"`
|
||||||
OverrideBohr *uint64 `toml:",omitempty"`
|
OverrideBohr *uint64 `toml:",omitempty"`
|
||||||
|
OverridePascal *uint64 `toml:",omitempty"`
|
||||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||||
BlobExtraReserve uint64
|
BlobExtraReserve uint64
|
||||||
}
|
}
|
||||||
@@ -131,6 +132,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||||||
enc.RPCTxFeeCap = c.RPCTxFeeCap
|
enc.RPCTxFeeCap = c.RPCTxFeeCap
|
||||||
enc.OverridePassedForkTime = c.OverridePassedForkTime
|
enc.OverridePassedForkTime = c.OverridePassedForkTime
|
||||||
enc.OverrideBohr = c.OverrideBohr
|
enc.OverrideBohr = c.OverrideBohr
|
||||||
|
enc.OverridePascal = c.OverridePascal
|
||||||
enc.OverrideVerkle = c.OverrideVerkle
|
enc.OverrideVerkle = c.OverrideVerkle
|
||||||
enc.BlobExtraReserve = c.BlobExtraReserve
|
enc.BlobExtraReserve = c.BlobExtraReserve
|
||||||
return &enc, nil
|
return &enc, nil
|
||||||
@@ -192,8 +194,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||||||
RPCGasCap *uint64
|
RPCGasCap *uint64
|
||||||
RPCEVMTimeout *time.Duration
|
RPCEVMTimeout *time.Duration
|
||||||
RPCTxFeeCap *float64
|
RPCTxFeeCap *float64
|
||||||
OverridePassedForkTime *uint64 `toml:",omitempty"`
|
OverridePassedForkTime *uint64 `toml:",omitempty"`
|
||||||
OverrideBohr *uint64 `toml:",omitempty"`
|
OverrideBohr *uint64 `toml:",omitempty"`
|
||||||
|
OverridePascal *uint64 `toml:",omitempty"`
|
||||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||||
BlobExtraReserve *uint64
|
BlobExtraReserve *uint64
|
||||||
}
|
}
|
||||||
@@ -366,6 +369,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||||||
if dec.OverrideBohr != nil {
|
if dec.OverrideBohr != nil {
|
||||||
c.OverrideBohr = dec.OverrideBohr
|
c.OverrideBohr = dec.OverrideBohr
|
||||||
}
|
}
|
||||||
|
if dec.OverridePascal != nil {
|
||||||
|
c.OverridePascal = dec.OverridePascal
|
||||||
|
}
|
||||||
if dec.OverrideVerkle != nil {
|
if dec.OverrideVerkle != nil {
|
||||||
c.OverrideVerkle = dec.OverrideVerkle
|
c.OverrideVerkle = dec.OverrideVerkle
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -483,13 +483,13 @@ func (h *handler) runEthPeer(peer *eth.Peer, handler eth.Handler) error {
|
|||||||
h.peersPerIP[remoteIP] = h.peersPerIP[remoteIP] + 1
|
h.peersPerIP[remoteIP] = h.peersPerIP[remoteIP] + 1
|
||||||
h.peerPerIPLock.Unlock()
|
h.peerPerIPLock.Unlock()
|
||||||
}
|
}
|
||||||
peer.Log().Debug("Ethereum peer connected", "name", peer.Name())
|
|
||||||
|
|
||||||
// Register the peer locally
|
// Register the peer locally
|
||||||
if err := h.peers.registerPeer(peer, snap, trust, bsc); err != nil {
|
if err := h.peers.registerPeer(peer, snap, trust, bsc); err != nil {
|
||||||
peer.Log().Error("Ethereum peer registration failed", "err", err)
|
peer.Log().Error("Ethereum peer registration failed", "err", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
peer.Log().Debug("Ethereum peer connected", "name", peer.Name(), "peers.len", h.peers.len())
|
||||||
defer h.unregisterPeer(peer.ID())
|
defer h.unregisterPeer(peer.ID())
|
||||||
|
|
||||||
p := h.peers.peer(peer.ID())
|
p := h.peers.peer(peer.ID())
|
||||||
@@ -632,7 +632,7 @@ func (h *handler) runBscExtension(peer *bsc.Peer, handler bsc.Handler) error {
|
|||||||
bsc.EgressRegistrationErrorMeter.Mark(1)
|
bsc.EgressRegistrationErrorMeter.Mark(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
peer.Log().Error("Bsc extension registration failed", "err", err)
|
peer.Log().Error("Bsc extension registration failed", "err", err, "name", peer.Name())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return handler(peer)
|
return handler(peer)
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ func (cs *chainSyncer) startSync(op *chainSyncOp) {
|
|||||||
// doSync synchronizes the local blockchain with a remote peer.
|
// doSync synchronizes the local blockchain with a remote peer.
|
||||||
func (h *handler) doSync(op *chainSyncOp) error {
|
func (h *handler) doSync(op *chainSyncOp) error {
|
||||||
// Run the sync cycle, and disable snap sync if we're past the pivot block
|
// Run the sync cycle, and disable snap sync if we're past the pivot block
|
||||||
err := h.downloader.LegacySync(op.peer.ID(), op.head, op.td, h.chain.Config().TerminalTotalDifficulty, op.mode)
|
err := h.downloader.LegacySync(op.peer.ID(), op.head, op.peer.Name(), op.td, h.chain.Config().TerminalTotalDifficulty, op.mode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,8 +131,8 @@ func (ec *Client) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumb
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BlobSidecars return the Sidecars of a given block number or hash.
|
// BlobSidecars return the Sidecars of a given block number or hash.
|
||||||
func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.BlobTxSidecar, error) {
|
func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.BlobSidecar, error) {
|
||||||
var r []*types.BlobTxSidecar
|
var r []*types.BlobSidecar
|
||||||
err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecars", blockNrOrHash.String())
|
err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecars", blockNrOrHash.String())
|
||||||
if err == nil && r == nil {
|
if err == nil && r == nil {
|
||||||
return nil, ethereum.NotFound
|
return nil, ethereum.NotFound
|
||||||
@@ -141,8 +141,8 @@ func (ec *Client) BlobSidecars(ctx context.Context, blockNrOrHash rpc.BlockNumbe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BlobSidecarByTxHash return a sidecar of a given blob transaction
|
// BlobSidecarByTxHash return a sidecar of a given blob transaction
|
||||||
func (ec *Client) BlobSidecarByTxHash(ctx context.Context, hash common.Hash) (*types.BlobTxSidecar, error) {
|
func (ec *Client) BlobSidecarByTxHash(ctx context.Context, hash common.Hash) (*types.BlobSidecar, error) {
|
||||||
var r *types.BlobTxSidecar
|
var r *types.BlobSidecar
|
||||||
err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecarByTxHash", hash)
|
err := ec.c.CallContext(ctx, &r, "eth_getBlobSidecarByTxHash", hash)
|
||||||
if err == nil && r == nil {
|
if err == nil && r == nil {
|
||||||
return nil, ethereum.NotFound
|
return nil, ethereum.NotFound
|
||||||
|
|||||||
1
go.mod
1
go.mod
@@ -27,7 +27,6 @@ require (
|
|||||||
github.com/fatih/color v1.16.0
|
github.com/fatih/color v1.16.0
|
||||||
github.com/fatih/structs v1.1.0
|
github.com/fatih/structs v1.1.0
|
||||||
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e
|
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e
|
||||||
github.com/fjl/memsize v0.0.2
|
|
||||||
github.com/fsnotify/fsnotify v1.6.0
|
github.com/fsnotify/fsnotify v1.6.0
|
||||||
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08
|
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08
|
||||||
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46
|
github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -335,8 +335,6 @@ github.com/ferranbt/fastssz v0.0.0-20210905181407-59cf6761a7d5 h1:6dVcS0LktRSyEE
|
|||||||
github.com/ferranbt/fastssz v0.0.0-20210905181407-59cf6761a7d5/go.mod h1:S8yiDeAXy8f88W4Ul+0dBMPx49S05byYbmZD6Uv94K4=
|
github.com/ferranbt/fastssz v0.0.0-20210905181407-59cf6761a7d5/go.mod h1:S8yiDeAXy8f88W4Ul+0dBMPx49S05byYbmZD6Uv94K4=
|
||||||
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e h1:bBLctRc7kr01YGvaDfgLbTwjFNW5jdp5y5rj8XXBHfY=
|
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e h1:bBLctRc7kr01YGvaDfgLbTwjFNW5jdp5y5rj8XXBHfY=
|
||||||
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
|
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
|
||||||
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
|
|
||||||
github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
|
|
||||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||||
github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg=
|
github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg=
|
||||||
github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag=
|
github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag=
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/metrics"
|
"github.com/ethereum/go-ethereum/metrics"
|
||||||
"github.com/ethereum/go-ethereum/metrics/exp"
|
"github.com/ethereum/go-ethereum/metrics/exp"
|
||||||
"github.com/fjl/memsize/memsizeui"
|
|
||||||
"github.com/mattn/go-colorable"
|
"github.com/mattn/go-colorable"
|
||||||
"github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
@@ -38,8 +37,6 @@ import (
|
|||||||
"gopkg.in/natefinch/lumberjack.v2"
|
"gopkg.in/natefinch/lumberjack.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Memsize memsizeui.Handler
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
verbosityFlag = &cli.IntFlag{
|
verbosityFlag = &cli.IntFlag{
|
||||||
Name: "verbosity",
|
Name: "verbosity",
|
||||||
@@ -313,7 +310,6 @@ func StartPProf(address string, withMetrics bool) {
|
|||||||
if withMetrics {
|
if withMetrics {
|
||||||
exp.Exp(metrics.DefaultRegistry)
|
exp.Exp(metrics.DefaultRegistry)
|
||||||
}
|
}
|
||||||
http.Handle("/memsize/", http.StripPrefix("/memsize", &Memsize))
|
|
||||||
log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
|
log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
|
||||||
go func() {
|
go func() {
|
||||||
if err := http.ListenAndServe(address, nil); err != nil {
|
if err := http.ListenAndServe(address, nil); err != nil {
|
||||||
|
|||||||
@@ -862,54 +862,72 @@ func (s *BlockChainAPI) Health() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFinalizedHeader returns the requested finalized block header.
|
func (s *BlockChainAPI) getFinalizedNumber(ctx context.Context, verifiedValidatorNum int64) (int64, error) {
|
||||||
// - probabilisticFinalized should be in range [2,21],
|
parliaConfig := s.b.ChainConfig().Parlia
|
||||||
// then the block header with number `max(fastFinalized, latest-probabilisticFinalized)` is returned
|
if parliaConfig == nil {
|
||||||
func (s *BlockChainAPI) GetFinalizedHeader(ctx context.Context, probabilisticFinalized int64) (map[string]interface{}, error) {
|
return 0, fmt.Errorf("only parlia engine supported")
|
||||||
if probabilisticFinalized < 2 || probabilisticFinalized > 21 {
|
|
||||||
return nil, fmt.Errorf("%d out of range [2,21]", probabilisticFinalized)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentTurnLength, err := s.b.CurrentTurnLength()
|
curValidators, err := s.b.CurrentValidators()
|
||||||
if err != nil { // impossible
|
if err != nil { // impossible
|
||||||
return nil, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
valLen := int64(len(curValidators))
|
||||||
|
if verifiedValidatorNum < 1 || verifiedValidatorNum > valLen {
|
||||||
|
return 0, fmt.Errorf("%d out of range [1,%d]", verifiedValidatorNum, valLen)
|
||||||
|
}
|
||||||
|
|
||||||
fastFinalizedHeader, err := s.b.HeaderByNumber(ctx, rpc.FinalizedBlockNumber)
|
fastFinalizedHeader, err := s.b.HeaderByNumber(ctx, rpc.FinalizedBlockNumber)
|
||||||
if err != nil { // impossible
|
if err != nil { // impossible
|
||||||
return nil, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
latestHeader, err := s.b.HeaderByNumber(ctx, rpc.LatestBlockNumber)
|
latestHeader, err := s.b.HeaderByNumber(ctx, rpc.LatestBlockNumber)
|
||||||
|
if err != nil { // impossible
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
lastHeader := latestHeader
|
||||||
|
confirmedValSet := make(map[common.Address]struct{}, valLen)
|
||||||
|
confirmedValSet[lastHeader.Coinbase] = struct{}{}
|
||||||
|
for count := 1; int64(len(confirmedValSet)) < verifiedValidatorNum && count <= int(parliaConfig.Epoch) && lastHeader.Number.Int64() > max(fastFinalizedHeader.Number.Int64(), 1); count++ {
|
||||||
|
lastHeader, err = s.b.HeaderByHash(ctx, lastHeader.ParentHash)
|
||||||
|
if err != nil { // impossible
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
confirmedValSet[lastHeader.Coinbase] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
finalizedBlockNumber := max(fastFinalizedHeader.Number.Int64(), lastHeader.Number.Int64())
|
||||||
|
log.Debug("getFinalizedNumber", "LatestBlockNumber", latestHeader.Number.Int64(), "fastFinalizedHeight", fastFinalizedHeader.Number.Int64(),
|
||||||
|
"lastHeader", lastHeader.Number.Int64(), "finalizedBlockNumber", finalizedBlockNumber, "len(confirmedValSet)", len(confirmedValSet))
|
||||||
|
|
||||||
|
return finalizedBlockNumber, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetFinalizedHeader returns the finalized block header based on the specified parameters.
|
||||||
|
// - `verifiedValidatorNum` must be within the range [1, len(currentValidators)].
|
||||||
|
// - The function calculates `probabilisticFinalizedHeight` as the highest height of the block verified by `verifiedValidatorNum` validators,
|
||||||
|
// it then returns the block header with a height equal to `max(fastFinalizedHeight, probabilisticFinalizedHeight)`.
|
||||||
|
// - The height of the returned block header is guaranteed to be monotonically increasing.
|
||||||
|
func (s *BlockChainAPI) GetFinalizedHeader(ctx context.Context, verifiedValidatorNum int64) (map[string]interface{}, error) {
|
||||||
|
finalizedBlockNumber, err := s.getFinalizedNumber(ctx, verifiedValidatorNum)
|
||||||
if err != nil { // impossible
|
if err != nil { // impossible
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
finalizedBlockNumber := max(fastFinalizedHeader.Number.Int64(), latestHeader.Number.Int64()-probabilisticFinalized*int64(currentTurnLength))
|
|
||||||
|
|
||||||
return s.GetHeaderByNumber(ctx, rpc.BlockNumber(finalizedBlockNumber))
|
return s.GetHeaderByNumber(ctx, rpc.BlockNumber(finalizedBlockNumber))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFinalizedBlock returns the requested finalized block.
|
// GetFinalizedBlock returns the finalized block based on the specified parameters.
|
||||||
// - probabilisticFinalized should be in range [2,21],
|
// - `verifiedValidatorNum` must be within the range [1, len(currentValidators)].
|
||||||
// then the block with number `max(fastFinalized, latest-probabilisticFinalized)` is returned
|
// - The function calculates `probabilisticFinalizedHeight` as the highest height of the block verified by `verifiedValidatorNum` validators,
|
||||||
// - When fullTx is true all transactions in the block are returned, otherwise
|
// it then returns the block with a height equal to `max(fastFinalizedHeight, probabilisticFinalizedHeight)`.
|
||||||
// only the transaction hash is returned.
|
// - If `fullTx` is true, the block includes all transactions; otherwise, only transaction hashes are included.
|
||||||
func (s *BlockChainAPI) GetFinalizedBlock(ctx context.Context, probabilisticFinalized int64, fullTx bool) (map[string]interface{}, error) {
|
// - The height of the returned block is guaranteed to be monotonically increasing.
|
||||||
if probabilisticFinalized < 2 || probabilisticFinalized > 21 {
|
func (s *BlockChainAPI) GetFinalizedBlock(ctx context.Context, verifiedValidatorNum int64, fullTx bool) (map[string]interface{}, error) {
|
||||||
return nil, fmt.Errorf("%d out of range [2,21]", probabilisticFinalized)
|
finalizedBlockNumber, err := s.getFinalizedNumber(ctx, verifiedValidatorNum)
|
||||||
}
|
|
||||||
|
|
||||||
currentTurnLength, err := s.b.CurrentTurnLength()
|
|
||||||
if err != nil { // impossible
|
if err != nil { // impossible
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
fastFinalizedHeader, err := s.b.HeaderByNumber(ctx, rpc.FinalizedBlockNumber)
|
|
||||||
if err != nil { // impossible
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
latestHeader, err := s.b.HeaderByNumber(ctx, rpc.LatestBlockNumber)
|
|
||||||
if err != nil { // impossible
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
finalizedBlockNumber := max(fastFinalizedHeader.Number.Int64(), latestHeader.Number.Int64()-probabilisticFinalized*int64(currentTurnLength))
|
|
||||||
|
|
||||||
return s.GetBlockByNumber(ctx, rpc.BlockNumber(finalizedBlockNumber), fullTx)
|
return s.GetBlockByNumber(ctx, rpc.BlockNumber(finalizedBlockNumber), fullTx)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -631,9 +631,9 @@ func (b testBackend) TxPoolContentFrom(addr common.Address) ([]*types.Transactio
|
|||||||
func (b testBackend) SubscribeNewTxsEvent(events chan<- core.NewTxsEvent) event.Subscription {
|
func (b testBackend) SubscribeNewTxsEvent(events chan<- core.NewTxsEvent) event.Subscription {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
func (b testBackend) ChainConfig() *params.ChainConfig { return b.chain.Config() }
|
func (b testBackend) ChainConfig() *params.ChainConfig { return b.chain.Config() }
|
||||||
func (b testBackend) Engine() consensus.Engine { return b.chain.Engine() }
|
func (b testBackend) Engine() consensus.Engine { return b.chain.Engine() }
|
||||||
func (b testBackend) CurrentTurnLength() (uint8, error) { return 1, nil }
|
func (b testBackend) CurrentValidators() ([]common.Address, error) { return []common.Address{}, nil }
|
||||||
func (b testBackend) GetLogs(ctx context.Context, blockHash common.Hash, number uint64) ([][]*types.Log, error) {
|
func (b testBackend) GetLogs(ctx context.Context, blockHash common.Hash, number uint64) ([][]*types.Log, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ type Backend interface {
|
|||||||
|
|
||||||
ChainConfig() *params.ChainConfig
|
ChainConfig() *params.ChainConfig
|
||||||
Engine() consensus.Engine
|
Engine() consensus.Engine
|
||||||
// CurrentTurnLength return the turnLength at the latest block
|
// CurrentValidators return the list of validator at the latest block
|
||||||
CurrentTurnLength() (uint8, error)
|
CurrentValidators() ([]common.Address, error)
|
||||||
|
|
||||||
// This is copied from filters.Backend
|
// This is copied from filters.Backend
|
||||||
// eth/filters needs to be initialized from this backend type, so methods needed by
|
// eth/filters needs to be initialized from this backend type, so methods needed by
|
||||||
|
|||||||
@@ -416,7 +416,7 @@ func (b *backendMock) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent)
|
|||||||
|
|
||||||
func (b *backendMock) Engine() consensus.Engine { return nil }
|
func (b *backendMock) Engine() consensus.Engine { return nil }
|
||||||
|
|
||||||
func (b *backendMock) CurrentTurnLength() (uint8, error) { return 1, nil }
|
func (b *backendMock) CurrentValidators() ([]common.Address, error) { return []common.Address{}, nil }
|
||||||
|
|
||||||
func (b *backendMock) MevRunning() bool { return false }
|
func (b *backendMock) MevRunning() bool { return false }
|
||||||
func (b *backendMock) HasBuilder(builder common.Address) bool { return false }
|
func (b *backendMock) HasBuilder(builder common.Address) bool { return false }
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ type Config struct {
|
|||||||
|
|
||||||
// DefaultConfig contains default settings for miner.
|
// DefaultConfig contains default settings for miner.
|
||||||
var DefaultConfig = Config{
|
var DefaultConfig = Config{
|
||||||
GasCeil: 30000000,
|
GasCeil: 0,
|
||||||
GasPrice: big.NewInt(params.GWei),
|
GasPrice: big.NewInt(params.GWei),
|
||||||
|
|
||||||
// The default recommit time is chosen as two seconds since
|
// The default recommit time is chosen as two seconds since
|
||||||
|
|||||||
@@ -153,8 +153,10 @@ var (
|
|||||||
FeynmanFixTime: newUint64(1713419340), // 2024-04-18 05:49:00 AM UTC
|
FeynmanFixTime: newUint64(1713419340), // 2024-04-18 05:49:00 AM UTC
|
||||||
CancunTime: newUint64(1718863500), // 2024-06-20 06:05:00 AM UTC
|
CancunTime: newUint64(1718863500), // 2024-06-20 06:05:00 AM UTC
|
||||||
HaberTime: newUint64(1718863500), // 2024-06-20 06:05:00 AM UTC
|
HaberTime: newUint64(1718863500), // 2024-06-20 06:05:00 AM UTC
|
||||||
HaberFixTime: nil, // TBD
|
HaberFixTime: newUint64(1727316120), // 2024-09-26 02:02:00 AM UTC
|
||||||
BohrTime: nil,
|
BohrTime: newUint64(1727317200), // 2024-09-26 02:20:00 AM UTC
|
||||||
|
// TODO
|
||||||
|
PascalTime: nil,
|
||||||
|
|
||||||
Parlia: &ParliaConfig{
|
Parlia: &ParliaConfig{
|
||||||
Period: 3,
|
Period: 3,
|
||||||
@@ -196,6 +198,8 @@ var (
|
|||||||
HaberTime: newUint64(1716962820), // 2024-05-29 06:07:00 AM UTC
|
HaberTime: newUint64(1716962820), // 2024-05-29 06:07:00 AM UTC
|
||||||
HaberFixTime: newUint64(1719986788), // 2024-07-03 06:06:28 AM UTC
|
HaberFixTime: newUint64(1719986788), // 2024-07-03 06:06:28 AM UTC
|
||||||
BohrTime: newUint64(1724116996), // 2024-08-20 01:23:16 AM UTC
|
BohrTime: newUint64(1724116996), // 2024-08-20 01:23:16 AM UTC
|
||||||
|
// TODO
|
||||||
|
PascalTime: nil,
|
||||||
|
|
||||||
Parlia: &ParliaConfig{
|
Parlia: &ParliaConfig{
|
||||||
Period: 3,
|
Period: 3,
|
||||||
@@ -238,6 +242,8 @@ var (
|
|||||||
HaberTime: newUint64(0),
|
HaberTime: newUint64(0),
|
||||||
HaberFixTime: newUint64(0),
|
HaberFixTime: newUint64(0),
|
||||||
BohrTime: newUint64(0),
|
BohrTime: newUint64(0),
|
||||||
|
// TODO
|
||||||
|
PascalTime: newUint64(0),
|
||||||
|
|
||||||
Parlia: &ParliaConfig{
|
Parlia: &ParliaConfig{
|
||||||
Period: 3,
|
Period: 3,
|
||||||
@@ -517,6 +523,7 @@ type ChainConfig struct {
|
|||||||
HaberTime *uint64 `json:"haberTime,omitempty"` // Haber switch time (nil = no fork, 0 = already on haber)
|
HaberTime *uint64 `json:"haberTime,omitempty"` // Haber switch time (nil = no fork, 0 = already on haber)
|
||||||
HaberFixTime *uint64 `json:"haberFixTime,omitempty"` // HaberFix switch time (nil = no fork, 0 = already on haberFix)
|
HaberFixTime *uint64 `json:"haberFixTime,omitempty"` // HaberFix switch time (nil = no fork, 0 = already on haberFix)
|
||||||
BohrTime *uint64 `json:"bohrTime,omitempty"` // Bohr switch time (nil = no fork, 0 = already on bohr)
|
BohrTime *uint64 `json:"bohrTime,omitempty"` // Bohr switch time (nil = no fork, 0 = already on bohr)
|
||||||
|
PascalTime *uint64 `json:"pascalTime,omitempty"` // Pascal switch time (nil = no fork, 0 = already on pascal)
|
||||||
PragueTime *uint64 `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already on prague)
|
PragueTime *uint64 `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already on prague)
|
||||||
VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle)
|
VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle)
|
||||||
|
|
||||||
@@ -637,7 +644,12 @@ func (c *ChainConfig) String() string {
|
|||||||
BohrTime = big.NewInt(0).SetUint64(*c.BohrTime)
|
BohrTime = big.NewInt(0).SetUint64(*c.BohrTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Ramanujan: %v, Niels: %v, MirrorSync: %v, Bruno: %v, Berlin: %v, YOLO v3: %v, CatalystBlock: %v, London: %v, ArrowGlacier: %v, MergeFork:%v, Euler: %v, Gibbs: %v, Nano: %v, Moran: %v, Planck: %v,Luban: %v, Plato: %v, Hertz: %v, Hertzfix: %v, ShanghaiTime: %v, KeplerTime: %v, FeynmanTime: %v, FeynmanFixTime: %v, CancunTime: %v, HaberTime: %v, HaberFixTime: %v, BohrTime: %v, Engine: %v}",
|
var PascalTime *big.Int
|
||||||
|
if c.PascalTime != nil {
|
||||||
|
PascalTime = big.NewInt(0).SetUint64(*c.PascalTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Ramanujan: %v, Niels: %v, MirrorSync: %v, Bruno: %v, Berlin: %v, YOLO v3: %v, CatalystBlock: %v, London: %v, ArrowGlacier: %v, MergeFork:%v, Euler: %v, Gibbs: %v, Nano: %v, Moran: %v, Planck: %v,Luban: %v, Plato: %v, Hertz: %v, Hertzfix: %v, ShanghaiTime: %v, KeplerTime: %v, FeynmanTime: %v, FeynmanFixTime: %v, CancunTime: %v, HaberTime: %v, HaberFixTime: %v, BohrTime: %v, PascalTime: %v, Engine: %v}",
|
||||||
c.ChainID,
|
c.ChainID,
|
||||||
c.HomesteadBlock,
|
c.HomesteadBlock,
|
||||||
c.DAOForkBlock,
|
c.DAOForkBlock,
|
||||||
@@ -677,6 +689,7 @@ func (c *ChainConfig) String() string {
|
|||||||
HaberTime,
|
HaberTime,
|
||||||
HaberFixTime,
|
HaberFixTime,
|
||||||
BohrTime,
|
BohrTime,
|
||||||
|
PascalTime,
|
||||||
engine,
|
engine,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -977,6 +990,20 @@ func (c *ChainConfig) IsOnBohr(currentBlockNumber *big.Int, lastBlockTime uint64
|
|||||||
return !c.IsBohr(lastBlockNumber, lastBlockTime) && c.IsBohr(currentBlockNumber, currentBlockTime)
|
return !c.IsBohr(lastBlockNumber, lastBlockTime) && c.IsBohr(currentBlockNumber, currentBlockTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsPascal returns whether time is either equal to the Pascal fork time or greater.
|
||||||
|
func (c *ChainConfig) IsPascal(num *big.Int, time uint64) bool {
|
||||||
|
return c.IsLondon(num) && isTimestampForked(c.PascalTime, time)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsOnPascal returns whether currentBlockTime is either equal to the Pascal fork time or greater firstly.
|
||||||
|
func (c *ChainConfig) IsOnPascal(currentBlockNumber *big.Int, lastBlockTime uint64, currentBlockTime uint64) bool {
|
||||||
|
lastBlockNumber := new(big.Int)
|
||||||
|
if currentBlockNumber.Cmp(big.NewInt(1)) >= 0 {
|
||||||
|
lastBlockNumber.Sub(currentBlockNumber, big.NewInt(1))
|
||||||
|
}
|
||||||
|
return !c.IsPascal(lastBlockNumber, lastBlockTime) && c.IsPascal(currentBlockNumber, currentBlockTime)
|
||||||
|
}
|
||||||
|
|
||||||
// IsPrague returns whether num is either equal to the Prague fork time or greater.
|
// IsPrague returns whether num is either equal to the Prague fork time or greater.
|
||||||
func (c *ChainConfig) IsPrague(num *big.Int, time uint64) bool {
|
func (c *ChainConfig) IsPrague(num *big.Int, time uint64) bool {
|
||||||
return c.IsLondon(num) && isTimestampForked(c.PragueTime, time)
|
return c.IsLondon(num) && isTimestampForked(c.PragueTime, time)
|
||||||
@@ -1043,6 +1070,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
|
|||||||
{name: "haberTime", timestamp: c.HaberTime},
|
{name: "haberTime", timestamp: c.HaberTime},
|
||||||
{name: "haberFixTime", timestamp: c.HaberFixTime},
|
{name: "haberFixTime", timestamp: c.HaberFixTime},
|
||||||
{name: "bohrTime", timestamp: c.BohrTime},
|
{name: "bohrTime", timestamp: c.BohrTime},
|
||||||
|
{name: "pascalTime", timestamp: c.PascalTime},
|
||||||
{name: "pragueTime", timestamp: c.PragueTime, optional: true},
|
{name: "pragueTime", timestamp: c.PragueTime, optional: true},
|
||||||
{name: "verkleTime", timestamp: c.VerkleTime, optional: true},
|
{name: "verkleTime", timestamp: c.VerkleTime, optional: true},
|
||||||
} {
|
} {
|
||||||
@@ -1199,6 +1227,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
|
|||||||
if isForkTimestampIncompatible(c.BohrTime, newcfg.BohrTime, headTimestamp) {
|
if isForkTimestampIncompatible(c.BohrTime, newcfg.BohrTime, headTimestamp) {
|
||||||
return newTimestampCompatError("Bohr fork timestamp", c.BohrTime, newcfg.BohrTime)
|
return newTimestampCompatError("Bohr fork timestamp", c.BohrTime, newcfg.BohrTime)
|
||||||
}
|
}
|
||||||
|
if isForkTimestampIncompatible(c.PascalTime, newcfg.PascalTime, headTimestamp) {
|
||||||
|
return newTimestampCompatError("Pascal fork timestamp", c.PascalTime, newcfg.PascalTime)
|
||||||
|
}
|
||||||
if isForkTimestampIncompatible(c.PragueTime, newcfg.PragueTime, headTimestamp) {
|
if isForkTimestampIncompatible(c.PragueTime, newcfg.PragueTime, headTimestamp) {
|
||||||
return newTimestampCompatError("Prague fork timestamp", c.PragueTime, newcfg.PragueTime)
|
return newTimestampCompatError("Prague fork timestamp", c.PragueTime, newcfg.PragueTime)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
VersionMajor = 1 // Major version component of the current release
|
VersionMajor = 1 // Major version component of the current release
|
||||||
VersionMinor = 4 // Minor version component of the current release
|
VersionMinor = 4 // Minor version component of the current release
|
||||||
VersionPatch = 13 // Patch version component of the current release
|
VersionPatch = 14 // Patch version component of the current release
|
||||||
VersionMeta = "" // Version metadata to append to the version string
|
VersionMeta = "" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user