mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-05 19:43:47 +00:00
chore(cmd): remove --taiko.preconfirmationForwardingUrl flag (#362)
* remove forwading tx's, as will be fetched from mempool * addtl config
This commit is contained in:
parent
a2cbf904ea
commit
283fedd05b
11 changed files with 5 additions and 147 deletions
|
|
@ -192,11 +192,6 @@ func makeFullNode(ctx *cli.Context) *node.Node {
|
||||||
cfg.Eth.OverrideVerkle = &v
|
cfg.Eth.OverrideVerkle = &v
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHANGE(taiko): set preconfirmation forwarding URL.
|
|
||||||
if ctx.IsSet(utils.PreconfirmationForwardingURLFlag.Name) {
|
|
||||||
cfg.Eth.PreconfirmationForwardingURL = ctx.String(utils.PreconfirmationForwardingURLFlag.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
backend, eth := utils.RegisterEthService(stack, &cfg.Eth)
|
backend, eth := utils.RegisterEthService(stack, &cfg.Eth)
|
||||||
|
|
||||||
// CHANGE(TAIKO): register Taiko RPC APIs.
|
// CHANGE(TAIKO): register Taiko RPC APIs.
|
||||||
|
|
|
||||||
|
|
@ -260,8 +260,6 @@ func init() {
|
||||||
debug.Flags,
|
debug.Flags,
|
||||||
metricsFlags,
|
metricsFlags,
|
||||||
)
|
)
|
||||||
// CHANGE(taiko): append Taiko flags into the original GETH flags
|
|
||||||
app.Flags = append(app.Flags, utils.TaikoFlag, utils.PreconfirmationForwardingURLFlag)
|
|
||||||
|
|
||||||
flags.AutoEnvVars(app.Flags, "GETH")
|
flags.AutoEnvVars(app.Flags, "GETH")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,6 @@ var (
|
||||||
Usage: "Taiko network",
|
Usage: "Taiko network",
|
||||||
Category: flags.TaikoCategory,
|
Category: flags.TaikoCategory,
|
||||||
}
|
}
|
||||||
PreconfirmationForwardingURLFlag = &cli.StringFlag{
|
|
||||||
Name: "taiko.preconfirmationForwardingUrl",
|
|
||||||
Usage: "URL to forward RPC requests before confirmation",
|
|
||||||
Category: flags.TaikoCategory,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterTaikoAPIs initializes and registers the Taiko RPC APIs.
|
// RegisterTaikoAPIs initializes and registers the Taiko RPC APIs.
|
||||||
|
|
|
||||||
|
|
@ -44,11 +44,10 @@ import (
|
||||||
|
|
||||||
// EthAPIBackend implements ethapi.Backend and tracers.Backend for full nodes
|
// EthAPIBackend implements ethapi.Backend and tracers.Backend for full nodes
|
||||||
type EthAPIBackend struct {
|
type EthAPIBackend struct {
|
||||||
extRPCEnabled bool
|
extRPCEnabled bool
|
||||||
allowUnprotectedTxs bool
|
allowUnprotectedTxs bool
|
||||||
eth *Ethereum
|
eth *Ethereum
|
||||||
gpo *gasprice.Oracle
|
gpo *gasprice.Oracle
|
||||||
preconfirmationForwardingURL string // CHANGE(taiko): add preconfirmation forwarding URL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChainConfig returns the active chain configuration.
|
// ChainConfig returns the active chain configuration.
|
||||||
|
|
@ -432,8 +431,3 @@ func (b *EthAPIBackend) StateAtBlock(ctx context.Context, block *types.Block, re
|
||||||
func (b *EthAPIBackend) StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (*types.Transaction, vm.BlockContext, *state.StateDB, tracers.StateReleaseFunc, error) {
|
func (b *EthAPIBackend) StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (*types.Transaction, vm.BlockContext, *state.StateDB, tracers.StateReleaseFunc, error) {
|
||||||
return b.eth.stateAtTransaction(ctx, block, txIndex, reexec)
|
return b.eth.stateAtTransaction(ctx, block, txIndex, reexec)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPreconfirmationForwardingURL returns the URL to forward RPC requests before confirmation.
|
|
||||||
func (b *EthAPIBackend) GetPreconfirmationForwardingURL() string {
|
|
||||||
return b.preconfirmationForwardingURL
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,6 @@ type Ethereum struct {
|
||||||
lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
|
lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
|
||||||
|
|
||||||
shutdownTracker *shutdowncheck.ShutdownTracker // Tracks if and when the node has shutdown ungracefully
|
shutdownTracker *shutdowncheck.ShutdownTracker // Tracks if and when the node has shutdown ungracefully
|
||||||
|
|
||||||
PreconfirmationForwardingURL string // CHANGE(taiko): add preconfirmation forwarding URL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new Ethereum object (including the initialisation of the common Ethereum object),
|
// New creates a new Ethereum object (including the initialisation of the common Ethereum object),
|
||||||
|
|
@ -257,7 +255,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
|
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
|
||||||
|
|
||||||
// CHANGE(taiko): set up the pre-confirmation forwarding URL
|
// CHANGE(taiko): set up the pre-confirmation forwarding URL
|
||||||
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil, config.PreconfirmationForwardingURL}
|
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
|
||||||
if eth.APIBackend.allowUnprotectedTxs {
|
if eth.APIBackend.allowUnprotectedTxs {
|
||||||
log.Info("Unprotected transactions allowed")
|
log.Info("Unprotected transactions allowed")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,9 +157,6 @@ type Config struct {
|
||||||
|
|
||||||
// OverrideVerkle (TODO: remove after the fork)
|
// OverrideVerkle (TODO: remove after the fork)
|
||||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||||
|
|
||||||
// CHANGE(taiko): add preconfirmation forwarding URL
|
|
||||||
PreconfirmationForwardingURL string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateConsensusEngine creates a consensus engine for the given chain config.
|
// CreateConsensusEngine creates a consensus engine for the given chain config.
|
||||||
|
|
|
||||||
|
|
@ -1974,18 +1974,6 @@ func (api *TransactionAPI) FillTransaction(ctx context.Context, args Transaction
|
||||||
// SendRawTransaction will add the signed transaction to the transaction pool.
|
// SendRawTransaction will add the signed transaction to the transaction pool.
|
||||||
// The sender is responsible for signing the transaction and using the correct nonce.
|
// The sender is responsible for signing the transaction and using the correct nonce.
|
||||||
func (api *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error) {
|
func (api *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error) {
|
||||||
// CHANGE(taiko): Forward the request to the preconf node if specified.
|
|
||||||
if forwardURL := api.b.GetPreconfirmationForwardingURL(); forwardURL != "" {
|
|
||||||
log.Info("Forwarding SendRawTransaction request", "forwardURL", forwardURL)
|
|
||||||
// Forward the raw transaction to the specified URL
|
|
||||||
h, err := forward[string](forwardURL, "eth_sendRawTransaction", []interface{}{input.String()})
|
|
||||||
if err == nil && h != nil {
|
|
||||||
return common.HexToHash(*h), nil
|
|
||||||
} else {
|
|
||||||
return common.Hash{}, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tx := new(types.Transaction)
|
tx := new(types.Transaction)
|
||||||
if err := tx.UnmarshalBinary(input); err != nil {
|
if err := tx.UnmarshalBinary(input); err != nil {
|
||||||
return common.Hash{}, err
|
return common.Hash{}, err
|
||||||
|
|
|
||||||
|
|
@ -3400,8 +3400,3 @@ func testRPCResponseWithFile(t *testing.T, testid int, result interface{}, rpc s
|
||||||
func addressToHash(a common.Address) common.Hash {
|
func addressToHash(a common.Address) common.Hash {
|
||||||
return common.BytesToHash(a.Bytes())
|
return common.BytesToHash(a.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHANGE(taiko): add preconfirmation forwarding URL
|
|
||||||
func (b testBackend) GetPreconfirmationForwardingURL() string {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -96,9 +96,6 @@ type Backend interface {
|
||||||
SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription
|
SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription
|
||||||
BloomStatus() (uint64, uint64)
|
BloomStatus() (uint64, uint64)
|
||||||
ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
|
ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
|
||||||
|
|
||||||
// CHANGE(taiko): add preconfirmation forwarding URL
|
|
||||||
GetPreconfirmationForwardingURL() string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAPIs(apiBackend Backend) []rpc.API {
|
func GetAPIs(apiBackend Backend) []rpc.API {
|
||||||
|
|
|
||||||
|
|
@ -1,94 +0,0 @@
|
||||||
package ethapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
type rpcRequest struct {
|
|
||||||
Jsonrpc string `json:"jsonrpc"`
|
|
||||||
Method string `json:"method"`
|
|
||||||
Params []interface{} `json:"params"`
|
|
||||||
ID int `json:"id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type rpcResponse struct {
|
|
||||||
Jsonrpc string `json:"jsonrpc"`
|
|
||||||
ID int `json:"id"`
|
|
||||||
Result *json.RawMessage `json:"result"`
|
|
||||||
Error *struct {
|
|
||||||
Code int `json:"code"`
|
|
||||||
Message string `json:"message"`
|
|
||||||
Data string `json:"data"`
|
|
||||||
} `json:"error,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func forward[T any](forwardURL string, method string, params []interface{}) (*T, error) {
|
|
||||||
rpcReq := rpcRequest{
|
|
||||||
Jsonrpc: "2.0",
|
|
||||||
Method: method,
|
|
||||||
Params: params,
|
|
||||||
ID: 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonData, err := json.Marshal(rpcReq)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", forwardURL, bytes.NewBuffer(jsonData))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
|
||||||
|
|
||||||
client := &http.Client{}
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
|
||||||
return nil, fmt.Errorf("failed to forward transaction, status code: %d", resp.StatusCode)
|
|
||||||
}
|
|
||||||
|
|
||||||
body, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var rpcResp rpcResponse
|
|
||||||
|
|
||||||
// Unmarshal the response into the struct
|
|
||||||
if err := json.Unmarshal(body, &rpcResp); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for errors in the response
|
|
||||||
if rpcResp.Error != nil {
|
|
||||||
err := fmt.Errorf("RPC error %d: %s", rpcResp.Error.Code, rpcResp.Error.Message)
|
|
||||||
|
|
||||||
log.Error("forwarded request error", "err", err, "method", method, "params", params)
|
|
||||||
|
|
||||||
return nil, fmt.Errorf("RPC error %d: %s", rpcResp.Error.Code, rpcResp.Error.Message)
|
|
||||||
}
|
|
||||||
|
|
||||||
if rpcResp.Result == nil {
|
|
||||||
log.Warn("forwarded request result is nil", "method", method)
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmarshal the Result into the desired type
|
|
||||||
var result T
|
|
||||||
if err := json.Unmarshal(*rpcResp.Result, &result); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &result, nil
|
|
||||||
}
|
|
||||||
|
|
@ -405,8 +405,3 @@ func (b *backendMock) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *backendMock) Engine() consensus.Engine { return nil }
|
func (b *backendMock) Engine() consensus.Engine { return nil }
|
||||||
|
|
||||||
// CHANGE(taiko): add preconfirmation forwarding URL
|
|
||||||
func (b *backendMock) GetPreconfirmationForwardingURL() string {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue