# Implementation Of Block-Level Access List
**Eip-7928** enables recording all account and storage location accessed during block execution in **BAL**.This enables parallel disk reads, parallel transaction validation, and executionless state updates. This marks an important step towards stateless ethereum ecosystem.
## Structural Change In Block
This particular eip introduces new fields both in **block-header** and **block-body**.
On high level it will look something like:

* The Block-Access List consists of list of account changes.
* Each of the account change is comprised of storage change,storage read,balance change,nonce change and code change with respect to each account.
* The storage changes are made of slot changes.Each of this slot change contains list of storage changes with respect to a storage key.
* Each of the storage change contained in slot change contains transaction index along with new value.
* The storage reads are made up of slot reads.Each of this slot read contains a storage key.
* The balance changes contain a list of changes in balance where each balance change contains transaction index and post balance.
* Similarly the nonce changes contain a list of changes in nonce where each nonce change contains transaction index and new nonce.
* And code changes contain a list of code changes where each code change contain transaction index and new code.
On the intial level implementation should involve :
* Including the alias and constants as specified in the original eip.
* Including the new fields `bal_hash` and `block_level_access_list` in block header and body.Since this changes are not backward compatible it requires a hardfork.
* Defining the necessary structs like `StorageChange`,`BalanceChange`,`NonceChange`,`CodeChange`,`SlotChanges`,`SlotRead`,`AccountChanges` and `BlockAccessList`.
* Enabling tracing the pre and post state of transaction by creating and using tracer for each respective change like slot,balance,nonce etc.
## Changes To `state_transition` and `build_block_access_list`
* Eip-7928 involves iterating over the transactions present in a block during state transition.
* Each transaction is traced using`execute_transaction_with_tracing` to fetch the pre and post state.
Each level of tracing should look something like:

* Upon tracing, storage change,balance change ,nonce change etc needs to be recorded.
### For storage change:
* If post value is not none and pre value not equal to post value:
1. If slot not in account data,create and write in storage-writes.
2. If slot in account data directly write in storage-writes.
* If post value is not none and pre value is same as post value,store the slot under storage-reads.
* If pre value not none and slot not in post storage.
1. If slot not in storage-writes of account data then create and enable zeroed slot storage.
2. If present enable directly zeroed slot storage.
* If pre value is not none store the slot under storage-reads account data.
### For balance change:
* If pre balance is different from post balance
a. Add address under balance touched.
b. Store the post balance under balance change in account data.
### For code change:
* If post code exists and post code not equal to pre code and post code not in`('', '0x')`.
a. Store post code under code change in account data.
### For nonce change:
* If pre info has code and pre info code not in `('', '0x', '0x0')`.
1. If pre nonce greater than post nonce,store the post nonce under account data nonce change.
### Coinbase Balance:
* If coinbase address exist in balance touched and it is greater than zero.
1. If coinbase address not in account data,intialize it.
2. If no balance change are recorded yet and last recorder change was before the final transaction index,then append a new balance change for the coinbase after the last transaction.
* ### `build_block_access_list` for the account data and validate block data
Using `build_block_access_list` as defined in Eip-7928 compute block access list. Validate it by checking `block.bal_hash == compute_bal_hash(computed_bal)`.
Along with this to enable better readibility we will use helper functions for the modified state transition. We are using rlp serialization instead of ssz to enable backward compatibility.The edge cases as listed in eip 7928 will be considered while implementing.
## Resources
* [Eip-7928](https://eips.ethereum.org/EIPS/eip-7928)
* [Ethereum-Magician](https://ethereum-magicians.org/t/eip-7928-block-level-access-lists/23337/2)
* [Structure Of Block](https://ethereum.org/en/developers/docs/blocks/#block-anatomy)
* [Opcodes](https://www.evm.codes/)
* [revm-inspectors](https://github.com/paradigmxyz/revm-inspectors)