ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
22.67k stars 5.62k forks source link

Support for sending type 3 transactions in solidity #15071

Open PatrickAlphaC opened 2 months ago

PatrickAlphaC commented 2 months ago

Abstract

If I'm understanding correctly, solidity currently has support for the new BLOBHASH opcode, and can read from this and can call this opcode with blobhash yul.

However, it's not clear to me if I can send a type 3 transaction with blob data from solidity. Something like the following:

// SPDX-License-Identifier: MIT

pragma solidity 0.8.24;

contract Hi {
    function doStuff() public {
        address randomAddress = address(57);
        randomAddress.call{blobData: hex"0x01"}
    }
}

Motivation

Mainly for foundry scripting this would be helpful. I can see a world where it doesn't make sense to support at the solidity level... Thinking about it more, it starting to make less sense to me, but wanted to make an issue anyways to verify this wouldn't be something the solidity language would support.

Specification

EIP specification:

BLOB_TX_TYPE | Bytes1(0x03)
-- | --
BYTES_PER_FIELD_ELEMENT | 32
FIELD_ELEMENTS_PER_BLOB | 4096
BLS_MODULUS | 52435875175126190479447740508185965837690552500527637822603658699938581184513
VERSIONED_HASH_VERSION_KZG | Bytes1(0x01)
POINT_EVALUATION_PRECOMPILE_ADDRESS | Bytes20(0x0A)
POINT_EVALUATION_PRECOMPILE_GAS | 50000
MAX_BLOB_GAS_PER_BLOCK | 786432
TARGET_BLOB_GAS_PER_BLOCK | 393216
MIN_BASE_FEE_PER_BLOB_GAS | 1
BLOB_BASE_FEE_UPDATE_FRACTION | 3338477
GAS_PER_BLOB | 2**17
HASH_OPCODE_BYTE | Bytes1(0x49)
HASH_OPCODE_GAS | 3
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS | 4096

BLOB_TX_TYPE    Bytes1(0x03)
BYTES_PER_FIELD_ELEMENT 32
FIELD_ELEMENTS_PER_BLOB 4096
BLS_MODULUS 52435875175126190479447740508185965837690552500527637822603658699938581184513
VERSIONED_HASH_VERSION_KZG  Bytes1(0x01)
POINT_EVALUATION_PRECOMPILE_ADDRESS Bytes20(0x0A)
POINT_EVALUATION_PRECOMPILE_GAS 50000
MAX_BLOB_GAS_PER_BLOCK  786432
TARGET_BLOB_GAS_PER_BLOCK   393216
MIN_BASE_FEE_PER_BLOB_GAS   1
BLOB_BASE_FEE_UPDATE_FRACTION   3338477
GAS_PER_BLOB    2**17
HASH_OPCODE_BYTE    Bytes1(0x49)
HASH_OPCODE_GAS 3
[MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS](https://github.com/ethereum/consensus-specs/blob/4de1d156c78b555421b72d6067c73b614ab55584/configs/mainnet.yaml#L148)    4096

Perhaps adding some functionality like the following would work.

randomAddress.call{tx_type: hex"0x03" /*(other variables here) */ }

I can see why this would be a bit silly, because the purpose of blobs is to not have the data on-chain, but putting it into the contract would redundantly place the data on-chain.

I can see a world where this isn't supported in solidity but only used as a cheatcode in foundry.

Backwards Compatibility

Since this is additive I don't think it would have an effect on anything prior.