Skip to content

Commit

Permalink
cspell: fix problems
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem-brouwer committed Aug 17, 2024
1 parent b8ab409 commit 2e7ff33
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 30 deletions.
3 changes: 2 additions & 1 deletion config/cspell-ts.json
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@
"Slominski",
"patarapolw",
"nickdodson",
"Kintsugi"
"Kintsugi",
"deauthorization"
]
}
5 changes: 1 addition & 4 deletions packages/block/test/from-rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ describe('[fromRPC] - Alchemy/Infura API block responses', () => {
it('should create pre and post merge blocks from Infura API responses to eth_getBlockByHash and eth_getBlockByNumber', () => {
const common = new Common({ chain: Mainnet })
let block = createBlockFromRPC(infura2000004woTxs as JsonRpcBlock, [], {
// cspell:disable-line
common,
setHardfork: true,
})
Expand All @@ -142,14 +141,13 @@ describe('[fromRPC] - Alchemy/Infura API block responses', () => {
infura2000004woTxs.hash,
'created premerge block w/o txns',
)
block = createBlockFromRPC(infura2000004wTxs as JsonRpcBlock, [], { common, setHardfork: true }) // cspell:disable-line
block = createBlockFromRPC(infura2000004wTxs as JsonRpcBlock, [], { common, setHardfork: true })
assert.equal(
bytesToHex(block.hash()),
infura2000004wTxs.hash,
'created premerge block with txns',
)
block = createBlockFromRPC(infura15571241woTxs as JsonRpcBlock, [], {
// cspell:disable-line
common,
setHardfork: true,
})
Expand All @@ -160,7 +158,6 @@ describe('[fromRPC] - Alchemy/Infura API block responses', () => {
)

block = createBlockFromRPC(infura15571241wTxs as JsonRpcBlock, [], {
// cspell:disable-line
common,
setHardfork: true,
})
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain/test/clique.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ describe('clique: reorgs', () => {
const { blocks, blockchain } = await initWithSigners([A, B])
const genesis = blocks[0]
await addNextBlock(blockchain, blocks, A, [C, true])
const headBlockNotForked = await addNextBlock(blockchain, blocks, B, [C, true]) // cspell:disable-line
const headBlockNotForked = await addNextBlock(blockchain, blocks, B, [C, true])
assert.deepEqual(
(blockchain.consensus as CliqueConsensus).cliqueActiveSigners(
blocks[blocks.length - 1].header.number + BigInt(1),
Expand Down
6 changes: 3 additions & 3 deletions packages/client/test/sim/txGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const kzg = await loadKZG()

function get_padded(data: any, blobs_len: number) {
const pData = new Uint8Array(blobs_len * USEFUL_BYTES_PER_BLOB)
const datalen = (data as Uint8Array).byteLength
pData.fill(data, 0, datalen)
const dataLen = (data as Uint8Array).byteLength
pData.fill(data, 0, dataLen)
// TODO: if data already fits in a pad, then ka-boom
pData[datalen] = 0x80
pData[dataLen] = 0x80
return pData
}

Expand Down
5 changes: 2 additions & 3 deletions packages/statemanager/src/cache/storage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// cspell:ignore dels
import { bytesToUnprefixedHex, hexToBytes } from '@ethereumjs/util'
import { OrderedMap } from '@js-sdsl/ordered-map'
import debugDefault from 'debug'
Expand Down Expand Up @@ -166,7 +165,7 @@ export class StorageCache extends Cache {
this._orderedMapCache!.setElement(addressHex, storageMap)
}

this._stats.dels += 1
this._stats.deletions += 1
}

/**
Expand Down Expand Up @@ -330,7 +329,7 @@ export class StorageCache extends Cache {
reads: 0,
hits: 0,
writes: 0,
dels: 0,
deletions: 0,
}
}
return stats
Expand Down
32 changes: 16 additions & 16 deletions packages/statemanager/test/rpcStateManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,40 +90,40 @@ describe('RPC State Manager API tests', () => {

assert.ok(state.getAccount(vitalikDotEth) !== undefined, 'vitalik.eth does exist')

const UNIERC20ContractAddress = createAddressFromString(
const UniswapERC20ContractAddress = createAddressFromString(
'0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984',
)
const UNIContractCode = await state.getCode(UNIERC20ContractAddress)
const UNIContractCode = await state.getCode(UniswapERC20ContractAddress)
assert.ok(UNIContractCode.length > 0, 'was able to retrieve UNI contract code')

await state.putCode(UNIERC20ContractAddress, UNIContractCode)
await state.putCode(UniswapERC20ContractAddress, UNIContractCode)
assert.ok(
state['_caches'].code?.get(UNIERC20ContractAddress) !== undefined,
state['_caches'].code?.get(UniswapERC20ContractAddress) !== undefined,
'UNI ERC20 contract code was found in cache',
)

const storageSlot = await state.getStorage(
UNIERC20ContractAddress,
UniswapERC20ContractAddress,
setLengthLeft(bigIntToBytes(1n), 32),
)
assert.ok(storageSlot.length > 0, 'was able to retrieve storage slot 1 for the UNI contract')

await expect(async () => {
await state.getStorage(UNIERC20ContractAddress, setLengthLeft(bigIntToBytes(1n), 31))
await state.getStorage(UniswapERC20ContractAddress, setLengthLeft(bigIntToBytes(1n), 31))
}).rejects.toThrowError('Storage key must be 32 bytes long')

await state.putStorage(
UNIERC20ContractAddress,
UniswapERC20ContractAddress,
setLengthLeft(bigIntToBytes(2n), 32),
utf8ToBytes('abcd'),
)
const slotValue = await state.getStorage(
UNIERC20ContractAddress,
UniswapERC20ContractAddress,
setLengthLeft(bigIntToBytes(2n), 32),
)
assert.ok(equalsBytes(slotValue, utf8ToBytes('abcd')), 'should retrieve slot 2 value')

const dumpedStorage = await state.dumpStorage(UNIERC20ContractAddress)
const dumpedStorage = await state.dumpStorage(UniswapERC20ContractAddress)
assert.deepEqual(dumpedStorage, {
[bytesToUnprefixedHex(setLengthLeft(bigIntToBytes(1n), 32))]: '0xabcd',
[bytesToUnprefixedHex(setLengthLeft(bigIntToBytes(2n), 32))]: bytesToHex(utf8ToBytes('abcd')),
Expand All @@ -137,7 +137,7 @@ describe('RPC State Manager API tests', () => {
await state.checkpoint()

await state.putStorage(
UNIERC20ContractAddress,
UniswapERC20ContractAddress,
setLengthLeft(bigIntToBytes(2n), 32),
new Uint8Array(0),
)
Expand All @@ -161,7 +161,7 @@ describe('RPC State Manager API tests', () => {
}

const deletedSlot = await state.getStorage(
UNIERC20ContractAddress,
UniswapERC20ContractAddress,
setLengthLeft(bigIntToBytes(2n), 32),
)

Expand All @@ -180,7 +180,7 @@ describe('RPC State Manager API tests', () => {
)

const deletedSlotAfterRevert = await state.getStorage(
UNIERC20ContractAddress,
UniswapERC20ContractAddress,
setLengthLeft(bigIntToBytes(2n), 32),
)

Expand All @@ -190,14 +190,14 @@ describe('RPC State Manager API tests', () => {
'slot deleted since last checkpoint should exist in storage cache after revert',
)

const cacheStorage = await state.dumpStorage(UNIERC20ContractAddress)
const cacheStorage = await state.dumpStorage(UniswapERC20ContractAddress)
assert.equal(
2,
Object.keys(cacheStorage).length,
'should have 2 storage slots in cache before clear',
)
await state.clearStorage(UNIERC20ContractAddress)
const clearedStorage = await state.dumpStorage(UNIERC20ContractAddress)
await state.clearStorage(UniswapERC20ContractAddress)
const clearedStorage = await state.dumpStorage(UniswapERC20ContractAddress)
assert.deepEqual({}, clearedStorage, 'storage cache should be empty after clear')

try {
Expand All @@ -211,7 +211,7 @@ describe('RPC State Manager API tests', () => {
}

assert.equal(
state['_caches'].account?.get(UNIERC20ContractAddress),
state['_caches'].account?.get(UniswapERC20ContractAddress),
undefined,
'should not have any code for contract after cache is reverted',
)
Expand Down
5 changes: 3 additions & 2 deletions packages/wallet/src/hdkey.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// cspell:ignore xprv xpub
import { mnemonicToSeedSync } from 'ethereum-cryptography/bip39/index.js'
import { HDKey } from 'ethereum-cryptography/hdkey.js'

Expand Down Expand Up @@ -28,7 +29,7 @@ export class EthereumHDKey {
constructor(private readonly _hdkey: HDKey) {}

/**
* Returns a BIP32 extended private key (xprv) // cspell:disable-line
* Returns a BIP32 extended private key (xprv)
*/
public privateExtendedKey(): string {
if (!this._hdkey.privateExtendedKey) {
Expand All @@ -38,7 +39,7 @@ export class EthereumHDKey {
}

/**
* Return a BIP32 extended public key (xpub) // cspell:disable-line
* Return a BIP32 extended public key (xpub)
*/
public publicExtendedKey(): string {
return this._hdkey.publicExtendedKey
Expand Down

0 comments on commit 2e7ff33

Please sign in to comment.