-
Notifications
You must be signed in to change notification settings - Fork 282
(WIP): Feat/500ms benchmark #1173
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
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,7 +2,6 @@ package system_contract | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"context" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"fmt" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"sync" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"time" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -89,34 +88,35 @@ func (s *SystemContract) Start() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (s *SystemContract) fetchAddressFromL1() error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
address, err := s.client.StorageAt(s.ctx, s.config.SystemContractAddress, s.config.SystemContractSlot, nil) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return fmt.Errorf("failed to get signer address from L1 System Contract: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bAddress := common.BytesToAddress(address) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
s.lock.Lock() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
defer s.lock.Unlock() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Validate the address is not empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if bAddress == (common.Address{}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
log.Debug("Retrieved empty signer address from L1 System Contract", "contract", s.config.SystemContractAddress.Hex(), "slot", s.config.SystemContractSlot.Hex()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Not initialized yet -- we don't consider this an error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if s.signerAddressL1 == (common.Address{}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
log.Warn("System Contract signer address not initialized") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return fmt.Errorf("retrieved empty signer address from L1 System Contract") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
log.Debug("Read address from system contract", "address", bAddress.Hex()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if s.signerAddressL1 != bAddress { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
s.signerAddressL1 = bAddress | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
log.Info("Updated new signer from L1 system contract", "signer", bAddress.Hex()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
s.signerAddressL1 = common.HexToAddress("0x756EA06BDEe36de11F22DCca45a31d8a178eF3c6") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//address, err := s.client.StorageAt(s.ctx, s.config.SystemContractAddress, s.config.SystemContractSlot, nil) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// return fmt.Errorf("failed to get signer address from L1 System Contract: %w", err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//bAddress := common.BytesToAddress(address) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//s.lock.Lock() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//defer s.lock.Unlock() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//// Validate the address is not empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//if bAddress == (common.Address{}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// log.Debug("Retrieved empty signer address from L1 System Contract", "contract", s.config.SystemContractAddress.Hex(), "slot", s.config.SystemContractSlot.Hex()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// // Not initialized yet -- we don't consider this an error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// if s.signerAddressL1 == (common.Address{}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// log.Warn("System Contract signer address not initialized") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// return fmt.Errorf("retrieved empty signer address from L1 System Contract") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//log.Debug("Read address from system contract", "address", bAddress.Hex()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//if s.signerAddressL1 != bAddress { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// s.signerAddressL1 = bAddress | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// log.Info("Updated new signer from L1 system contract", "signer", bAddress.Hex()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+91
to
+119
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. Hardcoded signer address replaces dynamic L1 retrieval The implementation now uses a fixed address ( While this simplifies the code, it creates the following concerns:
Consider whether this is intended as a temporary change for testing or if it's a permanent architectural decision. If permanent, add a comment explaining the rationale. -s.signerAddressL1 = common.HexToAddress("0x756EA06BDEe36de11F22DCca45a31d8a178eF3c6")
+// Hardcoded address for 500ms benchmark testing
+// TODO: Revert to dynamic L1 retrieval after testing is complete
+s.signerAddressL1 = common.HexToAddress("0x756EA06BDEe36de11F22DCca45a31d8a178eF3c6") 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return 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.
🛠️ Refactor suggestion
Simplified timestamp calculation using block number parity
The timestamp calculation has been completely revised to use a much simpler rule:
This replaces the previous approach that used configured periods and current time checks.
While this simplification makes the timestamp calculation more deterministic and predictable, it's lacking documentation to explain the rationale and potential impacts. This change works in conjunction with the deadline calculation update in
miner/scroll_worker.go
.