-
Notifications
You must be signed in to change notification settings - Fork 4k
geth: implement sync service spec #477
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
Changes from all commits
8599671
488c216
79ceb3d
376a378
ecd01fa
24b102a
de9515f
fd48c5c
29701bf
6a373d6
d743630
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@eth-optimism/l2geth": minor | ||
| --- | ||
|
|
||
| Implement the SyncService spec |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -44,3 +44,22 @@ func WriteHeadQueueIndex(db ethdb.KeyValueWriter, index uint64) { | |||||
| log.Crit("Failed to store queue index", "err", err) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| func ReadHeadVerifiedIndex(db ethdb.KeyValueReader) *uint64 { | ||||||
| data, _ := db.Get(headVerifiedIndexKey) | ||||||
| if len(data) == 0 { | ||||||
| return nil | ||||||
| } | ||||||
| ret := new(big.Int).SetBytes(data).Uint64() | ||||||
| return &ret | ||||||
| } | ||||||
|
|
||||||
| func WriteHeadVerifiedIndex(db ethdb.KeyValueWriter, index uint64) { | ||||||
| value := new(big.Int).SetUint64(index).Bytes() | ||||||
| if index == 0 { | ||||||
| value = []byte{0} | ||||||
| } | ||||||
| if err := db.Put(headVerifiedIndexKey, value); err != nil { | ||||||
| log.Crit("Failed to store verfied index", "err", err) | ||||||
|
Contributor
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. Typo
Suggested change
|
||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,9 +71,10 @@ func (b *EthAPIBackend) GetEthContext() (uint64, uint64) { | |
| return bn, ts | ||
| } | ||
|
|
||
| func (b *EthAPIBackend) GetRollupContext() (uint64, uint64) { | ||
| func (b *EthAPIBackend) GetRollupContext() (uint64, uint64, uint64) { | ||
| i := uint64(0) | ||
| q := uint64(0) | ||
| v := uint64(0) | ||
|
tynes marked this conversation as resolved.
|
||
| index := b.eth.syncService.GetLatestIndex() | ||
| if index != nil { | ||
| i = *index | ||
|
|
@@ -82,7 +83,11 @@ func (b *EthAPIBackend) GetRollupContext() (uint64, uint64) { | |
| if queueIndex != nil { | ||
| q = *queueIndex | ||
| } | ||
| return i, q | ||
| verifiedIndex := b.eth.syncService.GetLatestVerifiedIndex() | ||
| if verifiedIndex != nil { | ||
| v = *verifiedIndex | ||
| } | ||
| return i, q, v | ||
| } | ||
|
|
||
| // ChainConfig returns the active chain configuration. | ||
|
|
@@ -318,7 +323,7 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) | |
| return fmt.Errorf("Calldata cannot be larger than %d, sent %d", b.MaxCallDataSize, len(signedTx.Data())) | ||
| } | ||
| } | ||
| return b.eth.syncService.ApplyTransaction(signedTx) | ||
| return b.eth.syncService.ValidateAndApplySequencerTransaction(signedTx) | ||
|
Contributor
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. Any particular reason for the rename? Validation is something that every function should do anyway, don't think we should be explicitly saying it in the name?
Contributor
Author
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. I was copying the spec and there was strong opinions around naming the function that in the spec. I'm not super opinionated on this particular topic, but some functions assume validation has already happened |
||
| } | ||
| // OVM Disabled | ||
| return b.eth.txPool.AddLocal(signedTx) | ||
|
|
||
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.