Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt transparent upgradeability pattern #864

Merged
merged 24 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,8 @@ ef-tests: $(EF_TESTS_DIR) ## Runs Ethereum Foundation tests.
# Basic checks to do before opening a PR
pr:
$(MAKE) lint
$(MAKE) test
$(MAKE) test

# Set genesis from system contract source files
genesis:
$(MAKE) -C crates/evm/src/evm/system_contracts genesis
18 changes: 9 additions & 9 deletions bin/citrea/tests/e2e/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1776,28 +1776,28 @@ async fn test_system_tx_effect_on_block_gas_limit() -> Result<(), anyhow::Error>

let seq_port = seq_port_rx.await.unwrap();
let seq_test_client = make_test_client(seq_port).await;
// sys tx use L1BlockHash(48522 + 78491) + Bridge(258971) = 385984 gas
// sys tx use L1BlockHash(50751 + 80720) + Bridge(261215) = 392686 gas
// the block gas limit is 1_500_000 because the system txs gas limit is 1_500_000 (decided with @eyusufatik and @okkothejawa as bridge init takes 1M gas)

// 1500000 - 385984 = 1114016 gas left in block
// 1114016 / 21000 = 53,04... so 53 ether transfer transactions can be included in the block
// 1500000 - 392686 = 1107314 gas left in block
// 1107314 / 21000 = 52,72... so 52 ether transfer transactions can be included in the block

// send 53 ether transfer transactions
// send 52 ether transfer transactions
let addr = Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap();

