Skip to content

Commit 709b787

Browse files
committed
2 parents 9e8319a + 2667545 commit 709b787

40 files changed

+996
-504
lines changed

accounts/abi/bind/backends/simulated.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ type callMsg struct {
795795

796796
func (m callMsg) From() common.Address { return m.CallMsg.From }
797797
func (m callMsg) Nonce() uint64 { return 0 }
798-
func (m callMsg) CheckNonce() bool { return false }
798+
func (m callMsg) IsFake() bool { return true }
799799
func (m callMsg) To() *common.Address { return m.CallMsg.To }
800800
func (m callMsg) GasPrice() *big.Int { return m.CallMsg.GasPrice }
801801
func (m callMsg) GasFeeCap() *big.Int { return m.CallMsg.GasFeeCap }

accounts/external/backend.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ type signTransactionResult struct {
196196
Tx *types.Transaction `json:"tx"`
197197
}
198198

199+
// SignTx sends the transaction to the external signer.
200+
// If chainID is nil, or tx.ChainID is zero, the chain ID will be assigned
201+
// by the external signer. For non-legacy transactions, the chain ID of the
202+
// transaction overrides the chainID parameter.
199203
func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
200204
data := hexutil.Bytes(tx.Data())
201205
var to *common.MixedcaseAddress
@@ -218,17 +222,17 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
218222
args.MaxFeePerGas = (*hexutil.Big)(tx.GasFeeCap())
219223
args.MaxPriorityFeePerGas = (*hexutil.Big)(tx.GasTipCap())
220224
default:
221-
return nil, fmt.Errorf("Unsupported tx type %d", tx.Type())
225+
return nil, fmt.Errorf("unsupported tx type %d", tx.Type())
222226
}
223227
// We should request the default chain id that we're operating with
224228
// (the chain we're executing on)
225-
if chainID != nil {
229+
if chainID != nil && chainID.Sign() != 0 {
226230
args.ChainID = (*hexutil.Big)(chainID)
227231
}
228232
if tx.Type() != types.LegacyTxType {
229233
// However, if the user asked for a particular chain id, then we should
230234
// use that instead.
231-
if tx.ChainId() != nil {
235+
if tx.ChainId().Sign() != 0 {
232236
args.ChainID = (*hexutil.Big)(tx.ChainId())
233237
}
234238
accessList := tx.AccessList()

cmd/gubiq/chaincmd.go

+4
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,15 @@ The dumpgenesis command dumps the genesis block configuration in JSON format to
9090
utils.MetricsHTTPFlag,
9191
utils.MetricsPortFlag,
9292
utils.MetricsEnableInfluxDBFlag,
93+
utils.MetricsEnableInfluxDBV2Flag,
9394
utils.MetricsInfluxDBEndpointFlag,
9495
utils.MetricsInfluxDBDatabaseFlag,
9596
utils.MetricsInfluxDBUsernameFlag,
9697
utils.MetricsInfluxDBPasswordFlag,
9798
utils.MetricsInfluxDBTagsFlag,
99+
utils.MetricsInfluxDBTokenFlag,
100+
utils.MetricsInfluxDBBucketFlag,
101+
utils.MetricsInfluxDBOrganizationFlag,
98102
utils.TxLookupLimitFlag,
99103
},
100104
Category: "BLOCKCHAIN COMMANDS",

cmd/gubiq/config.go

+12
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,18 @@ func applyMetricConfig(ctx *cli.Context, cfg *gubiqConfig) {
222222
if ctx.GlobalIsSet(utils.MetricsInfluxDBTagsFlag.Name) {
223223
cfg.Metrics.InfluxDBTags = ctx.GlobalString(utils.MetricsInfluxDBTagsFlag.Name)
224224
}
225+
if ctx.GlobalIsSet(utils.MetricsEnableInfluxDBV2Flag.Name) {
226+
cfg.Metrics.EnableInfluxDBV2 = ctx.GlobalBool(utils.MetricsEnableInfluxDBV2Flag.Name)
227+
}
228+
if ctx.GlobalIsSet(utils.MetricsInfluxDBTokenFlag.Name) {
229+
cfg.Metrics.InfluxDBToken = ctx.GlobalString(utils.MetricsInfluxDBTokenFlag.Name)
230+
}
231+
if ctx.GlobalIsSet(utils.MetricsInfluxDBBucketFlag.Name) {
232+
cfg.Metrics.InfluxDBBucket = ctx.GlobalString(utils.MetricsInfluxDBBucketFlag.Name)
233+
}
234+
if ctx.GlobalIsSet(utils.MetricsInfluxDBOrganizationFlag.Name) {
235+
cfg.Metrics.InfluxDBOrganization = ctx.GlobalString(utils.MetricsInfluxDBOrganizationFlag.Name)
236+
}
225237
}
226238

227239
func deprecated(field string) bool {

cmd/gubiq/main.go

+4
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ var (
183183
utils.MetricsInfluxDBUsernameFlag,
184184
utils.MetricsInfluxDBPasswordFlag,
185185
utils.MetricsInfluxDBTagsFlag,
186+
utils.MetricsEnableInfluxDBV2Flag,
187+
utils.MetricsInfluxDBTokenFlag,
188+
utils.MetricsInfluxDBBucketFlag,
189+
utils.MetricsInfluxDBOrganizationFlag,
186190
}
187191
)
188192

cmd/utils/flags.go

+59-9
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ var (
124124
Name: "keystore",
125125
Usage: "Directory for the keystore (default = inside the datadir)",
126126
}
127-
NoUSBFlag = cli.BoolFlag{
128-
Name: "nousb",
129-
Usage: "Disables monitoring for and managing USB hardware wallets (deprecated)",
130-
}
131127
USBFlag = cli.BoolFlag{
132128
Name: "usb",
133129
Usage: "Enable monitoring and management of USB hardware wallets",
@@ -704,6 +700,29 @@ var (
704700
Value: metrics.DefaultConfig.InfluxDBTags,
705701
}
706702

703+
MetricsEnableInfluxDBV2Flag = cli.BoolFlag{
704+
Name: "metrics.influxdbv2",
705+
Usage: "Enable metrics export/push to an external InfluxDB v2 database",
706+
}
707+
708+
MetricsInfluxDBTokenFlag = cli.StringFlag{
709+
Name: "metrics.influxdb.token",
710+
Usage: "Token to authorize access to the database (v2 only)",
711+
Value: metrics.DefaultConfig.InfluxDBToken,
712+
}
713+
714+
MetricsInfluxDBBucketFlag = cli.StringFlag{
715+
Name: "metrics.influxdb.bucket",
716+
Usage: "InfluxDB bucket name to push reported metrics to (v2 only)",
717+
Value: metrics.DefaultConfig.InfluxDBBucket,
718+
}
719+
720+
MetricsInfluxDBOrganizationFlag = cli.StringFlag{
721+
Name: "metrics.influxdb.organization",
722+
Usage: "InfluxDB organization name (v2 only)",
723+
Value: metrics.DefaultConfig.InfluxDBOrganization,
724+
}
725+
707726
CatalystFlag = cli.BoolFlag{
708727
Name: "catalyst",
709728
Usage: "Catalyst mode (eth2 integration testing)",
@@ -1560,11 +1579,36 @@ func SetupMetrics(ctx *cli.Context) {
15601579
log.Info("Enabling metrics collection")
15611580

15621581
var (
1563-
enableExport = ctx.GlobalBool(MetricsEnableInfluxDBFlag.Name)
1564-
endpoint = ctx.GlobalString(MetricsInfluxDBEndpointFlag.Name)
1565-
database = ctx.GlobalString(MetricsInfluxDBDatabaseFlag.Name)
1566-
username = ctx.GlobalString(MetricsInfluxDBUsernameFlag.Name)
1567-
password = ctx.GlobalString(MetricsInfluxDBPasswordFlag.Name)
1582+
enableExport = ctx.GlobalBool(MetricsEnableInfluxDBFlag.Name)
1583+
enableExportV2 = ctx.GlobalBool(MetricsEnableInfluxDBV2Flag.Name)
1584+
)
1585+
1586+
if enableExport || enableExportV2 {
1587+
CheckExclusive(ctx, MetricsEnableInfluxDBFlag, MetricsEnableInfluxDBV2Flag)
1588+
1589+
v1FlagIsSet := ctx.GlobalIsSet(MetricsInfluxDBUsernameFlag.Name) ||
1590+
ctx.GlobalIsSet(MetricsInfluxDBPasswordFlag.Name)
1591+
1592+
v2FlagIsSet := ctx.GlobalIsSet(MetricsInfluxDBTokenFlag.Name) ||
1593+
ctx.GlobalIsSet(MetricsInfluxDBOrganizationFlag.Name) ||
1594+
ctx.GlobalIsSet(MetricsInfluxDBBucketFlag.Name)
1595+
1596+
if enableExport && v2FlagIsSet {
1597+
Fatalf("Flags --influxdb.metrics.organization, --influxdb.metrics.token, --influxdb.metrics.bucket are only available for influxdb-v2")
1598+
} else if enableExportV2 && v1FlagIsSet {
1599+
Fatalf("Flags --influxdb.metrics.username, --influxdb.metrics.password are only available for influxdb-v1")
1600+
}
1601+
}
1602+
1603+
var (
1604+
endpoint = ctx.GlobalString(MetricsInfluxDBEndpointFlag.Name)
1605+
database = ctx.GlobalString(MetricsInfluxDBDatabaseFlag.Name)
1606+
username = ctx.GlobalString(MetricsInfluxDBUsernameFlag.Name)
1607+
password = ctx.GlobalString(MetricsInfluxDBPasswordFlag.Name)
1608+
1609+
token = ctx.GlobalString(MetricsInfluxDBTokenFlag.Name)
1610+
bucket = ctx.GlobalString(MetricsInfluxDBBucketFlag.Name)
1611+
organization = ctx.GlobalString(MetricsInfluxDBOrganizationFlag.Name)
15681612
)
15691613

15701614
if enableExport {
@@ -1573,6 +1617,12 @@ func SetupMetrics(ctx *cli.Context) {
15731617
log.Info("Enabling metrics export to InfluxDB")
15741618

15751619
go influxdb.InfluxDBWithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, database, username, password, "gubiq.", tagsMap)
1620+
} else if enableExportV2 {
1621+
tagsMap := SplitTagsFlag(ctx.GlobalString(MetricsInfluxDBTagsFlag.Name))
1622+
1623+
log.Info("Enabling metrics export to InfluxDB (v2)")
1624+
1625+
go influxdb.InfluxDBV2WithTags(metrics.DefaultRegistry, 10*time.Second, endpoint, token, bucket, organization, "gubiq.", tagsMap)
15761626
}
15771627

15781628
if ctx.GlobalIsSet(MetricsHTTPFlag.Name) {

cmd/utils/flags_legacy.go

+5
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ var ShowDeprecated = cli.Command{
3636

3737
var DeprecatedFlags = []cli.Flag{
3838
LegacyMinerGasTargetFlag,
39+
NoUSBFlag,
3940
}
4041

4142
var (
4243
// (Deprecated May 2020, shown in aliased flags section)
44+
NoUSBFlag = cli.BoolFlag{
45+
Name: "nousb",
46+
Usage: "Disables monitoring for and managing USB hardware wallets (deprecated)",
47+
}
4348
LegacyRPCEnabledFlag = cli.BoolFlag{
4449
Name: "rpc",
4550
Usage: "Enable the HTTP-RPC server (deprecated and will be removed June 2021, use --http)",

core/rawdb/database.go

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ func (db *nofreezedb) Ancient(kind string, number uint64) ([]byte, error) {
8989
return nil, errNotSupported
9090
}
9191

92+
// ReadAncients returns an error as we don't have a backing chain freezer.
93+
func (db *nofreezedb) ReadAncients(kind string, start, max, maxByteSize uint64) ([][]byte, error) {
94+
return nil, errNotSupported
95+
}
96+
9297
// Ancients returns an error as we don't have a backing chain freezer.
9398
func (db *nofreezedb) Ancients() (uint64, error) {
9499
return 0, errNotSupported

core/rawdb/freezer.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ func (f *freezer) Ancient(kind string, number uint64) ([]byte, error) {
180180
return nil, errUnknownTable
181181
}
182182

183+
// ReadAncients retrieves multiple items in sequence, starting from the index 'start'.
184+
// It will return
185+
// - at most 'max' items,
186+
// - at least 1 item (even if exceeding the maxByteSize), but will otherwise
187+
// return as many items as fit into maxByteSize.
188+
func (f *freezer) ReadAncients(kind string, start, count, maxBytes uint64) ([][]byte, error) {
189+
if table := f.tables[kind]; table != nil {
190+
return table.RetrieveItems(start, count, maxBytes)
191+
}
192+
return nil, errUnknownTable
193+
}
194+
183195
// Ancients returns the length of the frozen items.
184196
func (f *freezer) Ancients() (uint64, error) {
185197
return atomic.LoadUint64(&f.frozen), nil
@@ -402,7 +414,7 @@ func (f *freezer) freeze(db ethdb.KeyValueStore) {
402414
}
403415
batch.Reset()
404416

405-
// Wipe out side chains also and track dangling side chians
417+
// Wipe out side chains also and track dangling side chains
406418
var dangling []common.Hash
407419
for number := first; number < f.frozen; number++ {
408420
// Always keep the genesis block in active database

0 commit comments

Comments
 (0)