-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(all): preconfs #281
feat(all): preconfs #281
Changes from 1 commit
c8648e9
5c474c0
ed57045
9e91c83
e4147eb
9316c67
3e33107
962c01a
d4ae804
283c866
07d9ac7
8175e6d
0be6e70
c09982c
11547c6
86dc5a9
ca1606a
7c97fef
28837e2
22827b7
239690d
a175b68
e085b23
c8e4db3
9dc9717
002515b
f61e2dd
aeeeda0
d1ebecb
58b373f
ffd909d
4edd506
6a3418e
b138398
139410e
7e281e2
323c733
6cd1f75
f07fe35
9d01948
cd44d64
7391e27
4ccf51d
d1ab2fb
bf451ad
b96e4b7
6674bcf
cd7ecf3
b46389f
9a8241c
c579ad7
6f0827b
c6597c6
a2e96fd
7510e3c
649a1e5
dc64cdf
34d90f5
66e3912
4f349c3
47b52e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -180,6 +180,7 @@ var ( | |||||
utils.AllowUnprotectedTxs, | ||||||
utils.BatchRequestLimit, | ||||||
utils.BatchResponseMaxSize, | ||||||
utils.PreconfirmationForwardingURLFlag, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
metricsFlags = []cli.Flag{ | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -101,6 +101,9 @@ type Ethereum struct { | |||||
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 | ||||||
|
||||||
// change(taiko) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||||||
PreconfirmationForwardingURL string | ||||||
} | ||||||
|
||||||
// New creates a new Ethereum object (including the | ||||||
|
@@ -252,7 +255,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { | |||||
eth.miner = miner.New(eth, &config.Miner, eth.blockchain.Config(), eth.EventMux(), eth.engine, eth.isLocalBlock) | ||||||
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData)) | ||||||
|
||||||
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil} | ||||||
// change(TAIKO): preconfirmation URL | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
log.Info("preconf url in eth.New", "url", config.PreconfirmationForwardingURL) | ||||||
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil, config.PreconfirmationForwardingURL} | ||||||
if eth.APIBackend.allowUnprotectedTxs { | ||||||
log.Info("Unprotected transactions allowed") | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -160,6 +160,9 @@ type Config struct { | |||||
|
||||||
// OverrideVerkle (TODO: remove after the fork) | ||||||
OverrideVerkle *uint64 `toml:",omitempty"` | ||||||
|
||||||
// change(taiko): preconf url | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
PreconfirmationForwardingURL string | ||||||
} | ||||||
|
||||||
// CreateConsensusEngine creates a consensus engine for the given chain config. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package ethapi | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/ethereum/go-ethereum/common/hexutil" | ||
) | ||
|
||
type InclusionPreconfirmationRequest struct { | ||
Tx []byte `json:"tx"` | ||
Slot uint64 `json:"slot"` | ||
Signature string `json:"signature"` | ||
} | ||
|
||
type InclusionPreconfirmationResponse struct { | ||
Request InclusionPreconfirmationRequest `json:"request"` | ||
ProposerSignature string `json:"proposerSignature"` | ||
} | ||
|
||
// change(taiko) | ||
func forwardRawTransaction(forwardURL string, input hexutil.Bytes, slot uint64, signature string) (*InclusionPreconfirmationResponse, error) { | ||
mask-pp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Prepare the request | ||
request := InclusionPreconfirmationRequest{ | ||
Tx: input, | ||
Slot: slot, // Set the appropriate slot value | ||
Signature: signature, // Set the appropriate signature value (a keccak256 hash) | ||
} | ||
|
||
jsonData, err := json.Marshal(request) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Send the request | ||
req, err := http.NewRequest("POST", fmt.Sprintf("%v/%v", forwardURL, "commitments/v1/request_preconf"), 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) | ||
} | ||
|
||
// Parse the response | ||
var response InclusionPreconfirmationResponse | ||
err = json.NewDecoder(resp.Body).Decode(&response) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &response, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto