Skip to content

Commit 75f8196

Browse files
authored
feat: fail when sending a transaction with non empty acess list (#4651)
Signed-off-by: Mariusz Jasuwienas <[email protected]>
1 parent 11129b0 commit 75f8196

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

packages/relay/src/lib/precheck.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export class Precheck {
7777
mirrorAccountInfo.ethereum_nonce + (await this.transactionPoolService.getPendingCount(parsedTx.from!));
7878
this.nonce(parsedTx, signerNonce);
7979
this.balance(parsedTx, mirrorAccountInfo.balance);
80+
this.accessList(parsedTx);
8081
await this.receiverAccount(parsedTx, requestDetails);
8182
}
8283

@@ -214,6 +215,14 @@ export class Precheck {
214215
}
215216
}
216217

218+
/**
219+
* Checks if the value of the access was not set.
220+
* @param tx - The transaction.
221+
*/
222+
accessList(tx: Transaction): void {
223+
if (tx.accessList?.length) throw predefined.NOT_YET_IMPLEMENTED;
224+
}
225+
217226
/**
218227
* Calculates the intrinsic gas cost based on the number of bytes in the data field.
219228
* Using a loop that goes through every two characters in the string it counts the zero and non-zero bytes.

packages/relay/tests/lib/precheck.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,4 +926,22 @@ describe('Precheck', async function () {
926926
);
927927
});
928928
});
929+
930+
describe('accessList', async function () {
931+
it('should successfully parse a valid transaction string with empty access list', function () {
932+
parsedTxWithMatchingChainId.accessList = [];
933+
precheck.accessList(parsedTxWithMatchingChainId);
934+
expect(parsedTxWithMatchingChainId.accessList).to.be.empty;
935+
});
936+
937+
it('should throw NOT_YET_IMPLEMENTED for non-empty access list', function () {
938+
parsedTxWithMatchingChainId.accessList = [
939+
{
940+
address: '0x67D8d32E9Bf1a9968a5ff53B87d777Aa8EBBEe69',
941+
storageKeys: [],
942+
},
943+
];
944+
expect(() => precheck.accessList(parsedTxWithMatchingChainId)).to.throw('Not yet implemented');
945+
});
946+
});
929947
});

packages/server/tests/acceptance/sendRawTransactionExtension.spec.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,50 @@ describe('@sendRawTransactionExtension Acceptance Tests', function () {
9797
});
9898
});
9999

100+
describe('accessList', function () {
101+
it('should fail when calling "eth_sendRawTransaction" with non-empty access list', async function () {
102+
const gasPrice = await relay.gasPrice();
103+
const transaction = {
104+
type: 2,
105+
chainId: Number(CHAIN_ID),
106+
nonce: await relay.getAccountNonce(accounts[1].address),
107+
maxPriorityFeePerGas: gasPrice,
108+
maxFeePerGas: gasPrice,
109+
gasLimit: defaultGasLimit,
110+
accessList: [
111+
{
112+
address: '0x67D8d32E9Bf1a9968a5ff53B87d777Aa8EBBEe69',
113+
storageKeys: [],
114+
},
115+
],
116+
to: accounts[0].address,
117+
};
118+
119+
const signedTx = await accounts[1].wallet.signTransaction(transaction);
120+
await expect(relay.sendRawTransaction(signedTx)).to.eventually.be.rejected;
121+
});
122+
123+
it('should succeed when calling "eth_sendRawTransaction" with an empty access list', async function () {
124+
const gasPrice = await relay.gasPrice();
125+
const transaction = {
126+
type: 2,
127+
chainId: Number(CHAIN_ID),
128+
nonce: await relay.getAccountNonce(accounts[1].address),
129+
maxPriorityFeePerGas: gasPrice,
130+
maxFeePerGas: gasPrice,
131+
gasLimit: defaultGasLimit,
132+
accessList: [],
133+
to: accounts[0].address,
134+
};
135+
const signedTx = await accounts[1].wallet.signTransaction(transaction);
136+
const transactionHash = await relay.sendRawTransaction(signedTx);
137+
await relay.pollForValidTransactionReceipt(transactionHash);
138+
139+
const info = await mirrorNode.get(`/contracts/results/${transactionHash}`);
140+
expect(info).to.exist;
141+
});
142+
});
143+
100144
describe('callDataSize', function () {
101145
it('@release should execute "eth_sendRawTransaction" with regular transaction size within the CALL_DATA_SIZE_LIMIT - 128kb limit', async function () {
102146
const gasPrice = await relay.gasPrice();

0 commit comments

Comments
 (0)