for _ in 0..52 {
for _ in 0..51 {
let _pending = seq_test_client
.send_eth(addr, None, None, None, 0u128)
.await
.unwrap();
}

// 53th tx should be the last tx in the soft batch
// 52th tx should be the last tx in the soft batch
let last_in_tx = seq_test_client
.send_eth(addr, None, None, None, 0u128)
.await;

// 54th tx should not be in soft batch
// 53th tx should not be in soft batch
let not_in_tx = seq_test_client
.send_eth(addr, None, None, None, 0u128)
.await;
Expand Down Expand Up @@ -2099,7 +2099,7 @@ async fn transaction_failing_on_l1_is_removed_from_mempool() -> Result<(), anyho

let random_wallet_address = random_wallet.address();

let second_block_base_fee = 768592592;
let second_block_base_fee = 768641461;

let _pending = seq_test_client
.send_eth(
Expand Down Expand Up @@ -3016,7 +3016,7 @@ async fn test_gas_limit_too_high() {

let target_gas_limit: u64 = 30_000_000;
let transfer_gas_limit = 21_000;
let system_txs_gas_used = 385984;
let system_txs_gas_used = 390434;
let tx_count = (target_gas_limit - system_txs_gas_used).div_ceil(transfer_gas_limit);
let addr = Address::from_str("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266").unwrap();

Expand Down
4 changes: 2 additions & 2 deletions bin/citrea/tests/evm/ethers_js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe("RpcTests", function() {

it("getCode returns the correct code", async function() {
let code = await provider.getCode("0x3200000000000000000000000000000000000001"); // BitcoinLightClient
expect(code).to.equal("0x6080604052600436106101145760003560e01c8063715018a6116100a0578063d269a03e11610064578063d269a03e14610332578063d761753e14610352578063e30c39781461037a578063ee82ac5e1461038f578063f2fde38b146103bc57600080fd5b8063715018a61461027057806379ba5097146102855780638da5cb5b1461029a578063a91d8b3d146102c7578063ad3cb1cc146102f457600080fd5b80634f1ef286116100e75780634f1ef286146101c85780634ffd344a146101db57806352d1902d1461020b57806357e871e71461022057806361b207e21461023657600080fd5b80630466efc4146101195780630e27bc11146101595780631f5783331461017b57806334cdf78d1461019b575b600080fd5b34801561012557600080fd5b50610146610134366004610d50565b60009081526002602052604090205490565b6040519081526020015b60405180910390f35b34801561016557600080fd5b50610179610174366004610d69565b6103dc565b005b34801561018757600080fd5b50610179610196366004610d50565b610505565b3480156101a757600080fd5b506101466101b6366004610d50565b60016020526000908152604090205481565b6101796101d6366004610dbd565b6105b3565b3480156101e757600080fd5b506101fb6101f6366004610ec8565b6105d2565b6040519015158152602001610150565b34801561021757600080fd5b506101466105f8565b34801561022c57600080fd5b5061014660005481565b34801561024257600080fd5b50610146610251366004610d50565b6000908152600160209081526040808320548352600290915290205490565b34801561027c57600080fd5b50610179610615565b34801561029157600080fd5b50610179610629565b3480156102a657600080fd5b506102af610671565b6040516001600160a01b039091168152602001610150565b3480156102d357600080fd5b506101466102e2366004610d50565b60026020526000908152604090205481565b34801561030057600080fd5b50610325604051806040016040528060058152602001640352e302e360dc1b81525081565b6040516101509190610f47565b34801561033e57600080fd5b506101fb61034d366004610ec8565b6106a6565b34801561035e57600080fd5b506102af73deaddeaddeaddeaddeaddeaddeaddeaddeaddead81565b34801561038657600080fd5b506102af6106b5565b34801561039b57600080fd5b506101466103aa366004610d50565b60009081526001602052604090205490565b3480156103c857600080fd5b506101796103d7366004610f7a565b6106de565b3373deaddeaddeaddeaddeaddeaddeaddeaddeaddead146104445760405162461bcd60e51b815260206004820152601f60248201527f63616c6c6572206973206e6f74207468652073797374656d2063616c6c65720060448201526064015b60405180910390fd5b600080549081900361048a5760405162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015260640161043b565b60008181526001602081905260409091208490556104a9908290610f95565b6000908155838152600260209081526040808320859055915482519081529081018590529081018390527f32eff959e2e8d1609edc4b39ccf75900aa6c1da5719f8432752963fdf008234f9060600160405180910390a1505050565b3373deaddeaddeaddeaddeaddeaddeaddeaddeaddead146105685760405162461bcd60e51b815260206004820152601f60248201527f63616c6c6572206973206e6f74207468652073797374656d2063616c6c657200604482015260640161043b565b600054156105ae5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b604482015260640161043b565b600055565b6105bb610763565b6105c482610808565b6105ce8282610810565b5050565b6000858152600160205260408120546105ee90868686866108d2565b9695505050505050565b6000610602610930565b5060008051602061100e83398151915290565b61061d610979565b61062760006109ab565b565b33806106336106b5565b6001600160a01b0316146106655760405163118cdaa760e01b81526001600160a01b038216600482015260240161043b565b61066e816109ab565b50565b6000807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005b546001600160a01b031692915050565b60006105ee86868686866108d2565b6000807f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00610696565b6106e6610979565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b0319166001600160a01b038316908117825561072a610671565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a35050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806107ea57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166107de60008051602061100e833981519152546001600160a01b031690565b6001600160a01b031614155b156106275760405163703e46dd60e11b815260040160405180910390fd5b61066e610979565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561086a575060408051601f3d908101601f1916820190925261086791810190610fb6565b60015b61089257604051634c9c8ce360e01b81526001600160a01b038316600482015260240161043b565b60008051602061100e83398151915281146108c357604051632a87526960e21b81526004810182905260240161043b565b6108cd83836109e3565b505050565b6000858152600260209081526040808320548151601f8701849004840281018401909252858252916109259188918491908990899081908401838280828437600092019190915250899250610a39915050565b979650505050505050565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146106275760405163703e46dd60e11b815260040160405180910390fd5b33610982610671565b6001600160a01b0316146106275760405163118cdaa760e01b815233600482015260240161043b565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b03191681556105ce82610a77565b6109ec82610ae8565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115610a31576108cd8282610b4d565b6105ce610bc5565b60008385148015610a48575081155b8015610a5357508251155b15610a6057506001610a6f565b610a6c85848685610be4565b90505b949350505050565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b806001600160a01b03163b600003610b1e57604051634c9c8ce360e01b81526001600160a01b038216600482015260240161043b565b60008051602061100e83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051610b6a9190610fcf565b600060405180830381855af49150503d8060008114610ba5576040519150601f19603f3d011682016040523d82523d6000602084013e610baa565b606091505b5091509150610bba858383610c8e565b925050505b92915050565b34156106275760405163b398979f60e01b815260040160405180910390fd5b600060208451610bf49190610feb565b15610c0157506000610a6f565b8351600003610c1257506000610a6f565b818560005b8651811015610c8157610c2b600284610feb565b600103610c4f57610c48610c428883016020015190565b83610ced565b9150610c68565b610c6582610c608984016020015190565b610ced565b91505b60019290921c91610c7a602082610f95565b9050610c17565b5090931495945050505050565b606082610ca357610c9e82610cf9565b610ce6565b8151158015610cba57506001600160a01b0384163b155b15610ce357604051639996b31560e01b81526001600160a01b038516600482015260240161043b565b50805b9392505050565b6000610ce68383610d22565b805115610d095780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b60008260005281602052602060006040600060025afa50602060006020600060025afa505060005192915050565b600060208284031215610d6257600080fd5b5035919050565b60008060408385031215610d7c57600080fd5b50508035926020909101359150565b80356001600160a01b0381168114610da257600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60008060408385031215610dd057600080fd5b610dd983610d8b565b9150602083013567ffffffffffffffff80821115610df657600080fd5b818501915085601f830112610e0a57600080fd5b813581811115610e1c57610e1c610da7565b604051601f8201601f19908116603f01168101908382118183101715610e4457610e44610da7565b81604052828152886020848701011115610e5d57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60008083601f840112610e9157600080fd5b50813567ffffffffffffffff811115610ea957600080fd5b602083019150836020828501011115610ec157600080fd5b9250929050565b600080600080600060808688031215610ee057600080fd5b8535945060208601359350604086013567ffffffffffffffff811115610f0557600080fd5b610f1188828901610e7f565b96999598509660600135949350505050565b60005b83811015610f3e578181015183820152602001610f26565b50506000910152565b6020815260008251806020840152610f66816040850160208701610f23565b601f01601f19169190910160400192915050565b600060208284031215610f8c57600080fd5b610ce682610d8b565b80820180821115610bbf57634e487b7160e01b600052601160045260246000fd5b600060208284031215610fc857600080fd5b5051919050565b60008251610fe1818460208701610f23565b9190910192915050565b60008261100857634e487b7160e01b600052601260045260246000fd5b50069056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca26469706673582212208a59ff38af63c8a0ca256bb007b725d98ab1c290599e8cdf87bcbf2a98add93164736f6c63430008190033");
expect(code).to.equal("0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806357e871e71161007157806357e871e71461014c57806361b207e214610155578063a91d8b3d14610182578063d269a03e146101a2578063d761753e146101b5578063ee82ac5e146101e857600080fd5b80630466efc4146100ae5780630e27bc11146100e15780631f578333146100f657806334cdf78d146101095780634ffd344a14610129575b600080fd5b6100ce6100bc366004610599565b60009081526002602052604090205490565b6040519081526020015b60405180910390f35b6100f46100ef3660046105b2565b610208565b005b6100f4610104366004610599565b610331565b6100ce610117366004610599565b60016020526000908152604090205481565b61013c61013736600461061d565b6103df565b60405190151581526020016100d8565b6100ce60005481565b6100ce610163366004610599565b6000908152600160209081526040808320548352600290915290205490565b6100ce610190366004610599565b60026020526000908152604090205481565b61013c6101b036600461061d565b610405565b6101d073deaddeaddeaddeaddeaddeaddeaddeaddeaddead81565b6040516001600160a01b0390911681526020016100d8565b6100ce6101f6366004610599565b60009081526001602052604090205490565b3373deaddeaddeaddeaddeaddeaddeaddeaddeaddead146102705760405162461bcd60e51b815260206004820152601f60248201527f63616c6c6572206973206e6f74207468652073797374656d2063616c6c65720060448201526064015b60405180910390fd5b60008054908190036102b65760405162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b6044820152606401610267565b60008181526001602081905260409091208490556102d5908290610678565b6000908155838152600260209081526040808320859055915482519081529081018590529081018390527f32eff959e2e8d1609edc4b39ccf75900aa6c1da5719f8432752963fdf008234f9060600160405180910390a1505050565b3373deaddeaddeaddeaddeaddeaddeaddeaddeaddead146103945760405162461bcd60e51b815260206004820152601f60248201527f63616c6c6572206973206e6f74207468652073797374656d2063616c6c6572006044820152606401610267565b600054156103da5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610267565b600055565b6000858152600160205260408120546103fb9086868686610410565b9695505050505050565b60006103fb86868686865b6000858152600260209081526040808320548151601f870184900484028101840190925285825291610463918891849190899089908190840183828082843760009201919091525089925061046e915050565b979650505050505050565b6000838514801561047d575081155b801561048857508251155b15610495575060016104a4565b6104a1858486856104ac565b90505b949350505050565b6000602084516104bc9190610699565b156104c9575060006104a4565b83516000036104da575060006104a4565b818560005b8651811015610549576104f3600284610699565b6001036105175761051061050a8883016020015190565b83610556565b9150610530565b61052d826105288984016020015190565b610556565b91505b60019290921c91610542602082610678565b90506104df565b5090931495945050505050565b6000610562838361056b565b90505b92915050565b60008260005281602052602060006040600060025afa50602060006020600060025afa505060005192915050565b6000602082840312156105ab57600080fd5b5035919050565b600080604083850312156105c557600080fd5b50508035926020909101359150565b60008083601f8401126105e657600080fd5b50813567ffffffffffffffff8111156105fe57600080fd5b60208301915083602082850101111561061657600080fd5b9250929050565b60008060008060006080868803121561063557600080fd5b8535945060208601359350604086013567ffffffffffffffff81111561065a57600080fd5b610666888289016105d4565b96999598509660600135949350505050565b8082018082111561056557634e487b7160e01b600052601160045260246000fd5b6000826106b657634e487b7160e01b600052601260045260246000fd5b50069056");
});

it("getStorage returns the correct storage", async function() {
Expand Down Expand Up @@ -238,7 +238,7 @@ describe("RpcTests", function() {
tx_receipt = await tx_response.wait(1);
expect.fail('Expected an error to be thrown');
} catch (error) {
expect(error.message).to.match(/transaction execution reverted \(action="sendTransaction", data=null, reason=null, invocation=null, revert=null, transaction={ "data": "", "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "to": "0x3100000000000000000000000000000000000002" }, receipt={ "_type": "TransactionReceipt", "blobGasPrice": null, "blobGasUsed": null, "blockHash": "0x[0-9a-fA-F]+", "blockNumber": \d+, "contractAddress": null, "cumulativeGasUsed": "26805", "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "gasPrice": "1000000", "gasUsed": "26805", "hash": "0x[0-9a-fA-F]+", "index": 0, "logs": \[ ], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "root": null, "status": 0, "to": "0x3100000000000000000000000000000000000002" }, code=CALL_EXCEPTION, version=6\.12\.1\)/);
expect(error.message).to.match(/transaction execution reverted \(action="sendTransaction", data=null, reason=null, invocation=null, revert=null, transaction={ "data": "", "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "to": "0x3100000000000000000000000000000000000002" }, receipt={ "_type": "TransactionReceipt", "blobGasPrice": null, "blobGasUsed": null, "blockHash": "0x[0-9a-fA-F]+", "blockNumber": \d+, "contractAddress": null, "cumulativeGasUsed": "\d+", "from": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "gasPrice": "1000000", "gasUsed": "\d+", "hash": "0x[0-9a-fA-F]+", "index": 0, "logs": \[ ], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "root": null, "status": 0, "to": "0x3100000000000000000000000000000000000002" }, code=CALL_EXCEPTION, version=6\.12\.1\)/);
eyusufatik marked this conversation as resolved.
Show resolved Hide resolved
}
});

Expand Down
Loading
Loading