Skip to content

Commit

Permalink
Remove legacy transaction max values
Browse files Browse the repository at this point in the history
  • Loading branch information
Pasifaee committed May 29, 2024
1 parent 5b98487 commit 2e1ced6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ethereum/circuits/lib/src/transaction.nr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ global MAX_PREFIXED_KEY_NIBBLE_LEN = 8; // (MAX_KEY_LEN + 1) * 2
global MAX_VALUE_LEN_M = 1000; // Values taken from txProofConfigM in tx.ts.
global MAX_LEAF_LEN_M = 1011;

global LEGACY_MAX_TX_ENCODED_LEN = 525;
global MAX_TX_ENCODED_LEN_M = MAX_VALUE_LEN_M;

type TxType = u8;

Expand Down
4 changes: 2 additions & 2 deletions ethereum/circuits/lib/src/verifiers/tx_helpers/split_test.nr
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mod transaction {
homestead::fork::{transaction::{encoded_tx as pre_byzantium_encoded_tx, tx_type as legacy_tx_type}}
};
use crate::verifiers::transaction::{MAX_ENCODED_TX_LENGTH, MAX_TX_RLP_LENGTH};
use crate::transaction::{TxType, LEGACY_MAX_TX_ENCODED_LEN};
use crate::transaction::{TxType, MAX_TX_ENCODED_LEN_M};

#[test]
fn eip1559() {
Expand All @@ -72,7 +72,7 @@ mod transaction {

#[test(should_fail_with="RLP receipt exceeds MAX_RLP_LENGTH")]
fn legacy_wrong_rlp() {
let mut wrong_legacy_rlp: Fragment<LEGACY_MAX_TX_ENCODED_LEN, u8> = Fragment::from_array_resize(pre_byzantium_encoded_tx);
let mut wrong_legacy_rlp: Fragment<MAX_TX_ENCODED_LEN_M, u8> = Fragment::from_array_resize(pre_byzantium_encoded_tx);
let not_zero_byte = 0x01;
wrong_legacy_rlp.set(wrong_legacy_rlp.length - 1, not_zero_byte);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { BYTE_HEX_LEN } from '../../../../../util/const.js';
import { getProofConfig } from '../proofConfig.js';

// TODO: Remove this when we remove legacy fixtures
export const LEGACY_MAX_TX_ENCODED_LEN = 525;
export const LEGACY_MAX_TX_RLP_LEN = LEGACY_MAX_TX_ENCODED_LEN - 1;
export const MAX_TX_ENCODED_LEN_M = 1000;
export const MAX_TX_RLP_LEN_M = MAX_TX_ENCODED_LEN_M - 1;

const MAX_KEY_LEN = 3;
const MAX_PROOF_LEVELS = MAX_KEY_LEN * BYTE_HEX_LEN + 1; // Path with N nibbles has N + 1 levels
export const MAX_VALUE_LEN = 1000;

export const txProofConfigM = getProofConfig(MAX_KEY_LEN, MAX_VALUE_LEN, MAX_PROOF_LEVELS);
export const txProofConfigM = getProofConfig(MAX_KEY_LEN, MAX_TX_ENCODED_LEN_M, MAX_PROOF_LEVELS);
4 changes: 2 additions & 2 deletions ethereum/oracles/src/noir/oracles/rpc/common/txConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { MAX_VALUE_LEN } from './proofConfig/tx.js';
import { MAX_TX_ENCODED_LEN_M } from './proofConfig/tx.js';

export const MAX_DATA_LEN_M = MAX_VALUE_LEN;
export const MAX_DATA_LEN_M = MAX_TX_ENCODED_LEN_M;
6 changes: 3 additions & 3 deletions ethereum/oracles/src/script/noir_fixtures/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { padArray } from '../../util/array.js';
import { TxRlpEncoder, encodeTx } from '../../ethereum/transaction.js';
import { ZERO_PAD_VALUE } from '../../noir/oracles/common/const.js';
import { createBoundedVecFixture } from './boundedVec.js';
import { LEGACY_MAX_TX_RLP_LEN, LEGACY_MAX_TX_ENCODED_LEN } from '../../noir/oracles/rpc/common/proofConfig/tx.js';
import { MAX_TX_RLP_LEN_M, MAX_TX_ENCODED_LEN_M } from '../../noir/oracles/rpc/common/proofConfig/tx.js';
import { MAX_DATA_LEN_M } from '../../noir/oracles/rpc/common/txConfig.js';

export function createTransactionFixture(tx: GetTransactionReturnType): string {
const rlpFields = TxRlpEncoder.txToFields(tx);
const txRlp = joinArray(padArray(encodeHex(toRlp(rlpFields)), LEGACY_MAX_TX_RLP_LEN, ZERO_PAD_VALUE));
const encodedTx = joinArray(padArray(encodeHex(encodeTx(tx)), LEGACY_MAX_TX_ENCODED_LEN, ZERO_PAD_VALUE));
const txRlp = joinArray(padArray(encodeHex(toRlp(rlpFields)), MAX_TX_RLP_LEN_M, ZERO_PAD_VALUE));
const encodedTx = joinArray(padArray(encodeHex(encodeTx(tx)), MAX_TX_ENCODED_LEN_M, ZERO_PAD_VALUE));

const txIdx = encodeField(tx.transactionIndex);
const to = encodeOptional(tx.to ? joinArray(encodeAddress(tx.to)) : undefined);
Expand Down

0 comments on commit 2e1ced6

Please sign in to comment.