Skip to content

Commit

Permalink
feat(synthesizer): remove a subcircuit list from opEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
SonYoungsung committed Jan 9, 2025
1 parent 790aaa7 commit 69034ae
Showing 1 changed file with 22 additions and 37 deletions.
59 changes: 22 additions & 37 deletions packages/frontend/synthesizer/src/opcodes/codes.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { Hardfork } from '@ethereumjs/common'

import { subcircuits } from '../tokamak/resources/subcircuitInfo.js'

import { handlers } from './functions.js'
import { dynamicGasHandlers } from './gas.js'
import { getFullname } from './util.js'

import type { SubcircuitCode, SubcircuitId } from '../tokamak/types/index.js'
import type { CustomOpcode } from '../types.js'
import type { OpHandler } from './functions.js'
import type { AsyncDynamicGasHandler, SyncDynamicGasHandler } from './gas.js'
import type { Common } from '@ethereumjs/common'
import { SynthesizerHandler } from './synthesizer/types.js'
import { synthesizerHandlers } from './synthesizer/handlers.js'
// import { SynthesizerHandler } from './synthesizer/types.js'
// import { synthesizerHandlers } from './synthesizer/handlers.js'
export class Opcode {
readonly code: number
readonly name: string
Expand Down Expand Up @@ -405,16 +403,17 @@ type OpcodeContext = {
dynamicGasHandlers: Map<number, AsyncDynamicGasHandler | SyncDynamicGasHandler>
handlers: Map<number, OpHandler>
opcodes: OpcodeList
subcircuitsId: SubcircuitId[]
opcodeMap: OpcodeMap
}

export type OpcodeMapEntry = {
opcodeInfo: Opcode
opHandler: OpHandler
gasHandler: AsyncDynamicGasHandler | SyncDynamicGasHandler
synthesizerHandler: SynthesizerHandler
subcircuit: SubcircuitCode | undefined
/**
* @todo: synthesizerHandler 추가 필요
*/
// synthesizerHandler: SynthesizerHandler
}
export type OpcodeMap = OpcodeMapEntry[]

Expand Down Expand Up @@ -486,44 +485,31 @@ export function getOpcodesForHF(common: Common, customOpcodes?: CustomOpcode[]):
//const dynamicGasHandlers = dynamicGasHandlersCopy
//const handlers = handlersCopy
const ops = createOpcodes(opcodeBuilder)

const subcircuitsId: SubcircuitId[] = []

/*eslint-disable */
subcircuits.forEach((entry) => {
subcircuitsId[entry.id] = {
code: parseInt(entry.opcode, 16),
name: entry.name,
nWire: entry.Nwires,
outIdx: entry.Out_idx[0],
nOut: entry.Out_idx[1],
inIdx: entry.In_idx[0],
nIn: entry.In_idx[1],
}
})

const opcodeMap: OpcodeMap = []

for (const [opNumber, op] of ops) {
const dynamicGas = dynamicGasHandlersCopy.get(opNumber)!
const handler = handlersCopy.get(opNumber)!
const synthesizerHandler = synthesizerHandlers.get(opNumber)!
const subcircuitCode = subcircuits.find((entry) => parseInt(entry.opcode, 16) === opNumber)
/**
* @todo: synthesizerHandler 추가 필요
*/
// const synthesizerHandler = synthesizerHandlers.get(opNumber)!
// const subcircuitCode = subcircuits.find((entry) => parseInt(entry.opcode, 16) === opNumber)
opcodeMap[opNumber] = {
opcodeInfo: op,
opHandler: handler,
gasHandler: dynamicGas,
synthesizerHandler,
subcircuit: subcircuitCode
? {
subcircuitId: subcircuitCode.id,
nWire: subcircuitCode.Nwires,
outIdx: subcircuitCode.Out_idx[0],
nOut: subcircuitCode.Out_idx[1],
inIdx: subcircuitCode.In_idx[0],
nIn: subcircuitCode.In_idx[1],
}
: undefined,
// synthesizerHandler,
// subcircuit: subcircuitCode
// ? {
// subcircuitId: subcircuitCode.id,
// nWire: subcircuitCode.Nwires,
// outIdx: subcircuitCode.Out_idx[0],
// nOut: subcircuitCode.Out_idx[1],
// inIdx: subcircuitCode.In_idx[0],
// nIn: subcircuitCode.In_idx[1],
// }
// : undefined,
}
}

Expand All @@ -539,7 +525,6 @@ export function getOpcodesForHF(common: Common, customOpcodes?: CustomOpcode[]):
dynamicGasHandlers: dynamicGasHandlersCopy,
handlers: handlersCopy,
opcodes: ops,
subcircuitsId,
opcodeMap,
}
}

0 comments on commit 69034ae

Please sign in to comment.