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 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 } diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index b95fb6027aee..db9f559cf7ab 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 + 500*((header.Number.Uint64()+1)%2) + w.chainConfig.SystemContract.Period)) } w.current = &work{