Skip to content

Commit

Permalink
Util: Small Deprecation Fixes (#3635)
Browse files Browse the repository at this point in the history
* Remove intermediary Util _unprefixedHexToBytes method

* Remove deprecated Util initKZG() method

* Small test description fix

* Small fix
  • Loading branch information
holgerd77 committed Sep 5, 2024
1 parent fe0d6b4 commit 2a3adf9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 31 deletions.
2 changes: 1 addition & 1 deletion packages/evm/vite.config.bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineConfig({
treeshake: 'safest',
},
lib: {
entry: '../tx/examples/londonTx.ts',
entry: './src/',
name: '@ethereumjs/evm',
fileName: (format) => `ethereumjs-evm-bundle.${format}.js`,
// only build for es
Expand Down
26 changes: 8 additions & 18 deletions packages/util/src/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,20 @@ for (let i = 0; i < 16; i++) {
hexToBytesMapFirstKey[key.toUpperCase()] = vFirstKey
}

/**
* NOTE: only use this function if the string is even, and only consists of hex characters
* If this is not the case, this function could return weird results
* @deprecated
*/
function _unprefixedHexToBytes(hex: string): Uint8Array {
const byteLen = hex.length
const bytes = new Uint8Array(byteLen / 2)
for (let i = 0; i < byteLen; i += 2) {
bytes[i / 2] = hexToBytesMapFirstKey[hex[i]] + hexToBytesMapSecondKey[hex[i + 1]]
}
return bytes
}

/**
* @deprecated
*/
export const unprefixedHexToBytes = (inp: string) => {
if (inp.slice(0, 2) === '0x') {
throw new Error('hex string is prefixed with 0x, should be unprefixed')
} else {
return _unprefixedHexToBytes(padToEven(inp))
inp = padToEven(inp)
const byteLen = inp.length
const bytes = new Uint8Array(byteLen / 2)
for (let i = 0; i < byteLen; i += 2) {
bytes[i / 2] = hexToBytesMapFirstKey[inp[i]] + hexToBytesMapSecondKey[inp[i + 1]]
}
return bytes
}
}

Expand Down Expand Up @@ -124,9 +116,7 @@ export const hexToBytes = (hex: PrefixedHexString): Uint8Array => {

const unprefixedHex = hex.slice(2)

return _unprefixedHexToBytes(
unprefixedHex.length % 2 === 0 ? unprefixedHex : padToEven(unprefixedHex),
)
return unprefixedHexToBytes(unprefixedHex)
}

/******************************************/
Expand Down
11 changes: 0 additions & 11 deletions packages/util/src/kzg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,3 @@ export interface Kzg {
kzgProofs: Uint8Array[],
): boolean
}

/**
* @deprecated This initialization method is deprecated since trusted setup loading is done directly in the reference KZG library
* initialization or should otherwise be assured independently before KZG library usage.
*
* @param kzgLib a KZG implementation (defaults to c-kzg)
* @param a dictionary of trusted setup options
*/
export function initKZG(kzg: Kzg, _trustedSetupPath?: string) {
kzg.loadTrustedSetup()
}
2 changes: 1 addition & 1 deletion packages/vm/test/api/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ describe('VM -> common (chain, HFs, EIPs)', () => {
})
})

describe('VM -> setHardfork, state (deprecated), blockchain', () => {
describe('VM -> setHardfork, blockchain', () => {
it('setHardfork', async () => {
const common = createCustomCommon(testnetMerge.default as ChainConfig, Mainnet, {
hardfork: Hardfork.Istanbul,
Expand Down

0 comments on commit 2a3adf9

Please sign in to comment.