Skip to content
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

Remove SMT logic for Zero Prover #1374

Open
wants to merge 2 commits into
base: zkevm
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions core/blockchain_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,26 @@ func ExecuteBlockEphemerallyZk(
}

var l2InfoRoot *libcommon.Hash
if chainConfig.IsForkID7Etrog(blockNum) {
l2InfoRoot, err = blockinfo.BuildBlockInfoTree(
&header.Coinbase,
header.Number.Uint64(),
header.Time,
blockGasLimit,
*usedGas,
*ger,
*l1Blockhash,
*prevBlockRoot,
&txInfos,
)
if err != nil {
return nil, err
if !chainConfig.IsNormalcy(blockNum) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if chainConfig.IsForkID7Etrog(blockNum) {
l2InfoRoot, err = blockinfo.BuildBlockInfoTree(
&header.Coinbase,
header.Number.Uint64(),
header.Time,
blockGasLimit,
*usedGas,
*ger,
*l1Blockhash,
*prevBlockRoot,
&txInfos,
)
if err != nil {
return nil, err
}
}
}

ibs.PostExecuteStateSet(chainConfig, block.NumberU64(), l2InfoRoot)
ibs.PostExecuteStateSet(chainConfig, block.NumberU64(), l2InfoRoot)
}

receiptSha := types.DeriveSha(receipts)
// [zkevm] todo
Expand Down
42 changes: 24 additions & 18 deletions core/state/intra_block_state_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (sdb *IntraBlockState) GetTxCount() (uint64, error) {

func (sdb *IntraBlockState) PostExecuteStateSet(chainConfig *chain.Config, blockNum uint64, blockInfoRoot *libcommon.Hash) {
//ETROG
if chainConfig.IsForkID7Etrog(blockNum) {
if chainConfig.IsForkID7Etrog(blockNum) && !chainConfig.IsNormalcy(blockNum) {
sdb.scalableSetBlockInfoRoot(blockInfoRoot)
}
}
Expand All @@ -70,18 +70,20 @@ func (sdb *IntraBlockState) PreExecuteStateSet(chainConfig *chain.Config, blockN
sdb.CreateAccount(ADDRESS_SCALABLE_L2, true)
}

//save block number
sdb.scalableSetBlockNum(blockNumber)
if !chainConfig.IsNormalcy(blockNumber) {
//save block number
sdb.scalableSetBlockNum(blockNumber)

//ETROG
if chainConfig.IsForkID7Etrog(blockNumber) {
currentTimestamp := sdb.ScalableGetTimestamp()
if blockTimestamp > currentTimestamp {
sdb.ScalableSetTimestamp(blockTimestamp)
}
//ETROG
if chainConfig.IsForkID7Etrog(blockNumber) {
currentTimestamp := sdb.ScalableGetTimestamp()
if blockTimestamp > currentTimestamp {
sdb.ScalableSetTimestamp(blockTimestamp)
}

//save prev block hash
sdb.scalableSetBlockHash(blockNumber-1, stateRoot)
//save prev block hash
sdb.scalableSetBlockHash(blockNumber-1, stateRoot)
}
}
}

Expand All @@ -99,18 +101,22 @@ func (sdb *IntraBlockState) SyncerPreExecuteStateSet(
}

//save block number
sdb.scalableSetBlockNum(blockNumber)
if !chainConfig.IsNormalcy(blockNumber) {
sdb.scalableSetBlockNum(blockNumber)
}
emptyHash := libcommon.Hash{}

//ETROG
if chainConfig.IsForkID7Etrog(blockNumber) {
currentTimestamp := sdb.ScalableGetTimestamp()
if blockTimestamp > currentTimestamp {
sdb.ScalableSetTimestamp(blockTimestamp)
}
if !chainConfig.IsNormalcy(blockNumber) {
currentTimestamp := sdb.ScalableGetTimestamp()
if blockTimestamp > currentTimestamp {
sdb.ScalableSetTimestamp(blockTimestamp)
}

//save prev block hash
sdb.scalableSetBlockHash(blockNumber-1, prevBlockHash)
//save prev block hash
sdb.scalableSetBlockHash(blockNumber-1, prevBlockHash)
}

//save ger with l1blockhash - but only in the case that the l1 info tree index hasn't been
// re-used. If it has been re-used we never write this to the contract storage
Expand Down
4 changes: 3 additions & 1 deletion zk/stages/stage_sequence_execute_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ func postBlockStateHandling(
return err
}

ibs.PostExecuteStateSet(cfg.chainConfig, header.Number.Uint64(), blockInfoRootHash)
if !cfg.chainConfig.IsNormalcy(header.Number.Uint64()) {
ibs.PostExecuteStateSet(cfg.chainConfig, header.Number.Uint64(), blockInfoRootHash)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PostExecuteStateSet function already contains the Normalcy HF check https://github.com/0xPolygonHermez/cdk-erigon/pull/1374/files?diff=split&w=0#diff-906193e92d24cc2159eff21e18a9732fa141799cc377b8e698902e0f2fd01176R62. IMO it is safe to remove it from here

}

// store a reference to this block info root against the block number
return hermezDb.WriteBlockInfoRoot(header.Number.Uint64(), *blockInfoRootHash)
Expand Down
Loading