From 29d57c1c02d69443a2768ebea74c282a1487cd24 Mon Sep 17 00:00:00 2001 From: Matthieu Vachon Date: Fri, 21 Feb 2025 13:06:01 -0500 Subject: [PATCH] Added `-trimprefix` and `NonceChangeReason` stringer too --- .../gen_balance_change_reason_stringer.go | 6 ++-- .../tracing/gen_gas_change_reason_stringer.go | 8 ++--- .../gen_nonce_change_reason_stringer.go | 29 +++++++++++++++++++ core/tracing/hooks.go | 6 ++-- 4 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 core/tracing/gen_nonce_change_reason_stringer.go diff --git a/core/tracing/gen_balance_change_reason_stringer.go b/core/tracing/gen_balance_change_reason_stringer.go index 4f094efb4f..250b521193 100644 --- a/core/tracing/gen_balance_change_reason_stringer.go +++ b/core/tracing/gen_balance_change_reason_stringer.go @@ -1,4 +1,4 @@ -// Code generated by "stringer -type=BalanceChangeReason -output gen_balance_change_reason_stringer.go"; DO NOT EDIT. +// Code generated by "stringer -type=BalanceChangeReason -trimprefix=BalanceChange -output gen_balance_change_reason_stringer.go"; DO NOT EDIT. package tracing @@ -26,9 +26,9 @@ func _() { _ = x[BalanceChangeRevert-15] } -const _BalanceChangeReason_name = "BalanceChangeUnspecifiedBalanceIncreaseRewardMineUncleBalanceIncreaseRewardMineBlockBalanceIncreaseWithdrawalBalanceIncreaseGenesisBalanceBalanceIncreaseRewardTransactionFeeBalanceDecreaseGasBuyBalanceIncreaseGasReturnBalanceIncreaseDaoContractBalanceDecreaseDaoAccountBalanceChangeTransferBalanceChangeTouchAccountBalanceIncreaseSelfdestructBalanceDecreaseSelfdestructBalanceDecreaseSelfdestructBurnBalanceChangeRevert" +const _BalanceChangeReason_name = "UnspecifiedBalanceIncreaseRewardMineUncleBalanceIncreaseRewardMineBlockBalanceIncreaseWithdrawalBalanceIncreaseGenesisBalanceBalanceIncreaseRewardTransactionFeeBalanceDecreaseGasBuyBalanceIncreaseGasReturnBalanceIncreaseDaoContractBalanceDecreaseDaoAccountTransferTouchAccountBalanceIncreaseSelfdestructBalanceDecreaseSelfdestructBalanceDecreaseSelfdestructBurnRevert" -var _BalanceChangeReason_index = [...]uint16{0, 24, 54, 84, 109, 138, 173, 194, 218, 244, 269, 290, 315, 342, 369, 400, 419} +var _BalanceChangeReason_index = [...]uint16{0, 11, 41, 71, 96, 125, 160, 181, 205, 231, 256, 264, 276, 303, 330, 361, 367} func (i BalanceChangeReason) String() string { if i >= BalanceChangeReason(len(_BalanceChangeReason_index)-1) { diff --git a/core/tracing/gen_gas_change_reason_stringer.go b/core/tracing/gen_gas_change_reason_stringer.go index dc58d667e7..e64be781a6 100644 --- a/core/tracing/gen_gas_change_reason_stringer.go +++ b/core/tracing/gen_gas_change_reason_stringer.go @@ -1,4 +1,4 @@ -// Code generated by "stringer -type=GasChangeReason -output gen_gas_change_reason_stringer.go"; DO NOT EDIT. +// Code generated by "stringer -type=GasChangeReason -trimprefix=GasChange -output gen_gas_change_reason_stringer.go"; DO NOT EDIT. package tracing @@ -32,12 +32,12 @@ func _() { } const ( - _GasChangeReason_name_0 = "GasChangeUnspecifiedGasChangeTxInitialBalanceGasChangeTxIntrinsicGasGasChangeTxRefundsGasChangeTxLeftOverReturnedGasChangeCallInitialBalanceGasChangeCallLeftOverReturnedGasChangeCallLeftOverRefundedGasChangeCallContractCreationGasChangeCallContractCreation2GasChangeCallCodeStorageGasChangeCallOpCodeGasChangeCallPrecompiledContractGasChangeCallStorageColdAccessGasChangeCallFailedExecutionGasChangeWitnessContractInitGasChangeWitnessContractCreationGasChangeWitnessCodeChunkGasChangeWitnessContractCollisionCheckGasChangeTxDataFloor" - _GasChangeReason_name_1 = "GasChangeIgnored" + _GasChangeReason_name_0 = "UnspecifiedTxInitialBalanceTxIntrinsicGasTxRefundsTxLeftOverReturnedCallInitialBalanceCallLeftOverReturnedCallLeftOverRefundedCallContractCreationCallContractCreation2CallCodeStorageCallOpCodeCallPrecompiledContractCallStorageColdAccessCallFailedExecutionWitnessContractInitWitnessContractCreationWitnessCodeChunkWitnessContractCollisionCheckTxDataFloor" + _GasChangeReason_name_1 = "Ignored" ) var ( - _GasChangeReason_index_0 = [...]uint16{0, 20, 45, 68, 86, 113, 140, 169, 198, 227, 257, 281, 300, 332, 362, 390, 418, 450, 475, 513, 533} + _GasChangeReason_index_0 = [...]uint16{0, 11, 27, 41, 50, 68, 86, 106, 126, 146, 167, 182, 192, 215, 236, 255, 274, 297, 313, 342, 353} ) func (i GasChangeReason) String() string { diff --git a/core/tracing/gen_nonce_change_reason_stringer.go b/core/tracing/gen_nonce_change_reason_stringer.go new file mode 100644 index 0000000000..f775c1f3a6 --- /dev/null +++ b/core/tracing/gen_nonce_change_reason_stringer.go @@ -0,0 +1,29 @@ +// Code generated by "stringer -type=NonceChangeReason -trimprefix NonceChange -output gen_nonce_change_reason_stringer.go"; DO NOT EDIT. + +package tracing + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NonceChangeUnspecified-0] + _ = x[NonceChangeGenesis-1] + _ = x[NonceChangeEoACall-2] + _ = x[NonceChangeContractCreator-3] + _ = x[NonceChangeNewContract-4] + _ = x[NonceChangeAuthorization-5] + _ = x[NonceChangeRevert-6] +} + +const _NonceChangeReason_name = "UnspecifiedGenesisEoACallContractCreatorNewContractAuthorizationRevert" + +var _NonceChangeReason_index = [...]uint8{0, 11, 18, 25, 40, 51, 64, 70} + +func (i NonceChangeReason) String() string { + if i >= NonceChangeReason(len(_NonceChangeReason_index)-1) { + return "NonceChangeReason(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _NonceChangeReason_name[_NonceChangeReason_index[i]:_NonceChangeReason_index[i+1]] +} diff --git a/core/tracing/hooks.go b/core/tracing/hooks.go index 976980459a..0485f7a3eb 100644 --- a/core/tracing/hooks.go +++ b/core/tracing/hooks.go @@ -221,7 +221,7 @@ type Hooks struct { // for tracing and reporting. type BalanceChangeReason byte -//go:generate go run golang.org/x/tools/cmd/stringer -type=BalanceChangeReason -output gen_balance_change_reason_stringer.go +//go:generate go run golang.org/x/tools/cmd/stringer -type=BalanceChangeReason -trimprefix=BalanceChange -output gen_balance_change_reason_stringer.go const ( BalanceChangeUnspecified BalanceChangeReason = 0 @@ -282,7 +282,7 @@ const ( // once per transaction, while those that start with `GasChangeCall` are emitted on a call basis. type GasChangeReason byte -//go:generate go run golang.org/x/tools/cmd/stringer -type=GasChangeReason -output gen_gas_change_reason_stringer.go +//go:generate go run golang.org/x/tools/cmd/stringer -type=GasChangeReason -trimprefix=GasChange -output gen_gas_change_reason_stringer.go const ( GasChangeUnspecified GasChangeReason = 0 @@ -348,6 +348,8 @@ const ( // NonceChangeReason is used to indicate the reason for a nonce change. type NonceChangeReason byte +//go:generate go run golang.org/x/tools/cmd/stringer -type=NonceChangeReason -trimprefix NonceChange -output gen_nonce_change_reason_stringer.go + const ( NonceChangeUnspecified NonceChangeReason = 0