mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-14 16:03:45 +00:00
feat(trace): Add chainID and version fields in trace. (#227)
* Add ChainID and version. * fix comments. * Update params/version.go Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> * fix comments. * Update version.go --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
This commit is contained in:
parent
d1f9523b08
commit
03b4de32b7
3 changed files with 23 additions and 5 deletions
|
|
@ -25,6 +25,8 @@ var (
|
||||||
|
|
||||||
// BlockTrace contains block execution traces and results required for rollers.
|
// BlockTrace contains block execution traces and results required for rollers.
|
||||||
type BlockTrace struct {
|
type BlockTrace struct {
|
||||||
|
ChainID uint64 `json:"chainID"`
|
||||||
|
Version string `json:"version"`
|
||||||
Coinbase *AccountWrapper `json:"coinbase"`
|
Coinbase *AccountWrapper `json:"coinbase"`
|
||||||
Header *Header `json:"header"`
|
Header *Header `json:"header"`
|
||||||
Transactions []*TransactionData `json:"transactions"`
|
Transactions []*TransactionData `json:"transactions"`
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/scroll-tech/go-ethereum/core/types"
|
"github.com/scroll-tech/go-ethereum/core/types"
|
||||||
"github.com/scroll-tech/go-ethereum/core/vm"
|
"github.com/scroll-tech/go-ethereum/core/vm"
|
||||||
"github.com/scroll-tech/go-ethereum/log"
|
"github.com/scroll-tech/go-ethereum/log"
|
||||||
|
"github.com/scroll-tech/go-ethereum/params"
|
||||||
"github.com/scroll-tech/go-ethereum/rollup/rcfg"
|
"github.com/scroll-tech/go-ethereum/rollup/rcfg"
|
||||||
"github.com/scroll-tech/go-ethereum/rollup/withdrawtrie"
|
"github.com/scroll-tech/go-ethereum/rollup/withdrawtrie"
|
||||||
"github.com/scroll-tech/go-ethereum/rpc"
|
"github.com/scroll-tech/go-ethereum/rpc"
|
||||||
|
|
@ -357,6 +358,8 @@ func (api *API) fillBlockTrace(env *traceEnv, block *types.Block) (*types.BlockT
|
||||||
}
|
}
|
||||||
|
|
||||||
blockTrace := &types.BlockTrace{
|
blockTrace := &types.BlockTrace{
|
||||||
|
ChainID: api.backend.ChainConfig().ChainID.Uint64(),
|
||||||
|
Version: params.ArchiveVersion(params.CommitHash),
|
||||||
Coinbase: &types.AccountWrapper{
|
Coinbase: &types.AccountWrapper{
|
||||||
Address: env.coinbase,
|
Address: env.coinbase,
|
||||||
Nonce: statedb.GetNonce(env.coinbase),
|
Nonce: statedb.GetNonce(env.coinbase),
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,14 @@ package params
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime/debug"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VersionMajor = 1 // Major version component of the current release
|
VersionMajor = 0 // Major version component of the current release
|
||||||
VersionMinor = 10 // Minor version component of the current release
|
VersionMinor = 1 // Minor version component of the current release
|
||||||
VersionPatch = 13 // Patch version component of the current release
|
VersionPatch = 9 // Patch version component of the current release
|
||||||
VersionMeta = "stable" // Version metadata to append to the version string
|
VersionMeta = "alpha" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version holds the textual version string.
|
// Version holds the textual version string.
|
||||||
|
|
@ -43,7 +44,8 @@ var VersionWithMeta = func() string {
|
||||||
|
|
||||||
// ArchiveVersion holds the textual version string used for Geth archives.
|
// ArchiveVersion holds the textual version string used for Geth archives.
|
||||||
// e.g. "1.8.11-dea1ce05" for stable releases, or
|
// e.g. "1.8.11-dea1ce05" for stable releases, or
|
||||||
// "1.8.13-unstable-21c059b6" for unstable releases
|
//
|
||||||
|
// "1.8.13-unstable-21c059b6" for unstable releases
|
||||||
func ArchiveVersion(gitCommit string) string {
|
func ArchiveVersion(gitCommit string) string {
|
||||||
vsn := Version
|
vsn := Version
|
||||||
if VersionMeta != "stable" {
|
if VersionMeta != "stable" {
|
||||||
|
|
@ -65,3 +67,14 @@ func VersionWithCommit(gitCommit, gitDate string) string {
|
||||||
}
|
}
|
||||||
return vsn
|
return vsn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var CommitHash = func() string {
|
||||||
|
if info, ok := debug.ReadBuildInfo(); ok {
|
||||||
|
for _, setting := range info.Settings {
|
||||||
|
if setting.Key == "vcs.revision" {
|
||||||
|
return setting.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue