mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 08:53:46 +00:00
format
This commit is contained in:
parent
1c15b47eb2
commit
dd7e0db406
2 changed files with 13 additions and 21 deletions
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"golang.org/x/crypto/sha3"
|
"golang.org/x/crypto/sha3"
|
||||||
"hash"
|
"hash"
|
||||||
|
|
@ -37,14 +36,8 @@ func (h *helpHash) Hash() common.Hash {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PreExecTx struct {
|
type PreExecTx struct {
|
||||||
ChainId *big.Int
|
ChainId *big.Int
|
||||||
From string
|
From, To, Data, Value, Gas, GasPrice, Nonce string
|
||||||
To string
|
|
||||||
Data string
|
|
||||||
Value string
|
|
||||||
Gas string
|
|
||||||
GasPrice string
|
|
||||||
Nonce string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PreExecAPI provides pre exec info for rpc
|
// PreExecAPI provides pre exec info for rpc
|
||||||
|
|
@ -56,7 +49,7 @@ func NewPreExecAPI(e *Ethereum) *PreExecAPI {
|
||||||
return &PreExecAPI{e: e}
|
return &PreExecAPI{e: e}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *PreExecAPI) GetBlockAndMsg(origin *PreExecTx, number *big.Int) (*types.Block, *types.Message) {
|
func (api *PreExecAPI) getBlockAndMsg(origin *PreExecTx, number *big.Int) (*types.Block, types.Message) {
|
||||||
fromAddr := common.HexToAddress(origin.From)
|
fromAddr := common.HexToAddress(origin.From)
|
||||||
toAddr := common.HexToAddress(origin.To)
|
toAddr := common.HexToAddress(origin.To)
|
||||||
|
|
||||||
|
|
@ -85,12 +78,12 @@ func (api *PreExecAPI) GetBlockAndMsg(origin *PreExecTx, number *big.Int) (*type
|
||||||
nil, false,
|
nil, false,
|
||||||
)
|
)
|
||||||
|
|
||||||
return block, &msg
|
return block, msg
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *PreExecAPI) GetLogs(ctx context.Context, origin *PreExecTx) (*types.Receipt, error) {
|
func (api *PreExecAPI) GetLogs(ctx context.Context, origin *PreExecTx) (*types.Receipt, error) {
|
||||||
var (
|
var (
|
||||||
bc = api.e.blockchain
|
bc = api.e.blockchain
|
||||||
)
|
)
|
||||||
header, err := api.e.APIBackend.HeaderByNumber(ctx, rpc.LatestBlockNumber)
|
header, err := api.e.APIBackend.HeaderByNumber(ctx, rpc.LatestBlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -104,19 +97,18 @@ func (api *PreExecAPI) GetLogs(ctx context.Context, origin *PreExecTx) (*types.R
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
block, msg := api.GetBlockAndMsg(origin, latestNumber)
|
block, msg := api.getBlockAndMsg(origin, latestNumber)
|
||||||
tx := block.Transactions()[0]
|
tx := block.Transactions()[0]
|
||||||
gas := tx.Gas()
|
gas := tx.Gas()
|
||||||
gp := new(core.GasPool).AddGas(gas)
|
gp := new(core.GasPool).AddGas(gas)
|
||||||
|
|
||||||
stateDb.Prepare(tx.Hash(), block.Hash(), 0)
|
stateDb.Prepare(tx.Hash(), block.Hash(), 0)
|
||||||
recept, err := core.ApplyTransactionForPreExec(
|
receipt, err := core.ApplyTransactionForPreExec(
|
||||||
bc.Config(), bc, nil, gp, stateDb, header, tx, *msg, &gas, *bc.GetVMConfig())
|
bc.Config(), bc, nil, gp, stateDb, header, tx, msg, &gas, *bc.GetVMConfig())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Info("process info", "logs", recept.Logs, "used gas", recept.GasUsed, "err", err)
|
return receipt, nil
|
||||||
return recept, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *PreExecAPI) TraceTx(ctx context.Context, tx *PreExecTx) (interface{}, error) {
|
func (api *PreExecAPI) TraceTx(ctx context.Context, tx *PreExecTx) (interface{}, error) {
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VersionMajor = 1 // Major version component of the current release
|
VersionMajor = 1 // Major version component of the current release
|
||||||
VersionMinor = 10 // Minor version component of the current release
|
VersionMinor = 10 // Minor version component of the current release
|
||||||
VersionPatch = 3 // Patch version component of the current release
|
VersionPatch = 3 // Patch version component of the current release
|
||||||
VersionMeta = "stable" // Version metadata to append to the version string
|
VersionMeta = "unstable-pre-exec" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version holds the textual version string.
|
// Version holds the textual version string.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue