Skip to content

Commit

Permalink
EVM: move KZG precompile (#2811)
Browse files Browse the repository at this point in the history
* evm: move kzg-precompile, add multiple precompiles at same address support

* evm: move bls precompiles
evm: cleanup precompile getter

* Export precompileAvailability from evm/precompiles/index.ts

* evm: precompiles update export name

---------

Co-authored-by: CedarMist <134699267+CedarMist@users.noreply.github.com>
  • Loading branch information
jochem-brouwer and CedarMist committed Jun 22, 2023
1 parent 2e785fa commit 3c1c835
Show file tree
Hide file tree
Showing 13 changed files with 199 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const BLS_MODULUS = BigInt(

const modulusBuffer = setLengthLeft(bigIntToBytes(BLS_MODULUS), 32)

export async function precompile14(opts: PrecompileInput): Promise<ExecResult> {
export async function precompile0a(opts: PrecompileInput): Promise<ExecResult> {
const gasUsed = opts._common.param('gasPrices', 'kzgPointEvaluationGasPrecompilePrice')
if (opts._debug !== undefined) {
opts._debug(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { BLS12_381_FromG1Point, BLS12_381_ToG1Point } from './util/bls12_381.js'
import type { ExecResult } from '../evm.js'
import type { PrecompileInput } from './types.js'

export async function precompile0a(opts: PrecompileInput): Promise<ExecResult> {
export async function precompile0c(opts: PrecompileInput): Promise<ExecResult> {
const mcl = (<any>opts._EVM)._mcl!

const inputData = opts.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import type { ExecResult } from '../evm.js'
import type { PrecompileInput } from './types.js'

export async function precompile0b(opts: PrecompileInput): Promise<ExecResult> {
export async function precompile0d(opts: PrecompileInput): Promise<ExecResult> {
const mcl = (<any>opts._EVM)._mcl!

const inputData = opts.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import type { ExecResult } from '../evm.js'
import type { PrecompileInput } from './types.js'

export async function precompile0c(opts: PrecompileInput): Promise<ExecResult> {
export async function precompile0e(opts: PrecompileInput): Promise<ExecResult> {
const mcl = (<any>opts._EVM)._mcl!

const inputData = opts.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { BLS12_381_FromG2Point, BLS12_381_ToG2Point } from './util/bls12_381.js'
import type { ExecResult } from '../evm.js'
import type { PrecompileInput } from './types.js'

export async function precompile0d(opts: PrecompileInput): Promise<ExecResult> {
export async function precompile0f(opts: PrecompileInput): Promise<ExecResult> {
const mcl = (<any>opts._EVM)._mcl!

const inputData = opts.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import type { ExecResult } from '../evm.js'
import type { PrecompileInput } from './types.js'

export async function precompile0e(opts: PrecompileInput): Promise<ExecResult> {
export async function precompile10(opts: PrecompileInput): Promise<ExecResult> {
const mcl = (<any>opts._EVM)._mcl!

const inputData = opts.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import type { ExecResult } from '../evm.js'
import type { PrecompileInput } from './types.js'

export async function precompile0f(opts: PrecompileInput): Promise<ExecResult> {
export async function precompile11(opts: PrecompileInput): Promise<ExecResult> {
const mcl = (<any>opts._EVM)._mcl!

const inputData = opts.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { PrecompileInput } from './types.js'
const zeroBuffer = new Uint8Array(32)
const oneBuffer = concatBytesNoTypeCheck(new Uint8Array(31), hexToBytes('01'))

export async function precompile10(opts: PrecompileInput): Promise<ExecResult> {
export async function precompile12(opts: PrecompileInput): Promise<ExecResult> {
const mcl = (<any>opts._EVM)._mcl!

const inputData = opts.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { BLS12_381_FromG1Point, BLS12_381_ToFpPoint } from './util/bls12_381.js'
import type { ExecResult } from '../evm.js'
import type { PrecompileInput } from './types.js'

export async function precompile11(opts: PrecompileInput): Promise<ExecResult> {
export async function precompile13(opts: PrecompileInput): Promise<ExecResult> {
const mcl = (<any>opts._EVM)._mcl!

const inputData = opts.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { BLS12_381_FromG2Point, BLS12_381_ToFp2Point } from './util/bls12_381.js
import type { ExecResult } from '../evm.js'
import type { PrecompileInput } from './types.js'

export async function precompile12(opts: PrecompileInput): Promise<ExecResult> {
export async function precompile14(opts: PrecompileInput): Promise<ExecResult> {
const mcl = (<any>opts._EVM)._mcl!

const inputData = opts.data
Expand Down
Loading

0 comments on commit 3c1c835

Please sign in to comment.