Skip to content

Commit

Permalink
Enable Tracer API
Browse files Browse the repository at this point in the history
  • Loading branch information
gameofpointers authored and wizeguyy committed Dec 11, 2024
1 parent e844225 commit 2fabfb0
Show file tree
Hide file tree
Showing 23 changed files with 3,404 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/utils/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/dominant-strategies/go-quai/params"
"github.com/dominant-strategies/go-quai/quai"
"github.com/dominant-strategies/go-quai/quai/quaiconfig"
"github.com/dominant-strategies/go-quai/quai/tracers"
"github.com/dominant-strategies/go-quai/quaistats"
"github.com/syndtr/goleveldb/leveldb"
)
Expand Down Expand Up @@ -124,6 +125,8 @@ func makeFullNode(p2p quai.NetworkingAPI, nodeLocation common.Location, slicesRu
if cfg.Quaistats.URL != "" && backend.ProcessingState() {
RegisterQuaiStatsService(stack, backend, cfg.Quaistats.URL, sendfullstats)
}

stack.RegisterAPIs(tracers.APIs(backend))
return stack, backend
}

Expand Down
3 changes: 3 additions & 0 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,9 @@ func (p *StateProcessor) StateAtTransaction(block *types.WorkObject, txIndex int
// Recompute transactions up to the target index.
signer := types.MakeSigner(p.hc.Config(), block.Number(nodeCtx))
for idx, tx := range block.Transactions() {
if types.IsCoinBaseTx(tx) || tx.Type() != types.QuaiTxType {
continue
}
// Assemble the transaction call message and return if the requested offset
msg, _ := tx.AsMessage(signer, block.BaseFee())
txContext := NewEVMTxContext(msg)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ require (
gonum.org/v1/gonum v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20210326210528-650f7c854440 // indirect
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,8 @@ gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20210326210528-650f7c854440 h1:SxFAMd+8zfpL/Rk4pgdb8leeZDiL3M/gCWCbBvmLkoE=
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20210326210528-650f7c854440/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
6 changes: 6 additions & 0 deletions internal/quaiapi/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type Backend interface {
BlockByHash(ctx context.Context, hash common.Hash) (*types.WorkObject, error)
BlockOrCandidateByHash(hash common.Hash) *types.WorkObject
BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.WorkObject, error)
GetHeaderOrCandidateByHash(hash common.Hash) *types.WorkObject
StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.WorkObject, error)
StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.WorkObject, error)
AddressOutpoints(ctx context.Context, address common.Address) ([]*types.OutpointAndDenomination, error)
Expand Down Expand Up @@ -116,6 +117,10 @@ type Backend interface {
TxMiningEnabled() bool
GetWorkShareThreshold() int
GetMinerEndpoints() []string
CheckIfEtxIsEligible(hash common.Hash, location common.Location) bool
IsGenesisHash(hash common.Hash) bool
StateAtBlock(context.Context, *types.WorkObject, uint64, *state.StateDB, bool) (*state.StateDB, error)
StateAtTransaction(context.Context, *types.WorkObject, int, uint64) (core.Message, vm.BlockContext, *state.StateDB, error)

BadHashExistsInChain() bool
IsBlockHashABadHash(hash common.Hash) bool
Expand All @@ -139,6 +144,7 @@ type Backend interface {
GetMinGasPrice() *big.Int
GetPoolGasPrice() *big.Int
SendTxToSharingClients(tx *types.Transaction)
CalcMaxBaseFee(block *types.WorkObject) (*big.Int, error)

// Filter API
BloomStatus() (uint64, uint64)
Expand Down
16 changes: 16 additions & 0 deletions quai/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ func (b *QuaiAPIBackend) BlockOrCandidateByHash(hash common.Hash) *types.WorkObj
return b.quai.core.GetBlockOrCandidateByHash(hash)
}

func (b *QuaiAPIBackend) GetHeaderOrCandidateByHash(hash common.Hash) *types.WorkObject {
return b.quai.core.GetHeaderOrCandidateByHash(hash)
}

func (b *QuaiAPIBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.WorkObject, error) {
if blockNr, ok := blockNrOrHash.Number(); ok {
return b.BlockByNumber(ctx, blockNr)
Expand Down Expand Up @@ -505,6 +509,14 @@ func (b *QuaiAPIBackend) StateAtTransaction(ctx context.Context, block *types.Wo
return b.quai.core.StateAtTransaction(block, txIndex, reexec)
}

func (b *QuaiAPIBackend) CalcMaxBaseFee(block *types.WorkObject) (*big.Int, error) {
nodeCtx := b.quai.core.NodeCtx()
if nodeCtx != common.ZONE_CTX {
return nil, errors.New("CalcMaxBaseFee can only be called in zone chain")
}
return b.quai.core.CalcMaxBaseFee(block)
}

func (b *QuaiAPIBackend) Append(header *types.WorkObject, manifest types.BlockManifest, domTerminus common.Hash, domOrigin bool, newInboundEtxs types.Transactions) (types.Transactions, error) {
return b.quai.core.Append(header, manifest, domTerminus, domOrigin, newInboundEtxs)
}
Expand Down Expand Up @@ -681,6 +693,10 @@ func (b *QuaiAPIBackend) GetTerminiByHash(hash common.Hash) *types.Termini {
return b.quai.core.GetTerminiByHash(hash)
}

func (b *QuaiAPIBackend) CheckIfEtxIsEligible(hash common.Hash, location common.Location) bool {
return b.quai.core.CheckIfEtxIsEligible(hash, location)
}

func (b *QuaiAPIBackend) IsGenesisHash(hash common.Hash) bool {
return b.quai.core.IsGenesisHash(hash)
}
Expand Down
Loading

0 comments on commit 2fabfb0

Please sign in to comment.