mirror of https://github.com/hyperledger/besu
EIP 7702 (#7237)
* EIP 7702 first draft Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * added CHANGELOG.md entry Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * bug fixes, added first tests Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * container verify GitHub workflow (#7239) Container verification step in release process automated with the container verify GitHub workflow. New workflow is triggered at the end of the release workflow which will check the release container images starts successfully. Verification test only checks container starts and reach the Ethereum main loop Signed-off-by: Chaminda Divitotawela <cdivitotawela@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Investigate chain halts when syncing (#7162) Fix some reasons for chain download halts when syncing Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net> Signed-off-by: Stefan Pingel <16143240+pinges@users.noreply.github.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Check for EOFCreate subcontainer rules (#7232) Check and test for the unused container rule, and only returncontract targets can have truncated data rule. Also test the other subcontainer rules in unit tests. Signed-off-by: Danno Ferrin <danno@numisight.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Remove deprecation message for `--Xp2p-peer-lower-bound` (#7247) Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * less invasive code injection approach Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * added missing java doc & fixed test Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * added (currently non-working) acceptance test, some bug fixes in the transaction validation and tx pool logic Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * fix spotless Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * updated acceptance test, still not working, newPayload request seems to be necessary before final fork choice update Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * use correct world state to inject temporary code, inject code in existing accounts as well Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * renamed test service to prague, because the engine versions used are only available in the prague hard fork Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * fixed acceptance test, some bug fixes if authorized account does not yet exist Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Add build version option to prefix git hash with custom version property (#7222) * Add build version option to prefix git hash with custom version property * Refactor to make appending the git hash a boolean property. Include a commented-out example of how to use the properties in the gradle file Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Handle invalid snap getTrieNode requests with empty paths gracefully (#7221) Signed-off-by: Jason Frame <jason.frame@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * fix typos in CHANGELOG (#7226) Signed-off-by: Ties <71668189+TiesD@users.noreply.github.com> Co-authored-by: Matt Nelson <85905982+non-fungible-nelson@users.noreply.github.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * feat: Add network option for LUKSO Mainnet (#7223) * Add option for LUKSO network Signed-off-by: Wolmin <lamonos123@gmail.com> * Add tests for LUKSO Signed-off-by: Wolmin <lamonos123@gmail.com> * Apply spotless Signed-off-by: Wolmin <lamonos123@gmail.com> * Add changelog entry Signed-off-by: Wolmin <lamonos123@gmail.com> * Fix duplicate func Signed-off-by: Wolmin <lamonos123@gmail.com> * Fix changelog Signed-off-by: Wolmin <lamonos123@gmail.com> * Add bootnodes to genesis Signed-off-by: Wolmin <lamonos123@gmail.com> --------- Signed-off-by: Wolmin <lamonos123@gmail.com> Signed-off-by: Wolmin <44748271+Wolmin@users.noreply.github.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Update Docker base image to Ubuntu 24.04 (#7251) Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Reconfigure how Protocol Specs are created WRT EVM condiguration (#7245) Make the max code size and max initcode size a part of the EVM configuration. As part of the change we need to move the tasks CodeFactory once handled as a static class and move it into the EVM. This has a nice follow on effect that we don't need to pass in max EOF versions or max code sizes anymore. Signed-off-by: Danno Ferrin <danno@numisight.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Fix the wrong 'Identifier' and 'Synchronizer' usage (#7252) * fix the synchronizer usage Signed-off-by: Leni <leniram159@gmail.com> * fix Identifier usage Signed-off-by: Leni <leniram159@gmail.com> --------- Signed-off-by: Leni <leniram159@gmail.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Fix flaky SECP256R1 test (#7249) Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * update to work with the new max retries value (#7253) Signed-off-by: Justin Florentine <justin+github@florentine.us> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Temporary CancunEOF fork for EOF testing. (#7227) Add Genesis ("CancunEOFTime") and reference test ("CancunEOF") support for a temporary Cancun+EOF fork, in anticipation of potential devnets. Signed-off-by: Danno Ferrin <danno@numisight.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * fixed bug introduced through merge of main, made acceptance test easier to understand Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * added missing java docs Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * removed unnecessary tag Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * make encodeSingleSetCode public again Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Snapserver responses to return at least one response (#7190) Signed-off-by: Jason Frame <jason.frame@consensys.net> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * copy setCodeTransactionPayloads as well Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * fixed bug during tests with forrest db Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Snapserver GetTrieNodes request to handle short hash for storage (#7264) Signed-off-by: Jason Frame <jason.frame@consensys.net> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * javadoc: Adding javadoc for ethstats module (#7269) * javadoc: Adding javadoc for ethstats module --------- Signed-off-by: Usman Saleem <usman@usmans.info> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Fix javadoc for ethereum:core top level package (#7270) * javadoc - Apply javadoc to ethereum core top level package --------- Signed-off-by: Usman Saleem <usman@usmans.info> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Disable Flaky tests - permissioning (#7256) * disable some flaky tests Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> * correct name for test Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> * formatting Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> * disable some flaky tests Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> --------- Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Usman Saleem <usman@usmans.info> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Add bootnodes to the maintained peer list (#7257) * Add bootnodes to the maintained peer list Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update unit tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add entry in changelog Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Tweak unit test Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactor to keep common steps the same for both cases Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add debug log, call sanitizePeers() only once Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Fix javadoc for ethereum api module, graphql package (#7272) * javadoc - Adding missing javadocs ethereum:api graphql package Signed-off-by: Usman Saleem <usman@usmans.info> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * T8n support for isStateTest and empty accounts (#7275) Update t8n executor to support new isStateTest env flag that will disable extra-transactional processing such as block rewards and beacon root. Also, make sure such extra-transactional commits don't create empty accounts. Signed-off-by: Danno Ferrin <danno@numisight.com> Co-authored-by: Usman Saleem <usman@usmans.info> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Promote storage x-trie-log subcommand to trie-log (#7278) Signed-off-by: Simon Dudley <simon.dudley@consensys.net> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Evm tool readme update (#7274) * update paths to binary. update docker build to use java 21 * updated suggested jdk --------- Signed-off-by: Justin Florentine <justin+github@florentine.us> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * javadoc - Add missing javadoc for evmtool module (#7277) Signed-off-by: Usman Saleem <usman@usmans.info> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Rename ValidatorPublicKey to ValidatorPubKey (#7280) Adapt to EIP-7002 name change for validator public key in all places. Signed-off-by: Danno Ferrin <danno@numisight.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Add info-level diagnostic logs to aid with resolving stalled BFT chains (#7271) * Add info-level diagnostic logs to aid with resolving stalled BFT chains Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add javadoc Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Matt Whitehead <matthew.whitehead@kaleido.io> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Update EIP-2935 contract (#7281) Use the updated contract and address for EIP-2539. Signed-off-by: Danno Ferrin <danno@numisight.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * add evmtool compability, fixing bugs related to sender recovery of 7702 txs and handling authorizations to empty accounts Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Deeper tracing of self-destructed accounts (#7284) Consider previously self-destructed accounts when creating accounts. Signed-off-by: Danno Ferrin <danno@numisight.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * next release version after 24.7.0 (#7285) Signed-off-by: garyschulte <garyschulte@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Add experimental `--Xsnapsync-bft-enabled` which enables snap sync for BFT chains (#7140) * Create a BFT-specific pivot block handler Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Change visibility Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactor sync-peer-count internal variable to match name, add experimental flag to enabled snap + BFT Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Merge with main Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix uppercase Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Address synchronization issue with trie pruning. Create BFT-specific account range handler. Add pipeline name and logs Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove debug log Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * fixing snapsync for empty state Signed-off-by: Karim Taam <karim.t2am@gmail.com> * Don't queue up events we can't handle Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix timing window where a validator with an empty data dir sometimes falls back to full sync if peer status isn't received quickly enough Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove BFT-specific account request class. Not needed Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactor some more 'fast' sync variables that are common to all pivot-based sync types Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * In FULL sync mode, disable bonsai-limit-trie-logs-enabled instead of failing to start Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add javadoc comments, clarify overriding bonsai-limit-trie-logs-enabled Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Add BFT pivot block selector tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Fix failure error message Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove the unnamed Pipe constructor and update tests to set a pipe name Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Revert some info logs back to debug given the feedback on noise in the logs syncing with holesky Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Refactor fastSyncPivotDistance to syncPivotDistance Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Incomplete refactoring Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Update BFT event queueing tests Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Event queue test fixes Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> * Remove automatic setting of bonsai-limit-trie-logs-enabled to false if sync-mode = FULL (moving to another PR) Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> --------- Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Karim Taam <karim.t2am@gmail.com> Signed-off-by: Matt Whitehead <matthew.whitehead@kaleido.io> Co-authored-by: Karim Taam <karim.t2am@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Turn off CicleCI for Besu (#7291) All the CI jobs run in GitHub actions and Circle CI it no longer needed in Besu project Signed-off-by: Chaminda Divitotawela <cdivitotawela@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Check for snap server (#6609) * EthPeer add isServingSnap to be able to make sure that we have enough snap servers connected when we are snap syncing Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Implement System Calls (#7263) Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * wrap WorldUpdater inside a WorldUpdaterService to inject the authorized code whenever needed Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Update limit trie logs validation message for sync-mode=FULL (#7279) Signed-off-by: Simon Dudley <simon.dudley@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Execute requests before block persist (#7295) Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * fixed MainnetTransactionProcessor retrieval of correctn `to` account with injected code, fixed code injection Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * only first authorization is accepted, all the following ones are ignored Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * don't cache account with empty code Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * revert wrapping of world updater, as its `updater()` method creates a type of nesting that is not compatible with wrapping it. Instead a service is injected in the world updater to inject the code into the authorized accounts Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Fixed outdated tech redirect link. (#7297) * fix wiki link Signed-off-by: Snazzy <snazzysam933@gmail.com> * fix format Signed-off-by: Snazzy <snazzysam933@gmail.com> * change knownHash Signed-off-by: Snazzy <snazzysam933@gmail.com> --------- Signed-off-by: Snazzy <snazzysam933@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Increment private nonce even if transaction failed. (#6593) Increment private nonce even if transaction failed Signed-off-by: George Tebrean <george@web3labs.com> Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net> Co-authored-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net> Co-authored-by: Stefan Pingel <16143240+pinges@users.noreply.github.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * feat: Enhance --profile to load external profiles (#7292) * feat: --profile can load external profiles * fix external profile name method * fix ProfilesCompletionCandidate * test: Add unit tests * changelog: Update changelog * test: Fix TomlConfigurationDefaultProviderTest * test: Fix BesuCommandTest --------- Signed-off-by: Usman Saleem <usman@usmans.info> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Fix status badge for documentation (#7304) Documentation has been moved to GitHub pages and no longer use readthedocs. Updated the README status badge for docs with correct link Signed-off-by: Chaminda Divitotawela <cdivitotawela@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * [MINOR] Fixed some typos (#7299) * typos Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> --------- Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * refactored to share one AuthorizedAccountService between the different instances of the world updater, renamed some classes Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * spotless Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * load code for authorization at the beginning of the transaction Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * ignore authorization if chain id doesn't match Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * cache authority address, evmtool: do not fail if sender address is wrong Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Add evmtool block-test subcommand (#7293) * Add evmtool block-test subcommand Add an evmtool subcommand that will run non-hive blockchain tests. Signed-off-by: Danno Ferrin <danno@numisight.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Make the retrying snap tasks switching (#7307) * make snap tasks switching Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * 6612: Remove deprecated sync modes and related helper methods (#7309) * 6612: Remove deprecated sync modes and related helper methods Signed-off-by: Matilda-Clerke <matilda.shay.clerke@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * EOF Reference Test Fixes (#7306) Fix a number of issues found in reference tests and evmone tests. - Be tolerant of more nulls in json - Support ContainerKind in reference tests - re-order EXTCALL oeprands - correct return value for REVERT in EXT*CALL - re-order EOFCREATE code validation Signed-off-by: Danno Ferrin <danno@numisight.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * test template refactor, bump besu-native to 0.9.2 (#7315) Signed-off-by: garyschulte <garyschulte@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Feature/use gnark-crypto for eip-2537 (#7316) * use gnark-crypto for bls precompiles Signed-off-by: garyschulte <garyschulte@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * 6612 update changelog with removed syncmodes (#7320) * 6612: Update changelog with removal of deprecated sync modes Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * 6612: Update changelog with removal of deprecated sync modes Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> * 6612: Update changelog with removal of deprecated sync modes Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> --------- Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Update datacopy (#7319) Check for OOG earlier in DataCopy. Add unit tests to cover operation branches. Signed-off-by: Danno Ferrin <danno@numisight.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * disable flaky test (#7308) * disable flaky test Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> * disable flaky test Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> --------- Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Update unit test (#7317) * Update parameterized unit tests so the enumerate with --dry-run * Update the prague-withdrawal.json unit test to handle current code Signed-off-by: Danno Ferrin <danno@numisight.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * persist accounts that have storage updates, but no nonce, balance nor code Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Revert "persist accounts that have storage updates, but no nonce, balance nor code" This reverts commit 9c9121a115ecb09f1c3add1fff4da3b102f8b429. Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * removed PKI backed QBFT (#7310) * removed PKI backed QBFT Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> * changelog Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> --------- Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * EIP-7251 add consolidation request type (#7266) * add request type for consolidations, encoder, decoder and tests * added raw tx for consolidation * add consolidation reqs to EngineGetPayloadResultV4 * set storage slot value to 0 initially and value for tx * updates plugin api Signed-off-by: Justin Florentine <justin+github@florentine.us> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> --------- Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Justin Florentine <justin+github@florentine.us> Co-authored-by: Justin Florentine <justin+github@florentine.us> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * fix: `eth_call` deserialization to correctly ignore unknown fields in the transaction object (#7323) * fix: Use Builder for JsonCallParameter * changelog * add additional unit tests * fix: Update builder to withGas to match the json eth_call --------- Signed-off-by: Usman Saleem <usman@usmans.info> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * Stop transaction selection on TX_EVALUATION_TOO_LONG (#7330) Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * message frame buider will create AuthorizedCodeService by itsef if it isn't set Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * get correct nonce for authorization Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * nonce only returns a vaid nonce, new method nonceList returns all the nonces Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * plugs leaky abstraction Signed-off-by: Justin Florentine <justin+github@florentine.us> * some renaming, acceptance tests checks for exact balance of tx sponsor at the end. Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * inject the 7702 code into DiffBasedWorldStateUpdateAccumulator.createAccount Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * spotless Signed-off-by: Justin Florentine <justin+github@florentine.us> * spotless fix, removed todos Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> * make AuthorityProcessor & chain id for it optional Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> --------- Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net> Signed-off-by: Chaminda Divitotawela <cdivitotawela@gmail.com> Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net> Signed-off-by: Stefan Pingel <16143240+pinges@users.noreply.github.com> Signed-off-by: Danno Ferrin <danno@numisight.com> Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net> Signed-off-by: Matthew Whitehead <matthew1001@gmail.com> Signed-off-by: Jason Frame <jason.frame@consensys.net> Signed-off-by: Ties <71668189+TiesD@users.noreply.github.com> Signed-off-by: Wolmin <lamonos123@gmail.com> Signed-off-by: Wolmin <44748271+Wolmin@users.noreply.github.com> Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: Leni <leniram159@gmail.com> Signed-off-by: Justin Florentine <justin+github@florentine.us> Signed-off-by: Usman Saleem <usman@usmans.info> Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Simon Dudley <simon.dudley@consensys.net> Signed-off-by: Matt Whitehead <matthew.whitehead@kaleido.io> Signed-off-by: garyschulte <garyschulte@gmail.com> Signed-off-by: Karim Taam <karim.t2am@gmail.com> Signed-off-by: Snazzy <snazzysam933@gmail.com> Signed-off-by: George Tebrean <george@web3labs.com> Signed-off-by: Matilda-Clerke <matilda.shay.clerke@gmail.com> Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net> Co-authored-by: Chaminda Divitotawela <cdivitotawela@users.noreply.github.com> Co-authored-by: Stefan Pingel <16143240+pinges@users.noreply.github.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Danno Ferrin <danno@numisight.com> Co-authored-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net> Co-authored-by: Matt Whitehead <matthew.whitehead@kaleido.io> Co-authored-by: Jason Frame <jason.frame@consensys.net> Co-authored-by: Ties <71668189+TiesD@users.noreply.github.com> Co-authored-by: Matt Nelson <85905982+non-fungible-nelson@users.noreply.github.com> Co-authored-by: Wolmin <44748271+Wolmin@users.noreply.github.com> Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Co-authored-by: leniram159 <leniram159@gmail.com> Co-authored-by: Justin Florentine <justin+github@florentine.us> Co-authored-by: Usman Saleem <usman@usmans.info> Co-authored-by: Simon Dudley <simon.dudley@consensys.net> Co-authored-by: garyschulte <garyschulte@gmail.com> Co-authored-by: Karim Taam <karim.t2am@gmail.com> Co-authored-by: gringsam <snazzysam933@gmail.com> Co-authored-by: George Tebrean <99179176+gtebrean@users.noreply.github.com> Co-authored-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net> Co-authored-by: Matilda-Clerke <matilda.shay.clerke@gmail.com>pull/7262/head
parent
76a3df704e
commit
895c17d5d2
@ -0,0 +1,193 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.tests.acceptance.ethereum; |
||||
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; |
||||
|
||||
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; |
||||
import org.hyperledger.besu.tests.acceptance.dsl.transaction.eth.EthTransactions; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.Optional; |
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import com.fasterxml.jackson.databind.node.ObjectNode; |
||||
import okhttp3.Call; |
||||
import okhttp3.MediaType; |
||||
import okhttp3.OkHttpClient; |
||||
import okhttp3.Request; |
||||
import okhttp3.RequestBody; |
||||
import okhttp3.Response; |
||||
import org.web3j.protocol.core.methods.response.EthBlock; |
||||
|
||||
public class PragueAcceptanceTestHelper { |
||||
protected static final MediaType MEDIA_TYPE_JSON = |
||||
MediaType.parse("application/json; charset=utf-8"); |
||||
|
||||
private final OkHttpClient httpClient; |
||||
private final ObjectMapper mapper; |
||||
private final BesuNode besuNode; |
||||
private final EthTransactions ethTransactions; |
||||
|
||||
private long blockTimeStamp = 0; |
||||
|
||||
PragueAcceptanceTestHelper(final BesuNode besuNode, final EthTransactions ethTransactions) { |
||||
this.besuNode = besuNode; |
||||
this.ethTransactions = ethTransactions; |
||||
httpClient = new OkHttpClient(); |
||||
mapper = new ObjectMapper(); |
||||
} |
||||
|
||||
public void buildNewBlock() throws IOException { |
||||
final EthBlock.Block block = besuNode.execute(ethTransactions.block()); |
||||
|
||||
blockTimeStamp += 1; |
||||
final Call buildBlockRequest = |
||||
createEngineCall(createForkChoiceRequest(block.getHash(), blockTimeStamp)); |
||||
|
||||
final String payloadId; |
||||
try (final Response buildBlockResponse = buildBlockRequest.execute()) { |
||||
payloadId = |
||||
mapper |
||||
.readTree(buildBlockResponse.body().string()) |
||||
.get("result") |
||||
.get("payloadId") |
||||
.asText(); |
||||
|
||||
assertThat(payloadId).isNotEmpty(); |
||||
} |
||||
|
||||
waitFor(500); |
||||
|
||||
final Call getPayloadRequest = createEngineCall(createGetPayloadRequest(payloadId)); |
||||
|
||||
final ObjectNode executionPayload; |
||||
final String newBlockHash; |
||||
final String parentBeaconBlockRoot; |
||||
try (final Response getPayloadResponse = getPayloadRequest.execute()) { |
||||
assertThat(getPayloadResponse.code()).isEqualTo(200); |
||||
|
||||
executionPayload = |
||||
(ObjectNode) |
||||
mapper |
||||
.readTree(getPayloadResponse.body().string()) |
||||
.get("result") |
||||
.get("executionPayload"); |
||||
|
||||
newBlockHash = executionPayload.get("blockHash").asText(); |
||||
parentBeaconBlockRoot = executionPayload.remove("parentBeaconBlockRoot").asText(); |
||||
|
||||
assertThat(newBlockHash).isNotEmpty(); |
||||
} |
||||
|
||||
final Call newPayloadRequest = |
||||
createEngineCall( |
||||
createNewPayloadRequest(executionPayload.toString(), parentBeaconBlockRoot)); |
||||
try (final Response newPayloadResponse = newPayloadRequest.execute()) { |
||||
assertThat(newPayloadResponse.code()).isEqualTo(200); |
||||
} |
||||
|
||||
final Call moveChainAheadRequest = createEngineCall(createForkChoiceRequest(newBlockHash)); |
||||
|
||||
try (final Response moveChainAheadResponse = moveChainAheadRequest.execute()) { |
||||
assertThat(moveChainAheadResponse.code()).isEqualTo(200); |
||||
} |
||||
} |
||||
|
||||
private Call createEngineCall(final String request) { |
||||
return httpClient.newCall( |
||||
new Request.Builder() |
||||
.url(besuNode.engineRpcUrl().get()) |
||||
.post(RequestBody.create(request, MEDIA_TYPE_JSON)) |
||||
.build()); |
||||
} |
||||
|
||||
private String createForkChoiceRequest(final String blockHash) { |
||||
return createForkChoiceRequest(blockHash, null); |
||||
} |
||||
|
||||
private String createForkChoiceRequest(final String parentBlockHash, final Long timeStamp) { |
||||
final Optional<Long> maybeTimeStamp = Optional.ofNullable(timeStamp); |
||||
|
||||
String forkChoiceRequest = |
||||
"{" |
||||
+ " \"jsonrpc\": \"2.0\"," |
||||
+ " \"method\": \"engine_forkchoiceUpdatedV3\"," |
||||
+ " \"params\": [" |
||||
+ " {" |
||||
+ " \"headBlockHash\": \"" |
||||
+ parentBlockHash |
||||
+ "\"," |
||||
+ " \"safeBlockHash\": \"" |
||||
+ parentBlockHash |
||||
+ "\"," |
||||
+ " \"finalizedBlockHash\": \"" |
||||
+ parentBlockHash |
||||
+ "\"" |
||||
+ " }"; |
||||
|
||||
if (maybeTimeStamp.isPresent()) { |
||||
forkChoiceRequest += |
||||
" ,{" |
||||
+ " \"timestamp\": \"" |
||||
+ Long.toHexString(maybeTimeStamp.get()) |
||||
+ "\"," |
||||
+ " \"prevRandao\": \"0x0000000000000000000000000000000000000000000000000000000000000000\"," |
||||
+ " \"suggestedFeeRecipient\": \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\"," |
||||
+ " \"withdrawals\": []," |
||||
+ " \"parentBeaconBlockRoot\": \"0x0000000000000000000000000000000000000000000000000000000000000000\"" |
||||
+ " }"; |
||||
} |
||||
|
||||
forkChoiceRequest += " ]," + " \"id\": 67" + "}"; |
||||
|
||||
return forkChoiceRequest; |
||||
} |
||||
|
||||
private String createGetPayloadRequest(final String payloadId) { |
||||
return "{" |
||||
+ " \"jsonrpc\": \"2.0\"," |
||||
+ " \"method\": \"engine_getPayloadV4\"," |
||||
+ " \"params\": [\"" |
||||
+ payloadId |
||||
+ "\"]," |
||||
+ " \"id\": 67" |
||||
+ "}"; |
||||
} |
||||
|
||||
private String createNewPayloadRequest( |
||||
final String executionPayload, final String parentBeaconBlockRoot) { |
||||
return "{" |
||||
+ " \"jsonrpc\": \"2.0\"," |
||||
+ " \"method\": \"engine_newPayloadV4\"," |
||||
+ " \"params\": [" |
||||
+ executionPayload |
||||
+ ",[]," |
||||
+ "\"" |
||||
+ parentBeaconBlockRoot |
||||
+ "\"" |
||||
+ "]," |
||||
+ " \"id\": 67" |
||||
+ "}"; |
||||
} |
||||
|
||||
private static void waitFor(final long durationMilliSeconds) { |
||||
try { |
||||
Thread.sleep(durationMilliSeconds); |
||||
} catch (InterruptedException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,125 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.tests.acceptance.ethereum; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
import org.hyperledger.besu.crypto.SECP256K1; |
||||
import org.hyperledger.besu.datatypes.Address; |
||||
import org.hyperledger.besu.datatypes.TransactionType; |
||||
import org.hyperledger.besu.datatypes.Wei; |
||||
import org.hyperledger.besu.ethereum.core.SetCodeAuthorization; |
||||
import org.hyperledger.besu.ethereum.core.Transaction; |
||||
import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; |
||||
import org.hyperledger.besu.tests.acceptance.dsl.account.Account; |
||||
import org.hyperledger.besu.tests.acceptance.dsl.blockchain.Amount; |
||||
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; |
||||
|
||||
import java.io.IOException; |
||||
import java.math.BigInteger; |
||||
import java.util.List; |
||||
import java.util.Optional; |
||||
|
||||
import org.apache.tuweni.bytes.Bytes; |
||||
import org.apache.tuweni.bytes.Bytes32; |
||||
import org.junit.jupiter.api.BeforeEach; |
||||
import org.junit.jupiter.api.Test; |
||||
import org.web3j.protocol.core.methods.response.TransactionReceipt; |
||||
|
||||
public class SetCodeTransactionAcceptanceTest extends AcceptanceTestBase { |
||||
private static final String GENESIS_FILE = "/dev/dev_prague.json"; |
||||
private static final SECP256K1 secp256k1 = new SECP256K1(); |
||||
|
||||
public static final Address SEND_ALL_ETH_CONTRACT_ADDRESS = |
||||
Address.fromHexStringStrict("0000000000000000000000000000000000009999"); |
||||
|
||||
private final Account authorizer = |
||||
accounts.createAccount( |
||||
Address.fromHexStringStrict("8da48afC965480220a3dB9244771bd3afcB5d895")); |
||||
public static final Bytes AUTHORIZER_PRIVATE_KEY = |
||||
Bytes.fromHexString("11f2e7b6a734ab03fa682450e0d4681d18a944f8b83c99bf7b9b4de6c0f35ea1"); |
||||
|
||||
private final Account transactionSponsor = |
||||
accounts.createAccount( |
||||
Address.fromHexStringStrict("a05b21E5186Ce93d2a226722b85D6e550Ac7D6E3")); |
||||
public static final Bytes TRANSACTION_SPONSOR_PRIVATE_KEY = |
||||
Bytes.fromHexString("3a4ff6d22d7502ef2452368165422861c01a0f72f851793b372b87888dc3c453"); |
||||
|
||||
private BesuNode besuNode; |
||||
private PragueAcceptanceTestHelper testHelper; |
||||
|
||||
@BeforeEach |
||||
void setUp() throws IOException { |
||||
besuNode = besu.createExecutionEngineGenesisNode("besuNode", GENESIS_FILE); |
||||
cluster.start(besuNode); |
||||
|
||||
testHelper = new PragueAcceptanceTestHelper(besuNode, ethTransactions); |
||||
} |
||||
|
||||
/** |
||||
* At the beginning of the test both the authorizer and the transaction sponsor have a balance of |
||||
* 90000 ETH. The authorizer creates an authorization for a contract that send all its ETH to any |
||||
* given address. The transaction sponsor created a 7702 transaction with it and sends all the ETH |
||||
* from the authorizer to itself. The authorizer balance should be 0 and the transaction sponsor |
||||
* balance should be 180000 ETH minus the transaction costs. |
||||
*/ |
||||
@Test |
||||
public void shouldTransferAllEthOfAuthorizerToSponsor() throws IOException { |
||||
|
||||
// 7702 transaction
|
||||
final org.hyperledger.besu.datatypes.SetCodeAuthorization authorization = |
||||
SetCodeAuthorization.builder() |
||||
.chainId(BigInteger.valueOf(20211)) |
||||
.address(SEND_ALL_ETH_CONTRACT_ADDRESS) |
||||
.signAndBuild( |
||||
secp256k1.createKeyPair( |
||||
secp256k1.createPrivateKey(AUTHORIZER_PRIVATE_KEY.toUnsignedBigInteger()))); |
||||
|
||||
final Transaction tx = |
||||
Transaction.builder() |
||||
.type(TransactionType.SET_CODE) |
||||
.chainId(BigInteger.valueOf(20211)) |
||||
.nonce(0) |
||||
.maxPriorityFeePerGas(Wei.of(1000000000)) |
||||
.maxFeePerGas(Wei.fromHexString("0x02540BE400")) |
||||
.gasLimit(1000000) |
||||
.to(Address.fromHexStringStrict(authorizer.getAddress())) |
||||
.value(Wei.ZERO) |
||||
.payload(Bytes32.leftPad(Bytes.fromHexString(transactionSponsor.getAddress()))) |
||||
.accessList(List.of()) |
||||
.setCodeTransactionPayloads(List.of(authorization)) |
||||
.signAndBuild( |
||||
secp256k1.createKeyPair( |
||||
secp256k1.createPrivateKey( |
||||
TRANSACTION_SPONSOR_PRIVATE_KEY.toUnsignedBigInteger()))); |
||||
|
||||
final String txHash = |
||||
besuNode.execute(ethTransactions.sendRawTransaction(tx.encoded().toHexString())); |
||||
testHelper.buildNewBlock(); |
||||
|
||||
Optional<TransactionReceipt> maybeTransactionReceipt = |
||||
besuNode.execute(ethTransactions.getTransactionReceipt(txHash)); |
||||
assertThat(maybeTransactionReceipt).isPresent(); |
||||
|
||||
cluster.verify(authorizer.balanceEquals(0)); |
||||
|
||||
final String gasPriceWithout0x = |
||||
maybeTransactionReceipt.get().getEffectiveGasPrice().substring(2); |
||||
final BigInteger txCost = |
||||
maybeTransactionReceipt.get().getGasUsed().multiply(new BigInteger(gasPriceWithout0x, 16)); |
||||
BigInteger expectedSponsorBalance = new BigInteger("180000000000000000000000").subtract(txCost); |
||||
cluster.verify(transactionSponsor.balanceEquals(Amount.wei(expectedSponsorBalance))); |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,82 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.datatypes; |
||||
|
||||
import org.hyperledger.besu.crypto.SECPSignature; |
||||
|
||||
import java.math.BigInteger; |
||||
import java.util.Optional; |
||||
|
||||
/** |
||||
* SetCodeAuthorization is a data structure that represents the authorization to set code on a EOA |
||||
* account. |
||||
*/ |
||||
public interface SetCodeAuthorization { |
||||
/** |
||||
* Return the chain id. |
||||
* |
||||
* @return chain id |
||||
*/ |
||||
BigInteger chainId(); |
||||
|
||||
/** |
||||
* Return the address of the account which code will be used. |
||||
* |
||||
* @return address |
||||
*/ |
||||
Address address(); |
||||
|
||||
/** |
||||
* Return the signature. |
||||
* |
||||
* @return signature |
||||
*/ |
||||
SECPSignature signature(); |
||||
|
||||
/** |
||||
* Return the authorizer address. |
||||
* |
||||
* @return authorizer address of the EOA which will load the code into its account |
||||
*/ |
||||
Optional<Address> authorizer(); |
||||
|
||||
/** |
||||
* Return a valid nonce or empty otherwise. A nonce is valid if the size of the list is exactly 1 |
||||
* |
||||
* @return all the optional nonce |
||||
*/ |
||||
Optional<Long> nonce(); |
||||
|
||||
/** |
||||
* Return the recovery id. |
||||
* |
||||
* @return byte |
||||
*/ |
||||
byte v(); |
||||
|
||||
/** |
||||
* Return the r value of the signature. |
||||
* |
||||
* @return r value |
||||
*/ |
||||
BigInteger r(); |
||||
|
||||
/** |
||||
* Return the s value of the signature. |
||||
* |
||||
* @return s value |
||||
*/ |
||||
BigInteger s(); |
||||
} |
@ -0,0 +1,260 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.ethereum.core; |
||||
|
||||
import org.hyperledger.besu.crypto.KeyPair; |
||||
import org.hyperledger.besu.crypto.SECPSignature; |
||||
import org.hyperledger.besu.crypto.SignatureAlgorithm; |
||||
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; |
||||
import org.hyperledger.besu.datatypes.Address; |
||||
import org.hyperledger.besu.datatypes.Hash; |
||||
import org.hyperledger.besu.ethereum.core.encoding.SetCodeTransactionEncoder; |
||||
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; |
||||
|
||||
import java.math.BigInteger; |
||||
import java.util.List; |
||||
import java.util.Optional; |
||||
import java.util.function.Supplier; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator; |
||||
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
import com.google.common.base.Suppliers; |
||||
import org.apache.tuweni.bytes.Bytes; |
||||
|
||||
public class SetCodeAuthorization implements org.hyperledger.besu.datatypes.SetCodeAuthorization { |
||||
private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM = |
||||
Suppliers.memoize(SignatureAlgorithmFactory::getInstance); |
||||
|
||||
public static final Bytes MAGIC = Bytes.fromHexString("05"); |
||||
|
||||
private final BigInteger chainId; |
||||
private final Address address; |
||||
private final Optional<Long> nonce; |
||||
private final SECPSignature signature; |
||||
private Optional<Address> authorizer = Optional.empty(); |
||||
private boolean isAuthorityComputed = false; |
||||
|
||||
/** |
||||
* An access list entry as defined in EIP-7702 |
||||
* |
||||
* @param chainId can be either the current chain id or zero |
||||
* @param address the address from which the code will be set into the EOA account |
||||
* @param nonce an optional nonce after which this auth expires |
||||
* @param signature the signature of the EOA account which will be used to set the code |
||||
*/ |
||||
public SetCodeAuthorization( |
||||
final BigInteger chainId, |
||||
final Address address, |
||||
final Optional<Long> nonce, |
||||
final SECPSignature signature) { |
||||
this.chainId = chainId; |
||||
this.address = address; |
||||
this.nonce = nonce; |
||||
this.signature = signature; |
||||
} |
||||
|
||||
/** |
||||
* Create access list entry. |
||||
* |
||||
* @param chainId can be either the current chain id or zero |
||||
* @param address the address from which the code will be set into the EOA account |
||||
* @param nonces the list of nonces |
||||
* @param v the recovery id |
||||
* @param r the r value of the signature |
||||
* @param s the s value of the signature |
||||
* @return SetCodeTransactionEntry |
||||
*/ |
||||
@JsonCreator |
||||
public static org.hyperledger.besu.datatypes.SetCodeAuthorization createSetCodeAuthorizationEntry( |
||||
@JsonProperty("chainId") final BigInteger chainId, |
||||
@JsonProperty("address") final Address address, |
||||
@JsonProperty("nonce") final List<Long> nonces, |
||||
@JsonProperty("v") final byte v, |
||||
@JsonProperty("r") final BigInteger r, |
||||
@JsonProperty("s") final BigInteger s) { |
||||
return new SetCodeAuthorization( |
||||
chainId, |
||||
address, |
||||
Optional.ofNullable(nonces.get(0)), |
||||
SIGNATURE_ALGORITHM.get().createSignature(r, s, v)); |
||||
} |
||||
|
||||
@JsonProperty("chainId") |
||||
@Override |
||||
public BigInteger chainId() { |
||||
return chainId; |
||||
} |
||||
|
||||
@JsonProperty("address") |
||||
@Override |
||||
public Address address() { |
||||
return address; |
||||
} |
||||
|
||||
@JsonProperty("signature") |
||||
@Override |
||||
public SECPSignature signature() { |
||||
return signature; |
||||
} |
||||
|
||||
@Override |
||||
public Optional<Address> authorizer() { |
||||
if (!isAuthorityComputed) { |
||||
authorizer = computeAuthority(); |
||||
isAuthorityComputed = true; |
||||
} |
||||
|
||||
return authorizer; |
||||
} |
||||
|
||||
@Override |
||||
public Optional<Long> nonce() { |
||||
return nonce; |
||||
} |
||||
|
||||
@JsonProperty("v") |
||||
@Override |
||||
public byte v() { |
||||
return signature.getRecId(); |
||||
} |
||||
|
||||
@JsonProperty("r") |
||||
@Override |
||||
public BigInteger r() { |
||||
return signature.getR(); |
||||
} |
||||
|
||||
@JsonProperty("s") |
||||
@Override |
||||
public BigInteger s() { |
||||
return signature.getS(); |
||||
} |
||||
|
||||
private Optional<Address> computeAuthority() { |
||||
BytesValueRLPOutput rlpOutput = new BytesValueRLPOutput(); |
||||
SetCodeTransactionEncoder.encodeSingleSetCodeWithoutSignature(this, rlpOutput); |
||||
|
||||
final Hash hash = Hash.hash(Bytes.concatenate(MAGIC, rlpOutput.encoded())); |
||||
|
||||
return SIGNATURE_ALGORITHM |
||||
.get() |
||||
.recoverPublicKeyFromSignature(hash, signature) |
||||
.map(Address::extract); |
||||
} |
||||
|
||||
/** |
||||
* Create set code authorization with a builder. |
||||
* |
||||
* @return SetCodeAuthorization.Builder |
||||
*/ |
||||
public static Builder builder() { |
||||
return new Builder(); |
||||
} |
||||
|
||||
/** Builder for SetCodeAuthorization. */ |
||||
public static class Builder { |
||||
private BigInteger chainId = BigInteger.ZERO; |
||||
private Address address; |
||||
private Optional<Long> nonce = Optional.empty(); |
||||
private SECPSignature signature; |
||||
|
||||
/** Create a new builder. */ |
||||
protected Builder() {} |
||||
|
||||
/** |
||||
* Set the optional chain id. |
||||
* |
||||
* @param chainId the chain id |
||||
* @return this builder |
||||
*/ |
||||
public Builder chainId(final BigInteger chainId) { |
||||
this.chainId = chainId; |
||||
return this; |
||||
} |
||||
|
||||
/** |
||||
* Set the address of the authorized smart contract. |
||||
* |
||||
* @param address the address |
||||
* @return this builder |
||||
*/ |
||||
public Builder address(final Address address) { |
||||
this.address = address; |
||||
return this; |
||||
} |
||||
|
||||
/** |
||||
* Set the optional nonce. |
||||
* |
||||
* @param nonce the optional nonce. |
||||
* @return this builder |
||||
*/ |
||||
public Builder nonces(final Optional<Long> nonce) { |
||||
this.nonce = nonce; |
||||
return this; |
||||
} |
||||
|
||||
/** |
||||
* Set the signature of the authorizer account. |
||||
* |
||||
* @param signature the signature |
||||
* @return this builder |
||||
*/ |
||||
public Builder signature(final SECPSignature signature) { |
||||
this.signature = signature; |
||||
return this; |
||||
} |
||||
|
||||
/** |
||||
* Sign the authorization with the given key pair and return the authorization. |
||||
* |
||||
* @param keyPair the key pair |
||||
* @return SetCodeAuthorization |
||||
*/ |
||||
public org.hyperledger.besu.datatypes.SetCodeAuthorization signAndBuild(final KeyPair keyPair) { |
||||
final BytesValueRLPOutput output = new BytesValueRLPOutput(); |
||||
output.startList(); |
||||
output.writeBigIntegerScalar(chainId); |
||||
output.writeBytes(address); |
||||
output.startList(); |
||||
nonce.ifPresent(output::writeLongScalar); |
||||
output.endList(); |
||||
output.endList(); |
||||
|
||||
signature( |
||||
SIGNATURE_ALGORITHM |
||||
.get() |
||||
.sign(Hash.hash(Bytes.concatenate(MAGIC, output.encoded())), keyPair)); |
||||
return build(); |
||||
} |
||||
|
||||
/** |
||||
* Build the authorization. |
||||
* |
||||
* @return SetCodeAuthorization |
||||
*/ |
||||
public org.hyperledger.besu.datatypes.SetCodeAuthorization build() { |
||||
if (address == null) { |
||||
throw new IllegalStateException("Address must be set"); |
||||
} |
||||
|
||||
if (signature == null) { |
||||
throw new IllegalStateException("Signature must be set"); |
||||
} |
||||
|
||||
return new SetCodeAuthorization(chainId, address, nonce, signature); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,116 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.ethereum.core.encoding; |
||||
|
||||
import org.hyperledger.besu.crypto.SECPSignature; |
||||
import org.hyperledger.besu.crypto.SignatureAlgorithm; |
||||
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; |
||||
import org.hyperledger.besu.datatypes.AccessListEntry; |
||||
import org.hyperledger.besu.datatypes.Address; |
||||
import org.hyperledger.besu.datatypes.TransactionType; |
||||
import org.hyperledger.besu.datatypes.Wei; |
||||
import org.hyperledger.besu.ethereum.core.SetCodeAuthorization; |
||||
import org.hyperledger.besu.ethereum.core.Transaction; |
||||
import org.hyperledger.besu.ethereum.rlp.RLPInput; |
||||
|
||||
import java.math.BigInteger; |
||||
import java.util.Optional; |
||||
import java.util.function.Supplier; |
||||
|
||||
import com.google.common.base.Suppliers; |
||||
|
||||
public class SetCodeTransactionDecoder { |
||||
private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM = |
||||
Suppliers.memoize(SignatureAlgorithmFactory::getInstance); |
||||
|
||||
private SetCodeTransactionDecoder() { |
||||
// private constructor
|
||||
} |
||||
|
||||
public static Transaction decode(final RLPInput input) { |
||||
input.enterList(); |
||||
final BigInteger chainId = input.readBigIntegerScalar(); |
||||
final Transaction.Builder builder = |
||||
Transaction.builder() |
||||
.type(TransactionType.SET_CODE) |
||||
.chainId(chainId) |
||||
.nonce(input.readLongScalar()) |
||||
.maxPriorityFeePerGas(Wei.of(input.readUInt256Scalar())) |
||||
.maxFeePerGas(Wei.of(input.readUInt256Scalar())) |
||||
.gasLimit(input.readLongScalar()) |
||||
.to(input.readBytes(v -> v.isEmpty() ? null : Address.wrap(v))) |
||||
.value(Wei.of(input.readUInt256Scalar())) |
||||
.payload(input.readBytes()) |
||||
.accessList( |
||||
input.readList( |
||||
accessListEntryRLPInput -> { |
||||
accessListEntryRLPInput.enterList(); |
||||
final AccessListEntry accessListEntry = |
||||
new AccessListEntry( |
||||
Address.wrap(accessListEntryRLPInput.readBytes()), |
||||
accessListEntryRLPInput.readList(RLPInput::readBytes32)); |
||||
accessListEntryRLPInput.leaveList(); |
||||
return accessListEntry; |
||||
})) |
||||
.setCodeTransactionPayloads( |
||||
input.readList( |
||||
setCodeTransactionPayloadsRLPInput -> |
||||
decodeInnerPayload(setCodeTransactionPayloadsRLPInput))); |
||||
|
||||
final byte recId = (byte) input.readUnsignedByteScalar(); |
||||
final BigInteger r = input.readUInt256Scalar().toUnsignedBigInteger(); |
||||
final BigInteger s = input.readUInt256Scalar().toUnsignedBigInteger(); |
||||
|
||||
input.leaveList(); |
||||
|
||||
final Transaction transaction = |
||||
builder.signature(SIGNATURE_ALGORITHM.get().createSignature(r, s, recId)).build(); |
||||
|
||||
return transaction; |
||||
} |
||||
|
||||
public static org.hyperledger.besu.datatypes.SetCodeAuthorization decodeInnerPayload( |
||||
final RLPInput input) { |
||||
input.enterList(); |
||||
final BigInteger chainId = input.readBigIntegerScalar(); |
||||
final Address address = Address.wrap(input.readBytes()); |
||||
|
||||
Optional<Long> nonce = Optional.empty(); |
||||
|
||||
if (!input.nextIsList()) { |
||||
throw new IllegalArgumentException("Optional nonce must be an list, but isn't"); |
||||
} |
||||
|
||||
final long noncesSize = input.nextSize(); |
||||
|
||||
input.enterList(); |
||||
if (noncesSize == 1) { |
||||
nonce = Optional.ofNullable(input.readLongScalar()); |
||||
} else if (noncesSize > 1) { |
||||
throw new IllegalArgumentException("Nonce list may only have 1 member, if any"); |
||||
} |
||||
input.leaveList(); |
||||
|
||||
final byte yParity = (byte) input.readUnsignedByteScalar(); |
||||
final BigInteger r = input.readUInt256Scalar().toUnsignedBigInteger(); |
||||
final BigInteger s = input.readUInt256Scalar().toUnsignedBigInteger(); |
||||
|
||||
input.leaveList(); |
||||
|
||||
final SECPSignature signature = SIGNATURE_ALGORITHM.get().createSignature(r, s, yParity); |
||||
|
||||
return new SetCodeAuthorization(chainId, address, nonce, signature); |
||||
} |
||||
} |
@ -0,0 +1,89 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.ethereum.core.encoding; |
||||
|
||||
import static org.hyperledger.besu.ethereum.core.encoding.AccessListTransactionEncoder.writeAccessList; |
||||
import static org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder.writeSignatureAndRecoveryId; |
||||
|
||||
import org.hyperledger.besu.datatypes.SetCodeAuthorization; |
||||
import org.hyperledger.besu.ethereum.core.Transaction; |
||||
import org.hyperledger.besu.ethereum.rlp.RLPOutput; |
||||
|
||||
import java.util.List; |
||||
|
||||
import org.apache.tuweni.bytes.Bytes; |
||||
|
||||
public class SetCodeTransactionEncoder { |
||||
|
||||
private SetCodeTransactionEncoder() { |
||||
// private constructor
|
||||
} |
||||
|
||||
public static void encodeSetCodeInner( |
||||
final List<SetCodeAuthorization> payloads, final RLPOutput rlpOutput) { |
||||
rlpOutput.startList(); |
||||
payloads.forEach(payload -> encodeSingleSetCode(payload, rlpOutput)); |
||||
rlpOutput.endList(); |
||||
} |
||||
|
||||
public static void encodeSingleSetCodeWithoutSignature( |
||||
final SetCodeAuthorization payload, final RLPOutput rlpOutput) { |
||||
rlpOutput.startList(); |
||||
encodeAuthorizationDetails(payload, rlpOutput); |
||||
rlpOutput.endList(); |
||||
} |
||||
|
||||
public static void encodeSingleSetCode( |
||||
final SetCodeAuthorization payload, final RLPOutput rlpOutput) { |
||||
rlpOutput.startList(); |
||||
encodeAuthorizationDetails(payload, rlpOutput); |
||||
rlpOutput.writeIntScalar(payload.signature().getRecId()); |
||||
rlpOutput.writeBigIntegerScalar(payload.signature().getR()); |
||||
rlpOutput.writeBigIntegerScalar(payload.signature().getS()); |
||||
rlpOutput.endList(); |
||||
} |
||||
|
||||
private static void encodeAuthorizationDetails( |
||||
final SetCodeAuthorization payload, final RLPOutput rlpOutput) { |
||||
rlpOutput.writeBigIntegerScalar(payload.chainId()); |
||||
rlpOutput.writeBytes(payload.address().copy()); |
||||
rlpOutput.startList(); |
||||
payload.nonce().ifPresent(rlpOutput::writeLongScalar); |
||||
rlpOutput.endList(); |
||||
} |
||||
|
||||
public static void encode(final Transaction transaction, final RLPOutput out) { |
||||
out.startList(); |
||||
out.writeBigIntegerScalar(transaction.getChainId().orElseThrow()); |
||||
out.writeLongScalar(transaction.getNonce()); |
||||
out.writeUInt256Scalar(transaction.getMaxPriorityFeePerGas().orElseThrow()); |
||||
out.writeUInt256Scalar(transaction.getMaxFeePerGas().orElseThrow()); |
||||
out.writeLongScalar(transaction.getGasLimit()); |
||||
out.writeBytes(transaction.getTo().map(Bytes::copy).orElse(Bytes.EMPTY)); |
||||
out.writeUInt256Scalar(transaction.getValue()); |
||||
out.writeBytes(transaction.getPayload()); |
||||
writeAccessList(out, transaction.getAccessList()); |
||||
encodeSetCodeInner( |
||||
transaction |
||||
.getAuthorizationList() |
||||
.orElseThrow( |
||||
() -> |
||||
new IllegalStateException( |
||||
"Developer error: the transaction should be guaranteed to have a set code payload here")), |
||||
out); |
||||
writeSignatureAndRecoveryId(transaction, out); |
||||
out.endList(); |
||||
} |
||||
} |
@ -0,0 +1,88 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.ethereum.mainnet; |
||||
|
||||
import org.hyperledger.besu.ethereum.core.Transaction; |
||||
import org.hyperledger.besu.evm.account.Account; |
||||
import org.hyperledger.besu.evm.account.AccountState; |
||||
import org.hyperledger.besu.evm.account.MutableAccount; |
||||
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService; |
||||
import org.hyperledger.besu.evm.worldstate.WorldUpdater; |
||||
|
||||
import java.math.BigInteger; |
||||
import java.util.Optional; |
||||
|
||||
import org.apache.tuweni.bytes.Bytes; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
public class AuthorityProcessor { |
||||
private static final Logger LOG = LoggerFactory.getLogger(AuthorityProcessor.class); |
||||
|
||||
private final Optional<BigInteger> maybeChainId; |
||||
|
||||
public AuthorityProcessor(final Optional<BigInteger> maybeChainId) { |
||||
this.maybeChainId = maybeChainId; |
||||
} |
||||
|
||||
public void addContractToAuthority( |
||||
final WorldUpdater worldUpdater, |
||||
final AuthorizedCodeService authorizedCodeService, |
||||
final Transaction transaction) { |
||||
|
||||
transaction |
||||
.getAuthorizationList() |
||||
.get() |
||||
.forEach( |
||||
payload -> |
||||
payload |
||||
.authorizer() |
||||
.ifPresent( |
||||
authorityAddress -> { |
||||
LOG.trace("Set code authority: {}", authorityAddress); |
||||
|
||||
if (maybeChainId.isPresent() |
||||
&& !payload.chainId().equals(BigInteger.ZERO) |
||||
&& !maybeChainId.get().equals(payload.chainId())) { |
||||
return; |
||||
} |
||||
|
||||
final Optional<MutableAccount> maybeAccount = |
||||
Optional.ofNullable(worldUpdater.getAccount(authorityAddress)); |
||||
final long accountNonce = |
||||
maybeAccount.map(AccountState::getNonce).orElse(0L); |
||||
|
||||
if (payload.nonce().isPresent() |
||||
&& !payload.nonce().get().equals(accountNonce)) { |
||||
return; |
||||
} |
||||
|
||||
if (authorizedCodeService.hasAuthorizedCode(authorityAddress)) { |
||||
return; |
||||
} |
||||
|
||||
Optional<Account> codeAccount = |
||||
Optional.ofNullable(worldUpdater.get(payload.address())); |
||||
final Bytes code; |
||||
if (codeAccount.isPresent()) { |
||||
code = codeAccount.get().getCode(); |
||||
} else { |
||||
code = Bytes.EMPTY; |
||||
} |
||||
|
||||
authorizedCodeService.addAuthorizedCode(authorityAddress, code); |
||||
})); |
||||
} |
||||
} |
@ -0,0 +1,120 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.ethereum.core.encoding; |
||||
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; |
||||
import static org.junit.jupiter.api.Assertions.assertThrows; |
||||
|
||||
import org.hyperledger.besu.crypto.SECPSignature; |
||||
import org.hyperledger.besu.datatypes.Address; |
||||
import org.hyperledger.besu.datatypes.SetCodeAuthorization; |
||||
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; |
||||
|
||||
import java.math.BigInteger; |
||||
|
||||
import org.apache.tuweni.bytes.Bytes; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
class SetCodeTransactionDecoderTest { |
||||
|
||||
@Test |
||||
void shouldDecodeInnerPayloadWithNonce() { |
||||
// "0xd80194633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c105"
|
||||
|
||||
final BytesValueRLPInput input = |
||||
new BytesValueRLPInput( |
||||
Bytes.fromHexString( |
||||
"0xf85b0194633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c18080a0840798fa67118e034c1eb7e42fe89e28d7cd5006dc813d5729e5f75b0d1a7ec5a03b1dbace38ceb862a65bf2eac0637693b5c3493bcb2a022dd614c0a74cce0b99"), |
||||
true); |
||||
final SetCodeAuthorization authorization = SetCodeTransactionDecoder.decodeInnerPayload(input); |
||||
|
||||
assertThat(authorization.chainId()).isEqualTo(BigInteger.ONE); |
||||
assertThat(authorization.address()) |
||||
.isEqualTo(Address.fromHexStringStrict("0x633688abc3cCf8B0C03088D2d1C6ae4958c2fA56")); |
||||
assertThat(authorization.nonce().get()).isEqualTo(0L); |
||||
|
||||
final SECPSignature signature = authorization.signature(); |
||||
assertThat(signature.getRecId()).isEqualTo((byte) 0); |
||||
assertThat(signature.getR().toString(16)) |
||||
.isEqualTo("840798fa67118e034c1eb7e42fe89e28d7cd5006dc813d5729e5f75b0d1a7ec5"); |
||||
assertThat(signature.getS().toString(16)) |
||||
.isEqualTo("3b1dbace38ceb862a65bf2eac0637693b5c3493bcb2a022dd614c0a74cce0b99"); |
||||
} |
||||
|
||||
@Test |
||||
void shouldDecodeInnerPayloadWithoutNonce() { |
||||
// "0xd70194633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c5"
|
||||
|
||||
final BytesValueRLPInput input = |
||||
new BytesValueRLPInput( |
||||
Bytes.fromHexString( |
||||
"0xf85a0194633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c001a0dd6b24048be1b7d7fe5bbbb73ffc37eb2ce1997ecb4ae5b6096532ef19363148a025b58a1ff8ad00bddbbfa1d5c2411961cbb6d08dcdc8ae88303db3c6cf983031"), |
||||
true); |
||||
final SetCodeAuthorization authorization = SetCodeTransactionDecoder.decodeInnerPayload(input); |
||||
|
||||
assertThat(authorization.chainId()).isEqualTo(BigInteger.ONE); |
||||
assertThat(authorization.address()) |
||||
.isEqualTo(Address.fromHexStringStrict("0x633688abc3cCf8B0C03088D2d1C6ae4958c2fA56")); |
||||
assertThat(authorization.nonce()).isEmpty(); |
||||
|
||||
final SECPSignature signature = authorization.signature(); |
||||
assertThat(signature.getRecId()).isEqualTo((byte) 1); |
||||
assertThat(signature.getR().toString(16)) |
||||
.isEqualTo("dd6b24048be1b7d7fe5bbbb73ffc37eb2ce1997ecb4ae5b6096532ef19363148"); |
||||
assertThat(signature.getS().toString(16)) |
||||
.isEqualTo("25b58a1ff8ad00bddbbfa1d5c2411961cbb6d08dcdc8ae88303db3c6cf983031"); |
||||
} |
||||
|
||||
@Test |
||||
void shouldThrowInnerPayloadWithMultipleNonces() { |
||||
// "d90194633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c20107"
|
||||
|
||||
final BytesValueRLPInput input = |
||||
new BytesValueRLPInput( |
||||
Bytes.fromHexString( |
||||
"0xf85c0194633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c2010201a0401b5d4ebe88306448115d1a46a30e5ad1136f2818b4ebb0733d9c4efffd135aa0753ff1dbce6db504ecb9635a64d8c4506ff887e2d2a0d2b7175baf94c849eccc"), |
||||
true); |
||||
|
||||
assertThrows( |
||||
IllegalArgumentException.class, |
||||
() -> { |
||||
SetCodeTransactionDecoder.decodeInnerPayload(input); |
||||
}); |
||||
} |
||||
|
||||
@Test |
||||
void shouldDecodeInnerPayloadWithoutNonceAndChainIdZero() { |
||||
// "d70094633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c5"
|
||||
|
||||
final BytesValueRLPInput input = |
||||
new BytesValueRLPInput( |
||||
Bytes.fromHexString( |
||||
"0xf85a0094633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c001a0025c1240d7ffec0daeedb752d3357aff2e3cd58468f0c2d43ee0ee999e02ace2a03c8a25b2becd6e666f69803d1ae3322f2e137b7745c2c7f19da80f993ffde4df"), |
||||
true); |
||||
final SetCodeAuthorization authorization = SetCodeTransactionDecoder.decodeInnerPayload(input); |
||||
|
||||
assertThat(authorization.chainId()).isEqualTo(BigInteger.ZERO); |
||||
assertThat(authorization.address()) |
||||
.isEqualTo(Address.fromHexStringStrict("0x633688abc3cCf8B0C03088D2d1C6ae4958c2fA56")); |
||||
assertThat(authorization.nonce().isEmpty()).isTrue(); |
||||
|
||||
final SECPSignature signature = authorization.signature(); |
||||
assertThat(signature.getRecId()).isEqualTo((byte) 1); |
||||
assertThat(signature.getR().toString(16)) |
||||
.isEqualTo("25c1240d7ffec0daeedb752d3357aff2e3cd58468f0c2d43ee0ee999e02ace2"); |
||||
assertThat(signature.getS().toString(16)) |
||||
.isEqualTo("3c8a25b2becd6e666f69803d1ae3322f2e137b7745c2c7f19da80f993ffde4df"); |
||||
} |
||||
} |
@ -0,0 +1,122 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.ethereum.core.encoding; |
||||
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; |
||||
|
||||
import org.hyperledger.besu.crypto.SignatureAlgorithm; |
||||
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; |
||||
import org.hyperledger.besu.datatypes.Address; |
||||
import org.hyperledger.besu.ethereum.core.SetCodeAuthorization; |
||||
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; |
||||
|
||||
import java.math.BigInteger; |
||||
import java.util.Optional; |
||||
import java.util.function.Supplier; |
||||
|
||||
import com.google.common.base.Suppliers; |
||||
import org.apache.tuweni.bytes.Bytes; |
||||
import org.junit.jupiter.api.BeforeEach; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
class SetCodeTransactionEncoderTest { |
||||
private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM = |
||||
Suppliers.memoize(SignatureAlgorithmFactory::getInstance); |
||||
|
||||
BytesValueRLPOutput output; |
||||
|
||||
@BeforeEach |
||||
void setUp() { |
||||
output = new BytesValueRLPOutput(); |
||||
} |
||||
|
||||
@Test |
||||
void shouldEncodeSingleSetCodeWithNonce() { |
||||
// "0xd80194633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c105"
|
||||
|
||||
final SetCodeAuthorization authorization = |
||||
new SetCodeAuthorization( |
||||
BigInteger.ONE, |
||||
Address.fromHexString("0x633688abc3cCf8B0C03088D2d1C6ae4958c2fA56"), |
||||
Optional.of(0L), |
||||
SIGNATURE_ALGORITHM |
||||
.get() |
||||
.createSignature( |
||||
new BigInteger( |
||||
"840798fa67118e034c1eb7e42fe89e28d7cd5006dc813d5729e5f75b0d1a7ec5", 16), |
||||
new BigInteger( |
||||
"3b1dbace38ceb862a65bf2eac0637693b5c3493bcb2a022dd614c0a74cce0b99", 16), |
||||
(byte) 0)); |
||||
|
||||
SetCodeTransactionEncoder.encodeSingleSetCode(authorization, output); |
||||
|
||||
assertThat(output.encoded()) |
||||
.isEqualTo( |
||||
Bytes.fromHexString( |
||||
"0xf85b0194633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c18080a0840798fa67118e034c1eb7e42fe89e28d7cd5006dc813d5729e5f75b0d1a7ec5a03b1dbace38ceb862a65bf2eac0637693b5c3493bcb2a022dd614c0a74cce0b99")); |
||||
} |
||||
|
||||
@Test |
||||
void shouldEncodeSingleSetCodeWithoutNonce() { |
||||
// "0xd70194633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c5"
|
||||
|
||||
final SetCodeAuthorization authorization = |
||||
new SetCodeAuthorization( |
||||
BigInteger.ONE, |
||||
Address.fromHexString("0x633688abc3cCf8B0C03088D2d1C6ae4958c2fA56"), |
||||
Optional.empty(), |
||||
SIGNATURE_ALGORITHM |
||||
.get() |
||||
.createSignature( |
||||
new BigInteger( |
||||
"dd6b24048be1b7d7fe5bbbb73ffc37eb2ce1997ecb4ae5b6096532ef19363148", 16), |
||||
new BigInteger( |
||||
"25b58a1ff8ad00bddbbfa1d5c2411961cbb6d08dcdc8ae88303db3c6cf983031", 16), |
||||
(byte) 1)); |
||||
|
||||
SetCodeTransactionEncoder.encodeSingleSetCode(authorization, output); |
||||
|
||||
assertThat(output.encoded()) |
||||
.isEqualTo( |
||||
Bytes.fromHexString( |
||||
"0xf85a0194633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c001a0dd6b24048be1b7d7fe5bbbb73ffc37eb2ce1997ecb4ae5b6096532ef19363148a025b58a1ff8ad00bddbbfa1d5c2411961cbb6d08dcdc8ae88303db3c6cf983031")); |
||||
} |
||||
|
||||
@Test |
||||
void shouldEncodeSingleSetCodeWithoutNonceAndChainIdZero() { |
||||
// "d70094633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c5"
|
||||
|
||||
final SetCodeAuthorization authorization = |
||||
new SetCodeAuthorization( |
||||
BigInteger.ZERO, |
||||
Address.fromHexString("0x633688abc3cCf8B0C03088D2d1C6ae4958c2fA56"), |
||||
Optional.empty(), |
||||
SIGNATURE_ALGORITHM |
||||
.get() |
||||
.createSignature( |
||||
new BigInteger( |
||||
"25c1240d7ffec0daeedb752d3357aff2e3cd58468f0c2d43ee0ee999e02ace2", 16), |
||||
new BigInteger( |
||||
"3c8a25b2becd6e666f69803d1ae3322f2e137b7745c2c7f19da80f993ffde4df", 16), |
||||
(byte) 1)); |
||||
|
||||
SetCodeTransactionEncoder.encodeSingleSetCode(authorization, output); |
||||
|
||||
assertThat(output.encoded()) |
||||
.isEqualTo( |
||||
Bytes.fromHexString( |
||||
"0xf85a8094633688abc3ccf8b0c03088d2d1c6ae4958c2fa56c001a0025c1240d7ffec0daeedb752d3357aff2e3cd58468f0c2d43ee0ee999e02ace2a03c8a25b2becd6e666f69803d1ae3322f2e137b7745c2c7f19da80f993ffde4df")); |
||||
} |
||||
} |
@ -0,0 +1,100 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.evm.account; |
||||
|
||||
import org.hyperledger.besu.datatypes.Address; |
||||
import org.hyperledger.besu.datatypes.Hash; |
||||
import org.hyperledger.besu.datatypes.Wei; |
||||
|
||||
import java.util.NavigableMap; |
||||
|
||||
import org.apache.tuweni.bytes.Bytes; |
||||
import org.apache.tuweni.bytes.Bytes32; |
||||
import org.apache.tuweni.units.bigints.UInt256; |
||||
|
||||
/** Wraps an EOA account and includes authorized code to be run on behalf of it. */ |
||||
public class AuthorizedCodeAccount implements Account { |
||||
private final Account wrappedAccount; |
||||
private final Bytes authorizedCode; |
||||
|
||||
/** The hash of the authorized code. */ |
||||
protected Hash codeHash = null; |
||||
|
||||
/** |
||||
* Creates a new AuthorizedCodeAccount. |
||||
* |
||||
* @param wrappedAccount the account that has authorized code to be loaded into it. |
||||
* @param authorizedCode the authorized code. |
||||
*/ |
||||
public AuthorizedCodeAccount(final Account wrappedAccount, final Bytes authorizedCode) { |
||||
this.wrappedAccount = wrappedAccount; |
||||
this.authorizedCode = authorizedCode; |
||||
} |
||||
|
||||
@Override |
||||
public Address getAddress() { |
||||
return wrappedAccount.getAddress(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isStorageEmpty() { |
||||
return wrappedAccount.isStorageEmpty(); |
||||
} |
||||
|
||||
@Override |
||||
public Hash getAddressHash() { |
||||
return wrappedAccount.getAddressHash(); |
||||
} |
||||
|
||||
@Override |
||||
public long getNonce() { |
||||
return wrappedAccount.getNonce(); |
||||
} |
||||
|
||||
@Override |
||||
public Wei getBalance() { |
||||
return wrappedAccount.getBalance(); |
||||
} |
||||
|
||||
@Override |
||||
public Bytes getCode() { |
||||
return authorizedCode; |
||||
} |
||||
|
||||
@Override |
||||
public Hash getCodeHash() { |
||||
if (codeHash == null) { |
||||
codeHash = authorizedCode.equals(Bytes.EMPTY) ? Hash.EMPTY : Hash.hash(authorizedCode); |
||||
} |
||||
|
||||
return codeHash; |
||||
} |
||||
|
||||
@Override |
||||
public UInt256 getStorageValue(final UInt256 key) { |
||||
return wrappedAccount.getStorageValue(key); |
||||
} |
||||
|
||||
@Override |
||||
public UInt256 getOriginalStorageValue(final UInt256 key) { |
||||
return wrappedAccount.getOriginalStorageValue(key); |
||||
} |
||||
|
||||
@Override |
||||
public NavigableMap<Bytes32, AccountStorageEntry> storageEntriesFrom( |
||||
final Bytes32 startKeyHash, final int limit) { |
||||
return wrappedAccount.storageEntriesFrom(startKeyHash, limit); |
||||
} |
||||
} |
@ -0,0 +1,138 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.evm.account; |
||||
|
||||
import org.hyperledger.besu.datatypes.Address; |
||||
import org.hyperledger.besu.datatypes.Hash; |
||||
import org.hyperledger.besu.datatypes.Wei; |
||||
|
||||
import java.util.Map; |
||||
import java.util.NavigableMap; |
||||
|
||||
import org.apache.tuweni.bytes.Bytes; |
||||
import org.apache.tuweni.bytes.Bytes32; |
||||
import org.apache.tuweni.units.bigints.UInt256; |
||||
|
||||
/** Wraps a mutable EOA account and includes authorized code to be run on behalf of it. */ |
||||
public class MutableAuthorizedCodeAccount implements MutableAccount { |
||||
|
||||
private final MutableAccount wrappedAccount; |
||||
private final Bytes authorizedCode; |
||||
|
||||
/** The hash of the authorized code. */ |
||||
protected Hash codeHash = null; |
||||
|
||||
/** |
||||
* Creates a new MutableAuthorizedCodeAccount. |
||||
* |
||||
* @param wrappedAccount the account that has authorized code to be loaded into it. |
||||
* @param authorizedCode the authorized code. |
||||
*/ |
||||
public MutableAuthorizedCodeAccount( |
||||
final MutableAccount wrappedAccount, final Bytes authorizedCode) { |
||||
this.wrappedAccount = wrappedAccount; |
||||
this.authorizedCode = authorizedCode; |
||||
} |
||||
|
||||
@Override |
||||
public Address getAddress() { |
||||
return wrappedAccount.getAddress(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isStorageEmpty() { |
||||
return wrappedAccount.isStorageEmpty(); |
||||
} |
||||
|
||||
@Override |
||||
public Hash getAddressHash() { |
||||
return wrappedAccount.getAddressHash(); |
||||
} |
||||
|
||||
@Override |
||||
public long getNonce() { |
||||
return wrappedAccount.getNonce(); |
||||
} |
||||
|
||||
@Override |
||||
public Wei getBalance() { |
||||
return wrappedAccount.getBalance(); |
||||
} |
||||
|
||||
@Override |
||||
public Bytes getCode() { |
||||
return authorizedCode; |
||||
} |
||||
|
||||
@Override |
||||
public Hash getCodeHash() { |
||||
if (codeHash == null) { |
||||
codeHash = authorizedCode.equals(Bytes.EMPTY) ? Hash.EMPTY : Hash.hash(authorizedCode); |
||||
} |
||||
|
||||
return codeHash; |
||||
} |
||||
|
||||
@Override |
||||
public UInt256 getStorageValue(final UInt256 key) { |
||||
return wrappedAccount.getStorageValue(key); |
||||
} |
||||
|
||||
@Override |
||||
public UInt256 getOriginalStorageValue(final UInt256 key) { |
||||
return wrappedAccount.getOriginalStorageValue(key); |
||||
} |
||||
|
||||
@Override |
||||
public NavigableMap<Bytes32, AccountStorageEntry> storageEntriesFrom( |
||||
final Bytes32 startKeyHash, final int limit) { |
||||
return wrappedAccount.storageEntriesFrom(startKeyHash, limit); |
||||
} |
||||
|
||||
@Override |
||||
public void setNonce(final long value) { |
||||
wrappedAccount.setNonce(value); |
||||
} |
||||
|
||||
@Override |
||||
public void setBalance(final Wei value) { |
||||
wrappedAccount.setBalance(value); |
||||
} |
||||
|
||||
@Override |
||||
public void setCode(final Bytes code) { |
||||
throw new RuntimeException("Cannot set code on an AuthorizedCodeAccount"); |
||||
} |
||||
|
||||
@Override |
||||
public void setStorageValue(final UInt256 key, final UInt256 value) { |
||||
wrappedAccount.setStorageValue(key, value); |
||||
} |
||||
|
||||
@Override |
||||
public void clearStorage() { |
||||
wrappedAccount.clearStorage(); |
||||
} |
||||
|
||||
@Override |
||||
public Map<UInt256, UInt256> getUpdatedStorage() { |
||||
return wrappedAccount.getUpdatedStorage(); |
||||
} |
||||
|
||||
@Override |
||||
public void becomeImmutable() { |
||||
wrappedAccount.becomeImmutable(); |
||||
} |
||||
} |
@ -0,0 +1,116 @@ |
||||
/* |
||||
* Copyright contributors to Hyperledger Besu. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
package org.hyperledger.besu.evm.worldstate; |
||||
|
||||
import org.hyperledger.besu.datatypes.Address; |
||||
import org.hyperledger.besu.evm.account.Account; |
||||
import org.hyperledger.besu.evm.account.AuthorizedCodeAccount; |
||||
import org.hyperledger.besu.evm.account.MutableAccount; |
||||
import org.hyperledger.besu.evm.account.MutableAuthorizedCodeAccount; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
|
||||
import org.apache.tuweni.bytes.Bytes; |
||||
|
||||
/** A service that manages the code injection of authorized code. */ |
||||
public class AuthorizedCodeService { |
||||
private final Map<Address, Bytes> authorizedCode = new HashMap<>(); |
||||
|
||||
/** Creates a new AuthorizedCodeService. */ |
||||
public AuthorizedCodeService() {} |
||||
|
||||
/** |
||||
* Authorizes to load the code of authorizedCode into the authorizer account. |
||||
* |
||||
* @param authorizer the address that gives the authorization. |
||||
* @param authorizedCode the code which will be loaded. |
||||
*/ |
||||
public void addAuthorizedCode(final Address authorizer, final Bytes authorizedCode) { |
||||
this.authorizedCode.put(authorizer, authorizedCode); |
||||
} |
||||
|
||||
/** |
||||
* Return all the authorities that have given their authorization to load the code of another |
||||
* account. |
||||
* |
||||
* @return the set of authorities. |
||||
*/ |
||||
public Set<Address> getAuthorities() { |
||||
return authorizedCode.keySet(); |
||||
} |
||||
|
||||
/** Resets all the authorized accounts. */ |
||||
public void resetAuthorities() { |
||||
authorizedCode.clear(); |
||||
} |
||||
|
||||
/** |
||||
* Checks if the provided address has set an authorized to load code into an EOA account. |
||||
* |
||||
* @param authority the address to check. |
||||
* @return {@code true} if the address has been authorized, {@code false} otherwise. |
||||
*/ |
||||
public boolean hasAuthorizedCode(final Address authority) { |
||||
return authorizedCode.containsKey(authority); |
||||
} |
||||
|
||||
/** |
||||
* Processes the provided account, injecting the authorized code if authorized. |
||||
* |
||||
* @param worldUpdater the world updater to retrieve the code account. |
||||
* @param originalAccount the account to process. |
||||
* @param address the address of the account in case the provided account is null |
||||
* @return the processed account, containing the authorized code if authorized. |
||||
*/ |
||||
public Account processAccount( |
||||
final WorldUpdater worldUpdater, final Account originalAccount, final Address address) { |
||||
if (!authorizedCode.containsKey(address)) { |
||||
return originalAccount; |
||||
} |
||||
|
||||
Account account = originalAccount; |
||||
if (account == null) { |
||||
account = worldUpdater.createAccount(address); |
||||
} |
||||
|
||||
return new AuthorizedCodeAccount(account, authorizedCode.get(address)); |
||||
} |
||||
|
||||
/** |
||||
* Processes the provided mutable account, injecting the authorized code if authorized. |
||||
* |
||||
* @param worldUpdater the world updater to retrieve the code account. |
||||
* @param originalAccount the mutable account to process. |
||||
* @param address the address of the account in case the provided account is null |
||||
* @return the processed mutable account, containing the authorized code if authorized. |
||||
*/ |
||||
public MutableAccount processMutableAccount( |
||||
final WorldUpdater worldUpdater, |
||||
final MutableAccount originalAccount, |
||||
final Address address) { |
||||
if (!authorizedCode.containsKey(address)) { |
||||
return originalAccount; |
||||
} |
||||
|
||||
MutableAccount account = originalAccount; |
||||
if (account == null) { |
||||
account = worldUpdater.createAccount(address); |
||||
} |
||||
|
||||
return new MutableAuthorizedCodeAccount(account, authorizedCode.get(address)); |
||||
} |
||||
} |
Loading…
Reference in new issue