-
Notifications
You must be signed in to change notification settings - Fork 46
EIP-7823 and EIP-7883 implementation --- Osaka MODEXP changes
#2477
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
base: arith-dev
Are you sure you want to change the base?
Changes from 9 commits
089f81c
bd40fca
4718cd1
0bd9eef
56978e9
1bcb4a3
5be004c
de62eed
613c290
7898299
09ba3c8
799e5ae
b9351dc
448e1bc
516f1ef
c7374ee
e7f461e
e1591ee
a951f32
cbf716f
14d43b2
84ec172
e0ee516
5d496ea
cc7cca1
604d294
f97e56c
5fbf41e
3c7db9d
1f0bb09
cc31318
af5ecfb
fc8217f
54c8057
18ea99c
cfa8e8e
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 |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
|
|
||
| package net.consensys.linea.zktracer.module.blake2fmodexpdata; | ||
|
|
||
| import static com.google.common.base.Preconditions.checkState; | ||
| import static net.consensys.linea.zktracer.module.ModuleName.BLAKE_MODEXP_DATA; | ||
|
|
||
| import java.util.List; | ||
|
|
@@ -28,21 +29,20 @@ | |
| import net.consensys.linea.zktracer.container.module.OperationListModule; | ||
| import net.consensys.linea.zktracer.container.stacked.ModuleOperationStackedList; | ||
| import net.consensys.linea.zktracer.module.ModuleName; | ||
| import net.consensys.linea.zktracer.module.hub.precompiles.ModexpMetadata; | ||
| import net.consensys.linea.zktracer.module.limits.precompiles.BlakeRounds; | ||
| import net.consensys.linea.zktracer.module.wcp.Wcp; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Getter | ||
| @Accessors(fluent = true) | ||
| public class BlakeModexpData implements OperationListModule<BlakeModexpDataOperation> { | ||
| public abstract class BlakeModexp implements OperationListModule<BlakeModexpOperation> { | ||
| private final Wcp wcp; | ||
| private final IncrementAndDetectModule modexpEffectiveCall; | ||
| private final IncrementingModule modexpLargeCall; | ||
| private final IncrementingModule blakeEffectiveCall; | ||
| private final BlakeRounds blakeRounds; | ||
|
|
||
| private final ModuleOperationStackedList<BlakeModexpDataOperation> operations = | ||
| private final ModuleOperationStackedList<BlakeModexpOperation> operations = | ||
| new ModuleOperationStackedList<>(); | ||
|
|
||
| private long previousID = 0; | ||
|
|
@@ -52,21 +52,26 @@ public ModuleName moduleKey() { | |
| return BLAKE_MODEXP_DATA; | ||
| } | ||
|
|
||
| public void callModexp(final ModexpMetadata modexpMetaData, final int operationID) { | ||
| operations.add(new BlakeModexpDataOperation(modexpMetaData, operationID)); | ||
| public void callModexp(BlakeModexpOperation modexpOperation) { | ||
|
|
||
| checkState(modexpOperation.isModexpOperation(), "Operation must be a MODEXP operation"); | ||
| operations.add(modexpOperation); | ||
|
|
||
| modexpEffectiveCall.updateTally(1); | ||
| modexpLargeCall.updateTally(modexpMetaData.largeModexp()); | ||
| callWcpForIdCheck(operationID); | ||
| modexpLargeCall.updateTally(modexpOperation.modexpMetaData.get().largeModexp()); | ||
| callWcpForIdCheck(modexpOperation.id()); | ||
| } | ||
|
|
||
| public void callBlake(final BlakeComponents blakeComponents, final int operationID) { | ||
| operations.add(new BlakeModexpDataOperation(blakeComponents, operationID)); | ||
| public void callBlake(BlakeModexpOperation blakeOperation) { | ||
| checkState(blakeOperation.isBlakeOperation(), "Operation must be a BLAKE2f operation"); | ||
| operations.add(blakeOperation); | ||
|
|
||
| blakeEffectiveCall.updateTally(1); | ||
| blakeRounds.addPrecompileLimit(blakeComponents.r()); | ||
| callWcpForIdCheck(operationID); | ||
| blakeRounds.addPrecompileLimit(blakeOperation.blake2fComponents.get().r()); | ||
| callWcpForIdCheck(blakeOperation.id()); | ||
| } | ||
|
|
||
| private void callWcpForIdCheck(final int operationID) { | ||
| private void callWcpForIdCheck(final long operationID) { | ||
|
Collaborator
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. operation is from hubStamp, whicj is a i32, so int is enough no ? |
||
| wcp.callLT(previousID, operationID); | ||
| previousID = operationID; | ||
| } | ||
|
|
@@ -84,7 +89,7 @@ public int spillage(Trace trace) { | |
| @Override | ||
| public void commit(Trace trace) { | ||
| int stamp = 0; | ||
| for (BlakeModexpDataOperation o : operations.getAll()) { | ||
| for (BlakeModexpOperation o : operations.getAll()) { | ||
| o.trace(trace.blake2fmodexpdata(), ++stamp); | ||
| } | ||
| } | ||
|
|
||
|
Collaborator
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. LondonBlakeModexp == OsakaBmakeModexp as it's the underlying operation which is different depeding on the Fork. So Imho, it seems no need to have an abstract BlakeModexpData and two extends. Only keep a non abstract BlakeModexppData seems enough. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| * Copyright Consensys Software Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations under the License. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package net.consensys.linea.zktracer.module.blake2fmodexpdata; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.experimental.Accessors; | ||
| import net.consensys.linea.zktracer.container.module.IncrementAndDetectModule; | ||
| import net.consensys.linea.zktracer.container.module.IncrementingModule; | ||
| import net.consensys.linea.zktracer.module.limits.precompiles.BlakeRounds; | ||
| import net.consensys.linea.zktracer.module.wcp.Wcp; | ||
|
|
||
| @Getter | ||
| @Accessors(fluent = true) | ||
| public class LondonBlakeModexp extends BlakeModexp { | ||
| public LondonBlakeModexp( | ||
| Wcp wcp, | ||
| IncrementAndDetectModule modexpEffectiveCall, | ||
| IncrementingModule modexpLargeCall, | ||
| IncrementingModule blakeEffectiveCall, | ||
| BlakeRounds blakeRounds) { | ||
| super(wcp, modexpEffectiveCall, modexpLargeCall, blakeEffectiveCall, blakeRounds); | ||
| } | ||
| } |
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.
why rm the data ? We have it for other modules (EcData, etc ...)