Skip to content

Commit ebc3f25

Browse files
feat(exec) : adds the baseFee and the coinBase to the public inputs of the execution proof
1 parent 8e4b7e5 commit ebc3f25

File tree

15 files changed

+252
-108
lines changed

15 files changed

+252
-108
lines changed

prover/backend/execution/craft.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ func CraftProverOutput(
3333
rsp = Response{
3434
BlocksData: make([]BlockData, len(blocks)),
3535
ChainID: cfg.Layer2.ChainID,
36+
BaseFee: cfg.Layer2.BaseFee,
37+
CoinBase: types.EthAddress(cfg.Layer2.CoinBase),
3638
L2BridgeAddress: types.EthAddress(cfg.Layer2.MsgSvcContract),
3739
MaxNbL2MessageHashes: cfg.TracesLimits.BlockL2L1Logs,
3840
}
@@ -193,6 +195,8 @@ func (rsp *Response) FuncInput() *public_input.Execution {
193195
fi = &public_input.Execution{
194196
L2MessageServiceAddr: types.EthAddress(rsp.L2BridgeAddress),
195197
ChainID: uint64(rsp.ChainID),
198+
BaseFee: uint64(rsp.BaseFee),
199+
CoinBase: types.EthAddress(rsp.CoinBase),
196200
FinalBlockTimestamp: lastBlock.TimeStamp,
197201
FinalBlockNumber: uint64(rsp.FirstBlockNumber + len(rsp.BlocksData) - 1),
198202
InitialBlockTimestamp: firstBlock.TimeStamp,
@@ -229,6 +233,8 @@ func NewWitness(cfg *config.Config, req *Request, rsp *Response) *Witness {
229233
TxHashes: txHashes,
230234
L2BridgeAddress: cfg.Layer2.MsgSvcContract,
231235
ChainID: cfg.Layer2.ChainID,
236+
BaseFee: cfg.Layer2.BaseFee,
237+
CoinBase: types.EthAddress(cfg.Layer2.CoinBase),
232238
BlockHashList: getBlockHashList(rsp),
233239
},
234240
FuncInp: rsp.FuncInput(),

prover/backend/execution/response.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,18 @@ type Response struct {
5151
ExecDataChecksum types.Bytes32 `json:"execDataChecksum"`
5252
// ChainID indicates which ChainID was used during the execution.
5353
ChainID uint `json:"chainID"`
54-
// L2BridgeAddress indicates which ChainID was used during the execution.
54+
// L2BridgeAddress indicates the address of the L2 bridge was used during
55+
// the execution.
5556
L2BridgeAddress types.EthAddress `json:"l2BridgeAddress"`
5657
// MaxNbL2MessageHashes indicates the max number of L2 Message hashes that
5758
// can be processed by the execution prover at once in the config.
5859
MaxNbL2MessageHashes int `json:"maxNbL2MessageHashes"`
60+
// CoinBase indicates the coinbase of the L2 network that was used during
61+
// the proof generation
62+
CoinBase types.EthAddress `json:"coinBase"`
63+
// BaseFee indicates the base fee of the L2 network that was used during
64+
// the proof generation
65+
BaseFee uint `json:"baseFee"`
5966

6067
// AllRollingHash stores the collection of all the rolling hash events
6168
// occurring during the execution frame.

prover/circuits/execution/pi.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ type FunctionalPublicInputSnark struct {
107107
InitialBlockNumber frontend.Variable
108108
ChainID frontend.Variable
109109
L2MessageServiceAddr frontend.Variable
110+
BaseFee frontend.Variable
111+
CoinBase frontend.Variable
110112
}
111113

112114
// RangeCheck checks that values are within range
@@ -139,10 +141,26 @@ func (spi *FunctionalPublicInputSnark) Sum(api frontend.API, hsh gnarkHash.Field
139141
)
140142

141143
hsh.Reset()
142-
hsh.Write(spi.DataChecksum, l2MessagesSum,
143-
spi.FinalStateRootHash, spi.FinalBlockNumber, spi.FinalBlockTimestamp, finalRollingHash[0], finalRollingHash[1], spi.LastRollingHashUpdateNumber,
144-
spi.InitialStateRootHash, spi.InitialBlockNumber, spi.InitialBlockTimestamp, initialRollingHash[0], initialRollingHash[1], spi.FirstRollingHashUpdateNumber,
145-
spi.ChainID, spi.L2MessageServiceAddr)
144+
hsh.Write(
145+
spi.DataChecksum,
146+
l2MessagesSum,
147+
spi.FinalStateRootHash,
148+
spi.FinalBlockNumber,
149+
spi.FinalBlockTimestamp,
150+
finalRollingHash[0],
151+
finalRollingHash[1],
152+
spi.LastRollingHashUpdateNumber,
153+
spi.InitialStateRootHash,
154+
spi.InitialBlockNumber,
155+
spi.InitialBlockTimestamp,
156+
initialRollingHash[0],
157+
initialRollingHash[1],
158+
spi.FirstRollingHashUpdateNumber,
159+
spi.ChainID,
160+
spi.L2MessageServiceAddr,
161+
spi.BaseFee,
162+
spi.CoinBase,
163+
)
146164

147165
return hsh.Sum()
148166
}
@@ -152,6 +170,8 @@ func (spi *FunctionalPublicInputSnark) Assign(pi *public_input.Execution) error
152170
spi.InitialStateRootHash = pi.InitialStateRootHash[:]
153171
spi.InitialBlockNumber = pi.InitialBlockNumber
154172
spi.ChainID = pi.ChainID
173+
spi.CoinBase = pi.CoinBase[:]
174+
spi.BaseFee = pi.BaseFee
155175
spi.L2MessageServiceAddr = pi.L2MessageServiceAddr[:]
156176

157177
return spi.FunctionalPublicInputQSnark.Assign(pi)

prover/circuits/execution/pi_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestPIConsistency(t *testing.T) {
2222
InitialBlockTimestamp: 2,
2323
FirstRollingHashUpdateNumber: 3,
2424
ChainID: 7,
25+
BaseFee: 3,
2526
}
2627

2728
utils.FillRange(pi.DataChecksum[:], 10)
@@ -32,6 +33,7 @@ func TestPIConsistency(t *testing.T) {
3233
utils.FillRange(pi.FinalStateRootHash[:], 210)
3334
utils.FillRange(pi.LastRollingHashUpdate[:], 250)
3435
utils.FillRange(pi.L2MessageServiceAddr[:], 40)
36+
utils.FillRange(pi.CoinBase[:], 22)
3537

3638
// state root hashes are field elements
3739
pi.InitialStateRootHash[0] &= 0x0f

prover/circuits/execution/pi_wizard_extraction.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ func checkPublicInputs(
135135

136136
api.AssertIsEqual(bridgeAddress, gnarkFuncInp.L2MessageServiceAddr)
137137

138+
api.AssertIsEqual(
139+
wvc.GetPublicInput(api, publicInput.BaseFee),
140+
gnarkFuncInp.BaseFee,
141+
)
142+
143+
api.AssertIsEqual(
144+
wvc.GetPublicInput(api, publicInput.CoinBase),
145+
gnarkFuncInp.CoinBase,
146+
)
147+
138148
}
139149

140150
// execDataHash hash the execution-data with its length so that we can guard

prover/config/config.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,18 @@ func newConfigFromFile(path string, withValidation bool) (*Config, error) {
7777
logrus.SetLevel(logrus.Level(cfg.LogLevel)) // #nosec G115 -- overflow not possible (uint8 -> uint32)
7878

7979
// Extract the Layer2.MsgSvcContract address from the string
80-
addr, err := common.NewMixedcaseAddressFromString(cfg.Layer2.MsgSvcContractStr)
80+
lsMsgSvcAddress, err := common.NewMixedcaseAddressFromString(cfg.Layer2.MsgSvcContractStr)
8181
if withValidation && err != nil {
8282
return nil, fmt.Errorf("failed to extract Layer2.MsgSvcContract address: %w", err)
8383
}
84-
cfg.Layer2.MsgSvcContract = addr.Address()
84+
cfg.Layer2.MsgSvcContract = lsMsgSvcAddress.Address()
8585

8686
// Extract the coinbase address from the string
87-
// addr, err := common.NewMixedcaseAddressFromString(cfg.Layer2.CoinbaseStr)
88-
// if withValidation && err != nil {
89-
// return nil, fmt.Errorf("failed to extract Layer2.MsgSvcContract address: %w", err)
90-
// }
91-
// cfg.Layer2.MsgSvcContract = addr.Address()
87+
coinBaseAddr, err := common.NewMixedcaseAddressFromString(cfg.Layer2.CoinBaseStr)
88+
if withValidation && err != nil {
89+
return nil, fmt.Errorf("failed to extract Layer2.MsgSvcContract address: %w", err)
90+
}
91+
cfg.Layer2.MsgSvcContract = coinBaseAddr.Address()
9292

9393
// ensure that asset dir / kzgsrs exists using os.Stat
9494
srsDir := cfg.PathForSRS()
@@ -103,6 +103,7 @@ func newConfigFromFile(path string, withValidation bool) (*Config, error) {
103103
cfg.PublicInputInterconnection.ChainID = uint64(cfg.Layer2.ChainID)
104104
cfg.PublicInputInterconnection.BaseFee = uint64(cfg.Layer2.BaseFee)
105105
cfg.PublicInputInterconnection.L2MsgServiceAddr = cfg.Layer2.MsgSvcContract
106+
cfg.PublicInputInterconnection.CoinBase = cfg.Layer2.CoinBase
106107

107108
return &cfg, nil
108109
}
@@ -152,10 +153,12 @@ type Config struct {
152153
// Use this field when you need the ETH address as a string.
153154
MsgSvcContractStr string `mapstructure:"message_service_contract" validate:"required,eth_addr"`
154155

155-
// CoinbaseStr string `mapstructure:"coinbase" validate:"required,eth_addr"`
156+
// CoinBaseStr stores the coinbase address of Linea as a string.
157+
CoinBaseStr string `mapstructure:"coin_base" validate:"required,eth_addr"`
156158

157159
// MsgSvcContract stores the unique ID of the Service Contract (SC), as a common.Address.
158160
MsgSvcContract common.Address `mapstructure:"-"`
161+
CoinBase common.Address `mapstructure:"-"`
159162
}
160163

161164
TracesLimits TracesLimits `mapstructure:"traces_limits" validate:"required"`
@@ -324,7 +327,7 @@ type PublicInput struct {
324327
ChainID uint64 // duplicate from Config
325328
BaseFee uint64 // duplicate from Config
326329
L2MsgServiceAddr common.Address // duplicate from Config
327-
// Coinbase common.Address // duplicate from Config
330+
CoinBase common.Address // duplicate from Config
328331
}
329332

330333
type Debug struct {

prover/public-input/execution.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
)
1212

1313
type Execution struct {
14-
L2MessageServiceAddr types.EthAddress
15-
ChainID uint64
1614
InitialBlockTimestamp uint64
1715
FinalStateRootHash [32]byte
1816
FinalBlockNumber uint64
@@ -25,6 +23,12 @@ type Execution struct {
2523
L2MessageHashes [][32]byte
2624
InitialStateRootHash [32]byte
2725
InitialBlockNumber uint64
26+
27+
// Dynamic chain config parameters
28+
L2MessageServiceAddr types.EthAddress
29+
ChainID uint64
30+
BaseFee uint64
31+
CoinBase types.EthAddress
2832
}
2933

3034
func (pi *Execution) Sum(hsh hash.Hash) []byte {
@@ -58,6 +62,8 @@ func (pi *Execution) Sum(hsh hash.Hash) []byte {
5862
writeNum(hsh, pi.FirstRollingHashUpdateNumber)
5963
writeNum(hsh, pi.ChainID)
6064
hsh.Write(pi.L2MessageServiceAddr[:])
65+
writeNum(hsh, pi.BaseFee)
66+
hsh.Write(pi.CoinBase[:])
6167

6268
return hsh.Sum(nil)
6369

prover/zkevm/limitless.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,8 @@ var publicInputNames = []string{
10171017
publicInput.NBytesChainID,
10181018
publicInput.L2MessageServiceAddrHi,
10191019
publicInput.L2MessageServiceAddrLo,
1020+
publicInput.BaseFee,
1021+
publicInput.CoinBase,
10201022
}
10211023

10221024
// LogPublicInputs logs the list of the public inputs for the module

prover/zkevm/prover/publicInput/execution_data_collector/execution_data_collector.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ func ProjectionQueries(comp *wizard.CompiledIOP,
871871
// compute the fetcher table, directly tied to the arithmetization.
872872
timestampTable := []ifaces.Column{
873873
timestamps.RelBlock,
874-
timestamps.Data,
874+
timestamps.DataLo,
875875
}
876876

877877
// compute the ExecutionDataCollector table.
@@ -1311,7 +1311,7 @@ func AssignExecutionDataCollector(run *wizard.ProverRuntime,
13111311
rlpCt := 0
13121312
totalCt := 0
13131313

1314-
for blockCt := 0; blockCt < timestamps.Data.Size(); blockCt++ {
1314+
for blockCt := 0; blockCt < timestamps.DataLo.Size(); blockCt++ {
13151315
isBlockPresent := metadata.FilterFetched.GetColAssignmentAt(run, blockCt)
13161316
if isBlockPresent.IsOne() {
13171317
// block-wide information
@@ -1339,7 +1339,7 @@ func AssignExecutionDataCollector(run *wizard.ProverRuntime,
13391339
totalCt++
13401340

13411341
// row 1, load the timestamp
1342-
fetchedTimestamp := timestamps.Data.GetColAssignmentAt(run, blockCt)
1342+
fetchedTimestamp := timestamps.DataLo.GetColAssignmentAt(run, blockCt)
13431343
vect.IsTimestamp[totalCt].SetOne()
13441344
vect.NoBytes[totalCt].SetInt64(noBytesTimestamp)
13451345
genericLoadFunction(loadTimestamp, fetchedTimestamp)

0 commit comments

Comments
 (0)