From 6ea46893478311ef049e391d1432b246fe07876a Mon Sep 17 00:00:00 2001 From: georgehao Date: Fri, 25 Apr 2025 15:16:28 +0800 Subject: [PATCH 1/5] mock signer address --- consensus/system_contract/system_contract.go | 58 ++++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/consensus/system_contract/system_contract.go b/consensus/system_contract/system_contract.go index a93968e873fc..b775e3f2f60d 100644 --- a/consensus/system_contract/system_contract.go +++ b/consensus/system_contract/system_contract.go @@ -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()) + //} return nil } From c44e300ff4b7aac3986ffe54bae6c7d9e3a01e9e Mon Sep 17 00:00:00 2001 From: georgehao Date: Fri, 25 Apr 2025 17:58:32 +0800 Subject: [PATCH 2/5] change peroid from s -> ms --- miner/scroll_worker.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index b95fb6027aee..a210b961738f 100644 --- a/miner/scroll_worker.go +++ b/miner/scroll_worker.go @@ -552,6 +552,7 @@ func (w *worker) newWork(now time.Time, parentHash common.Hash, reorging bool, r vmConfig.Debug = true vmConfig.Tracer = cccLogger } + deadline := time.Unix(int64(header.Time), 0) if w.chainConfig.Clique != nil && w.chainConfig.Clique.RelaxedPeriod { // clique with relaxed period uses time.Now() as the header.Time, calculate the deadline @@ -559,7 +560,7 @@ func (w *worker) newWork(now time.Time, parentHash common.Hash, reorging bool, r } if w.chainConfig.SystemContract != nil && w.chainConfig.SystemContract.RelaxedPeriod { // system contract with relaxed period uses time.Now() as the header.Time, calculate the deadline - deadline = time.Unix(int64(header.Time+w.chainConfig.SystemContract.Period), 0) + deadline = time.UnixMilli(int64(header.Time*1000 + w.chainConfig.SystemContract.Period)) } w.current = &work{ From ff0fa925f56363905636f5a49c265d5f5935a7f1 Mon Sep 17 00:00:00 2001 From: georgehao Date: Fri, 25 Apr 2025 19:17:19 +0800 Subject: [PATCH 3/5] update --- miner/scroll_worker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index a210b961738f..3e5bbbca0332 100644 --- a/miner/scroll_worker.go +++ b/miner/scroll_worker.go @@ -560,7 +560,7 @@ func (w *worker) newWork(now time.Time, parentHash common.Hash, reorging bool, r } if w.chainConfig.SystemContract != nil && w.chainConfig.SystemContract.RelaxedPeriod { // system contract with relaxed period uses time.Now() as the header.Time, calculate the deadline - deadline = time.UnixMilli(int64(header.Time*1000 + w.chainConfig.SystemContract.Period)) + deadline = time.UnixMilli(int64(header.Time*1000 + 500*((header.Number.Uint64()+1)%2+1) + w.chainConfig.SystemContract.Period)) } w.current = &work{ From 1e03b6c6cbfd409deac64cacc49db0bafabff572 Mon Sep 17 00:00:00 2001 From: georgehao Date: Fri, 25 Apr 2025 20:14:32 +0800 Subject: [PATCH 4/5] calcTIme+1 --- consensus/system_contract/consensus.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/consensus/system_contract/consensus.go b/consensus/system_contract/consensus.go index 797297870d86..d9f1f593e610 100644 --- a/consensus/system_contract/consensus.go +++ b/consensus/system_contract/consensus.go @@ -226,15 +226,23 @@ func (s *SystemContract) VerifyUncles(chain consensus.ChainReader, block *types. } func (s *SystemContract) CalcTimestamp(parent *types.Header) uint64 { - timestamp := parent.Time + s.config.Period + timestamp := parent.Time - // If RelaxedPeriod is enabled, always set the header timestamp to now (ie the time we start building it) as - // we don't know when it will be sealed - if s.config.RelaxedPeriod || timestamp < uint64(time.Now().Unix()) { - timestamp = uint64(time.Now().Unix()) + if parent.Number.Uint64()%2 == 0 { + timestamp += 1 } return timestamp + + //timestamp := parent.Time + s.config.Period + // + //// If RelaxedPeriod is enabled, always set the header timestamp to now (ie the time we start building it) as + //// we don't know when it will be sealed + //if s.config.RelaxedPeriod || timestamp < uint64(time.Now().Unix()) { + // timestamp = uint64(time.Now().Unix()) + //} + // + //return timestamp } // Prepare initializes the consensus fields of a block header according to the From 4c5ec01d0402bed1b4d3f35fa5c0eadec8df7d08 Mon Sep 17 00:00:00 2001 From: georgehao Date: Fri, 25 Apr 2025 20:33:13 +0800 Subject: [PATCH 5/5] update +2 --- miner/scroll_worker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index 3e5bbbca0332..db9f559cf7ab 100644 --- a/miner/scroll_worker.go +++ b/miner/scroll_worker.go @@ -560,7 +560,7 @@ func (w *worker) newWork(now time.Time, parentHash common.Hash, reorging bool, r } if w.chainConfig.SystemContract != nil && w.chainConfig.SystemContract.RelaxedPeriod { // system contract with relaxed period uses time.Now() as the header.Time, calculate the deadline - deadline = time.UnixMilli(int64(header.Time*1000 + 500*((header.Number.Uint64()+1)%2+1) + w.chainConfig.SystemContract.Period)) + deadline = time.UnixMilli(int64(header.Time*1000 + 500*((header.Number.Uint64()+1)%2) + w.chainConfig.SystemContract.Period)) } w.current = &work{