diff --git a/chain/protocol_param.go b/chain/protocol_param.go deleted file mode 100644 index ae085def3..000000000 --- a/chain/protocol_param.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright 2023 The Erigon contributors - - 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. -*/ - -package chain - -const ( - // EIP-4844: Shard Blob Transactions - FieldElementsPerBlob = 4096 // each field element is 32 bytes - BlobSize = FieldElementsPerBlob * 32 - DataGasPerBlob uint64 = 0x20000 - TargetDataGasPerBlock uint64 = 0x60000 - MaxDataGasPerBlock uint64 = 0xC0000 - MaxBlobsPerBlock uint64 = MaxDataGasPerBlock / DataGasPerBlob -) diff --git a/common/fixedgas/protocol.go b/common/fixedgas/protocol.go index 603094add..3bf86d64f 100644 --- a/common/fixedgas/protocol.go +++ b/common/fixedgas/protocol.go @@ -1,5 +1,5 @@ /* - Copyright 2021 Erigon contributors + Copyright 2021 The Erigon contributors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -158,4 +158,12 @@ const ( // EIP-3860 to limit size of initcode MaxInitCodeSize = 2 * MaxCodeSize // Maximum initcode to permit in a creation transaction and create instructions InitCodeWordGas = 2 + + // EIP-4844: Shard Blob Transactions + FieldElementsPerBlob = 4096 // each field element is 32 bytes + BlobSize = FieldElementsPerBlob * 32 + BlobGasPerBlob uint64 = 0x20000 + TargetBlobGasPerBlock uint64 = 0x60000 + MaxBlobGasPerBlock uint64 = 0xC0000 + MaxBlobsPerBlock uint64 = MaxBlobGasPerBlock / BlobGasPerBlob ) diff --git a/go.mod b/go.mod index 9dc79801a..f10e748c7 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon-lib go 1.19 require ( - github.com/ledgerwatch/interfaces v0.0.0-20230726195055-b5334a3d9932 + github.com/ledgerwatch/interfaces v0.0.0-20230728094508-bfae3efc9be4 github.com/ledgerwatch/log/v3 v3.8.0 github.com/ledgerwatch/secp256k1 v1.0.0 github.com/ledgerwatch/trackerslist v1.1.0 diff --git a/go.sum b/go.sum index ea5afab8f..f5fc1dd7c 100644 --- a/go.sum +++ b/go.sum @@ -233,8 +233,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= -github.com/ledgerwatch/interfaces v0.0.0-20230726195055-b5334a3d9932 h1:GERJonV4ypxj/96/tJjEta3f2um9c6t1PGCJOM/jnlw= -github.com/ledgerwatch/interfaces v0.0.0-20230726195055-b5334a3d9932/go.mod h1:ugQv1QllJzBny3cKZKxUrSnykkjkBgm27eQM6dnGAcc= +github.com/ledgerwatch/interfaces v0.0.0-20230728094508-bfae3efc9be4 h1:JqDVUu2USxg2evWyVmDduPBQFPUVp2QvGSnp0DZUOFk= +github.com/ledgerwatch/interfaces v0.0.0-20230728094508-bfae3efc9be4/go.mod h1:ugQv1QllJzBny3cKZKxUrSnykkjkBgm27eQM6dnGAcc= github.com/ledgerwatch/log/v3 v3.8.0 h1:gCpp7uGtIerEz1jKVPeDnbIopFPud9ZnCpBLlLBGqPU= github.com/ledgerwatch/log/v3 v3.8.0/go.mod h1:J2Jl6zV/58LeA6LTaVVnCGyf1/cYYSEOOLHY4ZN8S2A= github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ= diff --git a/gointerfaces/downloader/downloader.pb.go b/gointerfaces/downloader/downloader.pb.go index 1691e0041..beddbbca4 100644 --- a/gointerfaces/downloader/downloader.pb.go +++ b/gointerfaces/downloader/downloader.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.22.3 +// protoc-gen-go v1.31.0 +// protoc v4.23.3 // source: downloader/downloader.proto package downloader diff --git a/gointerfaces/downloader/downloader_grpc.pb.go b/gointerfaces/downloader/downloader_grpc.pb.go index 8079b0245..8a6a60a7d 100644 --- a/gointerfaces/downloader/downloader_grpc.pb.go +++ b/gointerfaces/downloader/downloader_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.22.3 +// - protoc v4.23.3 // source: downloader/downloader.proto package downloader diff --git a/gointerfaces/execution/execution.pb.go b/gointerfaces/execution/execution.pb.go index e4bd7d16a..e42d23e5d 100644 --- a/gointerfaces/execution/execution.pb.go +++ b/gointerfaces/execution/execution.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.22.3 +// protoc-gen-go v1.31.0 +// protoc v4.23.3 // source: execution/execution.proto package execution @@ -267,8 +267,8 @@ type Header struct { TransactionHash *types.H256 `protobuf:"bytes,16,opt,name=transaction_hash,json=transactionHash,proto3" json:"transaction_hash,omitempty"` BaseFeePerGas *types.H256 `protobuf:"bytes,17,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3,oneof" json:"base_fee_per_gas,omitempty"` WithdrawalHash *types.H256 `protobuf:"bytes,18,opt,name=withdrawal_hash,json=withdrawalHash,proto3,oneof" json:"withdrawal_hash,omitempty"` - DataGasUsed *uint64 `protobuf:"varint,19,opt,name=data_gas_used,json=dataGasUsed,proto3,oneof" json:"data_gas_used,omitempty"` - ExcessDataGas *uint64 `protobuf:"varint,20,opt,name=excess_data_gas,json=excessDataGas,proto3,oneof" json:"excess_data_gas,omitempty"` + BlobGasUsed *uint64 `protobuf:"varint,19,opt,name=blob_gas_used,json=blobGasUsed,proto3,oneof" json:"blob_gas_used,omitempty"` + ExcessBlobGas *uint64 `protobuf:"varint,20,opt,name=excess_blob_gas,json=excessBlobGas,proto3,oneof" json:"excess_blob_gas,omitempty"` } func (x *Header) Reset() { @@ -429,16 +429,16 @@ func (x *Header) GetWithdrawalHash() *types.H256 { return nil } -func (x *Header) GetDataGasUsed() uint64 { - if x != nil && x.DataGasUsed != nil { - return *x.DataGasUsed +func (x *Header) GetBlobGasUsed() uint64 { + if x != nil && x.BlobGasUsed != nil { + return *x.BlobGasUsed } return 0 } -func (x *Header) GetExcessDataGas() uint64 { - if x != nil && x.ExcessDataGas != nil { - return *x.ExcessDataGas +func (x *Header) GetExcessBlobGas() uint64 { + if x != nil && x.ExcessBlobGas != nil { + return *x.ExcessBlobGas } return 0 } @@ -1368,17 +1368,17 @@ var file_execution_execution_proto_rawDesc = []byte{ 0x0f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x48, 0x32, 0x35, 0x36, 0x48, 0x01, 0x52, 0x0e, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, - 0x6c, 0x48, 0x61, 0x73, 0x68, 0x88, 0x01, 0x01, 0x12, 0x27, 0x0a, 0x0d, 0x64, 0x61, 0x74, 0x61, + 0x6c, 0x48, 0x61, 0x73, 0x68, 0x88, 0x01, 0x01, 0x12, 0x27, 0x0a, 0x0d, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x04, 0x48, - 0x02, 0x52, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x47, 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x88, 0x01, - 0x01, 0x12, 0x2b, 0x0a, 0x0f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x64, 0x61, 0x74, 0x61, + 0x02, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x62, 0x47, 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x88, 0x01, + 0x01, 0x12, 0x2b, 0x0a, 0x0f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, 0x61, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x04, 0x48, 0x03, 0x52, 0x0d, 0x65, 0x78, - 0x63, 0x65, 0x73, 0x73, 0x44, 0x61, 0x74, 0x61, 0x47, 0x61, 0x73, 0x88, 0x01, 0x01, 0x42, 0x13, + 0x63, 0x65, 0x73, 0x73, 0x42, 0x6c, 0x6f, 0x62, 0x47, 0x61, 0x73, 0x88, 0x01, 0x01, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x66, 0x65, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x67, 0x61, 0x73, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, - 0x61, 0x6c, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x64, 0x61, 0x74, 0x61, + 0x61, 0x6c, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x65, 0x78, - 0x63, 0x65, 0x73, 0x73, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x67, 0x61, 0x73, 0x22, 0xde, 0x01, + 0x63, 0x65, 0x73, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, 0x61, 0x73, 0x22, 0xde, 0x01, 0x0a, 0x09, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x2a, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x48, 0x32, 0x35, 0x36, 0x52, 0x09, 0x62, 0x6c, diff --git a/gointerfaces/execution/execution_grpc.pb.go b/gointerfaces/execution/execution_grpc.pb.go index 92d55ffcc..3cf518eb9 100644 --- a/gointerfaces/execution/execution_grpc.pb.go +++ b/gointerfaces/execution/execution_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.22.3 +// - protoc v4.23.3 // source: execution/execution.proto package execution diff --git a/gointerfaces/remote/ethbackend.pb.go b/gointerfaces/remote/ethbackend.pb.go index 73504ad55..95fdddcb7 100644 --- a/gointerfaces/remote/ethbackend.pb.go +++ b/gointerfaces/remote/ethbackend.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.22.3 +// protoc-gen-go v1.31.0 +// protoc v4.23.3 // source: remote/ethbackend.proto package remote diff --git a/gointerfaces/remote/ethbackend_grpc.pb.go b/gointerfaces/remote/ethbackend_grpc.pb.go index 9e67462ed..44636df59 100644 --- a/gointerfaces/remote/ethbackend_grpc.pb.go +++ b/gointerfaces/remote/ethbackend_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.22.3 +// - protoc v4.23.3 // source: remote/ethbackend.proto package remote diff --git a/gointerfaces/remote/kv.pb.go b/gointerfaces/remote/kv.pb.go index 90025c0cf..a3948ddda 100644 --- a/gointerfaces/remote/kv.pb.go +++ b/gointerfaces/remote/kv.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.22.3 +// protoc-gen-go v1.31.0 +// protoc v4.23.3 // source: remote/kv.proto package remote diff --git a/gointerfaces/remote/kv_grpc.pb.go b/gointerfaces/remote/kv_grpc.pb.go index 0732be103..eb32cbf39 100644 --- a/gointerfaces/remote/kv_grpc.pb.go +++ b/gointerfaces/remote/kv_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.22.3 +// - protoc v4.23.3 // source: remote/kv.proto package remote diff --git a/gointerfaces/sentinel/sentinel.pb.go b/gointerfaces/sentinel/sentinel.pb.go index ce2c8b0dd..c5252034c 100644 --- a/gointerfaces/sentinel/sentinel.pb.go +++ b/gointerfaces/sentinel/sentinel.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.22.3 +// protoc-gen-go v1.31.0 +// protoc v4.23.3 // source: p2psentinel/sentinel.proto package sentinel diff --git a/gointerfaces/sentinel/sentinel_grpc.pb.go b/gointerfaces/sentinel/sentinel_grpc.pb.go index 8eb4ff505..222d0fb8f 100644 --- a/gointerfaces/sentinel/sentinel_grpc.pb.go +++ b/gointerfaces/sentinel/sentinel_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.22.3 +// - protoc v4.23.3 // source: p2psentinel/sentinel.proto package sentinel diff --git a/gointerfaces/sentry/sentry.pb.go b/gointerfaces/sentry/sentry.pb.go index 5f0c375f0..2cc443be6 100644 --- a/gointerfaces/sentry/sentry.pb.go +++ b/gointerfaces/sentry/sentry.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.22.3 +// protoc-gen-go v1.31.0 +// protoc v4.23.3 // source: p2psentry/sentry.proto package sentry diff --git a/gointerfaces/sentry/sentry_grpc.pb.go b/gointerfaces/sentry/sentry_grpc.pb.go index 29f502691..854dd9dca 100644 --- a/gointerfaces/sentry/sentry_grpc.pb.go +++ b/gointerfaces/sentry/sentry_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.22.3 +// - protoc v4.23.3 // source: p2psentry/sentry.proto package sentry diff --git a/gointerfaces/txpool/mining.pb.go b/gointerfaces/txpool/mining.pb.go index 90b5affbe..827e8da6e 100644 --- a/gointerfaces/txpool/mining.pb.go +++ b/gointerfaces/txpool/mining.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.22.3 +// protoc-gen-go v1.31.0 +// protoc v4.23.3 // source: txpool/mining.proto package txpool diff --git a/gointerfaces/txpool/mining_grpc.pb.go b/gointerfaces/txpool/mining_grpc.pb.go index 00e0887b9..c2054b4e1 100644 --- a/gointerfaces/txpool/mining_grpc.pb.go +++ b/gointerfaces/txpool/mining_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.22.3 +// - protoc v4.23.3 // source: txpool/mining.proto package txpool diff --git a/gointerfaces/txpool/txpool.pb.go b/gointerfaces/txpool/txpool.pb.go index c5a342605..49693c16b 100644 --- a/gointerfaces/txpool/txpool.pb.go +++ b/gointerfaces/txpool/txpool.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.22.3 +// protoc-gen-go v1.31.0 +// protoc v4.23.3 // source: txpool/txpool.proto package txpool diff --git a/gointerfaces/txpool/txpool_grpc.pb.go b/gointerfaces/txpool/txpool_grpc.pb.go index 37340b884..a1ae12fc0 100644 --- a/gointerfaces/txpool/txpool_grpc.pb.go +++ b/gointerfaces/txpool/txpool_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.22.3 +// - protoc v4.23.3 // source: txpool/txpool.proto package txpool diff --git a/gointerfaces/types/types.pb.go b/gointerfaces/types/types.pb.go index 39e5a1f8a..b81ea0b4d 100644 --- a/gointerfaces/types/types.pb.go +++ b/gointerfaces/types/types.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.22.3 +// protoc-gen-go v1.31.0 +// protoc v4.23.3 // source: types/types.proto package types @@ -423,7 +423,7 @@ type ExecutionPayload struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` // v1 - no withdrawals, v2 - with withdrawals, v3 - with excess data gas + Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` // v1 - no withdrawals, v2 - with withdrawals, v3 - with blob gas ParentHash *H256 `protobuf:"bytes,2,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty"` Coinbase *H160 `protobuf:"bytes,3,opt,name=coinbase,proto3" json:"coinbase,omitempty"` StateRoot *H256 `protobuf:"bytes,4,opt,name=state_root,json=stateRoot,proto3" json:"state_root,omitempty"` @@ -439,8 +439,8 @@ type ExecutionPayload struct { BlockHash *H256 `protobuf:"bytes,14,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` Transactions [][]byte `protobuf:"bytes,15,rep,name=transactions,proto3" json:"transactions,omitempty"` Withdrawals []*Withdrawal `protobuf:"bytes,16,rep,name=withdrawals,proto3" json:"withdrawals,omitempty"` - DataGasUsed *uint64 `protobuf:"varint,17,opt,name=data_gas_used,json=dataGasUsed,proto3,oneof" json:"data_gas_used,omitempty"` - ExcessDataGas *uint64 `protobuf:"varint,18,opt,name=excess_data_gas,json=excessDataGas,proto3,oneof" json:"excess_data_gas,omitempty"` + BlobGasUsed *uint64 `protobuf:"varint,17,opt,name=blob_gas_used,json=blobGasUsed,proto3,oneof" json:"blob_gas_used,omitempty"` + ExcessBlobGas *uint64 `protobuf:"varint,18,opt,name=excess_blob_gas,json=excessBlobGas,proto3,oneof" json:"excess_blob_gas,omitempty"` } func (x *ExecutionPayload) Reset() { @@ -587,16 +587,16 @@ func (x *ExecutionPayload) GetWithdrawals() []*Withdrawal { return nil } -func (x *ExecutionPayload) GetDataGasUsed() uint64 { - if x != nil && x.DataGasUsed != nil { - return *x.DataGasUsed +func (x *ExecutionPayload) GetBlobGasUsed() uint64 { + if x != nil && x.BlobGasUsed != nil { + return *x.BlobGasUsed } return 0 } -func (x *ExecutionPayload) GetExcessDataGas() uint64 { - if x != nil && x.ExcessDataGas != nil { - return *x.ExcessDataGas +func (x *ExecutionPayload) GetExcessBlobGas() uint64 { + if x != nil && x.ExcessBlobGas != nil { + return *x.ExcessBlobGas } return 0 } @@ -1173,14 +1173,14 @@ var file_types_types_proto_rawDesc = []byte{ 0x6e, 0x73, 0x12, 0x33, 0x0a, 0x0b, 0x77, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x18, 0x10, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x52, 0x0b, 0x77, 0x69, 0x74, 0x68, - 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x12, 0x27, 0x0a, 0x0d, 0x64, 0x61, 0x74, 0x61, 0x5f, + 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x73, 0x12, 0x27, 0x0a, 0x0d, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x18, 0x11, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, - 0x52, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x47, 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x88, 0x01, 0x01, - 0x12, 0x2b, 0x0a, 0x0f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, + 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x62, 0x47, 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x88, 0x01, 0x01, + 0x12, 0x2b, 0x0a, 0x0f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, 0x61, 0x73, 0x18, 0x12, 0x20, 0x01, 0x28, 0x04, 0x48, 0x01, 0x52, 0x0d, 0x65, 0x78, 0x63, - 0x65, 0x73, 0x73, 0x44, 0x61, 0x74, 0x61, 0x47, 0x61, 0x73, 0x88, 0x01, 0x01, 0x42, 0x10, 0x0a, - 0x0e, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x42, - 0x12, 0x0a, 0x10, 0x5f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, + 0x65, 0x73, 0x73, 0x42, 0x6c, 0x6f, 0x62, 0x47, 0x61, 0x73, 0x88, 0x01, 0x01, 0x42, 0x10, 0x0a, + 0x0e, 0x5f, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x42, + 0x12, 0x0a, 0x10, 0x5f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, 0x61, 0x73, 0x22, 0x8a, 0x01, 0x0a, 0x0a, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x27, 0x0a, 0x0f, 0x76, 0x61, 0x6c, 0x69, diff --git a/txpool/pool.go b/txpool/pool.go index fa6739cf1..106bfcbe3 100644 --- a/txpool/pool.go +++ b/txpool/pool.go @@ -527,7 +527,7 @@ func (p *TxPool) IsLocal(idHash []byte) bool { func (p *TxPool) AddNewGoodPeer(peerID types.PeerID) { p.recentlyConnectedPeers.AddPeer(peerID) } func (p *TxPool) Started() bool { return p.started.Load() } -func (p *TxPool) best(n uint16, txs *types.TxsRlp, tx kv.Tx, onTopOf, availableGas, availableDataGas uint64, toSkip mapset.Set[[32]byte]) (bool, int, error) { +func (p *TxPool) best(n uint16, txs *types.TxsRlp, tx kv.Tx, onTopOf, availableGas, availableBlobGas uint64, toSkip mapset.Set[[32]byte]) (bool, int, error) { p.lock.Lock() defer p.lock.Unlock() @@ -568,12 +568,12 @@ func (p *TxPool) best(n uint16, txs *types.TxsRlp, tx kv.Tx, onTopOf, availableG continue } - // Skip transactions that require more data gas than is available + // Skip transactions that require more blob gas than is available blobCount := uint64(len(mt.Tx.BlobHashes)) - if blobCount*chain.DataGasPerBlob > availableDataGas { + if blobCount*fixedgas.BlobGasPerBlob > availableBlobGas { continue } - availableDataGas -= blobCount * chain.DataGasPerBlob + availableBlobGas -= blobCount * fixedgas.BlobGasPerBlob // make sure we have enough gas in the caller to add this transaction. // not an exact science using intrinsic gas but as close as we could hope for at @@ -610,13 +610,13 @@ func (p *TxPool) ResetYieldedStatus() { } } -func (p *TxPool) YieldBest(n uint16, txs *types.TxsRlp, tx kv.Tx, onTopOf, availableGas, availableDataGas uint64, toSkip mapset.Set[[32]byte]) (bool, int, error) { - return p.best(n, txs, tx, onTopOf, availableGas, availableDataGas, toSkip) +func (p *TxPool) YieldBest(n uint16, txs *types.TxsRlp, tx kv.Tx, onTopOf, availableGas, availableBlobGas uint64, toSkip mapset.Set[[32]byte]) (bool, int, error) { + return p.best(n, txs, tx, onTopOf, availableGas, availableBlobGas, toSkip) } -func (p *TxPool) PeekBest(n uint16, txs *types.TxsRlp, tx kv.Tx, onTopOf, availableGas, availableDataGas uint64) (bool, error) { +func (p *TxPool) PeekBest(n uint16, txs *types.TxsRlp, tx kv.Tx, onTopOf, availableGas, availableBlobGas uint64) (bool, error) { set := mapset.NewThreadUnsafeSet[[32]byte]() - onTime, _, err := p.best(n, txs, tx, onTopOf, availableGas, availableDataGas, set) + onTime, _, err := p.best(n, txs, tx, onTopOf, availableGas, availableBlobGas, set) return onTime, err } @@ -667,7 +667,7 @@ func (p *TxPool) validateTx(txn *types.TxSlot, isLocal bool, stateCache kvcache. if blobCount == 0 { return txpoolcfg.NoBlobs } - if blobCount > chain.MaxBlobsPerBlock { + if blobCount > fixedgas.MaxBlobsPerBlock { return txpoolcfg.TooManyBlobs } equalNumber := len(txn.BlobHashes) == len(txn.Blobs) && @@ -743,7 +743,7 @@ func (p *TxPool) validateTx(txn *types.TxSlot, isLocal bool, stateCache kvcache. var maxUint256 = new(uint256.Int).SetAllOne() -// Sender should have enough balance for: gasLimit x feeCap + dataGas x dataFeeCap + transferred_value +// Sender should have enough balance for: gasLimit x feeCap + blobGas x blobFeeCap + transferred_value // See YP, Eq (61) in Section 6.2 "Execution" func requiredBalance(txn *types.TxSlot) *uint256.Int { // See https://github.com/ethereum/EIPs/pull/3594 @@ -755,13 +755,13 @@ func requiredBalance(txn *types.TxSlot) *uint256.Int { // and https://eips.ethereum.org/EIPS/eip-4844#gas-accounting blobCount := uint64(len(txn.BlobHashes)) if blobCount != 0 { - maxDataGasCost := uint256.NewInt(chain.DataGasPerBlob) - maxDataGasCost.Mul(maxDataGasCost, uint256.NewInt(blobCount)) - _, overflow = maxDataGasCost.MulOverflow(maxDataGasCost, &txn.DataFeeCap) + maxBlobGasCost := uint256.NewInt(fixedgas.BlobGasPerBlob) + maxBlobGasCost.Mul(maxBlobGasCost, uint256.NewInt(blobCount)) + _, overflow = maxBlobGasCost.MulOverflow(maxBlobGasCost, &txn.BlobFeeCap) if overflow { return maxUint256 } - _, overflow = total.AddOverflow(total, maxDataGasCost) + _, overflow = total.AddOverflow(total, maxBlobGasCost) if overflow { return maxUint256 } @@ -1123,8 +1123,8 @@ func (p *TxPool) setBaseFee(baseFee uint64) (uint64, bool) { return p.pendingBaseFee.Load(), changed } -// TODO(eip-4844) logic similar to base fee for data gasprice -// DataFeeCap must be >= data gasprice +// TODO(eip-4844) logic similar to base fee for blob gasprice +// BlobFeeCap must be >= blob gasprice func (p *TxPool) addLocked(mt *metaTx, announcements *types.Announcements) txpoolcfg.DiscardReason { // Insert to pending pool, if pool doesn't have txn with same Nonce and bigger Tip diff --git a/txpool/txpool_grpc_server.go b/txpool/txpool_grpc_server.go index c34a08f3c..de4c26db3 100644 --- a/txpool/txpool_grpc_server.go +++ b/txpool/txpool_grpc_server.go @@ -52,7 +52,7 @@ var TxPoolAPIVersion = &types2.VersionReply{Major: 1, Minor: 0, Patch: 0} type txPool interface { ValidateSerializedTxn(serializedTxn []byte) error - PeekBest(n uint16, txs *types.TxsRlp, tx kv.Tx, onTopOf, availableGas, availableDataGas uint64) (bool, error) + PeekBest(n uint16, txs *types.TxsRlp, tx kv.Tx, onTopOf, availableGas, availableBlobGas uint64) (bool, error) GetRlp(tx kv.Tx, hash []byte) ([]byte, error) AddLocalTxs(ctx context.Context, newTxs types.TxSlots, tx kv.Tx) ([]txpoolcfg.DiscardReason, error) deprecatedForEach(_ context.Context, f func(rlp []byte, sender common.Address, t SubPoolType), tx kv.Tx) @@ -155,7 +155,7 @@ func (s *GrpcServer) Pending(ctx context.Context, _ *emptypb.Empty) (*txpool_pro reply := &txpool_proto.PendingReply{} reply.Txs = make([]*txpool_proto.PendingReply_Tx, 0, 32) txSlots := types.TxsRlp{} - if _, err := s.txPool.PeekBest(math.MaxInt16, &txSlots, tx, 0 /* onTopOf */, math.MaxUint64 /* availableGas */, math.MaxUint64 /* availableDataGas */); err != nil { + if _, err := s.txPool.PeekBest(math.MaxInt16, &txSlots, tx, 0 /* onTopOf */, math.MaxUint64 /* availableGas */, math.MaxUint64 /* availableBlobGas */); err != nil { return nil, err } var senderArr [20]byte diff --git a/types/txn.go b/types/txn.go index 0c579c5e1..9a0c3c071 100644 --- a/types/txn.go +++ b/types/txn.go @@ -31,8 +31,8 @@ import ( "github.com/ledgerwatch/secp256k1" "golang.org/x/crypto/sha3" - "github.com/ledgerwatch/erigon-lib/chain" "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/fixedgas" "github.com/ledgerwatch/erigon-lib/common/length" "github.com/ledgerwatch/erigon-lib/common/u256" "github.com/ledgerwatch/erigon-lib/crypto" @@ -103,7 +103,7 @@ type TxSlot struct { Size uint32 // Size of the payload // EIP-4844: Shard Blob Transactions - DataFeeCap uint256.Int // max_fee_per_data_gas + BlobFeeCap uint256.Int // max_fee_per_blob_gas BlobHashes []common.Hash Blobs [][]byte Commitments []gokzg4844.KZGCommitment @@ -211,12 +211,12 @@ func (ctx *TxParseContext) ParseTransaction(payload []byte, pos int, slot *TxSlo } blobPos := dataPos for blobPos < dataPos+dataLen { - blobPos, err = rlp.StringOfLen(payload, blobPos, chain.BlobSize) + blobPos, err = rlp.StringOfLen(payload, blobPos, fixedgas.BlobSize) if err != nil { return 0, fmt.Errorf("%w: blob: %s", ErrParseTxn, err) //nolint } - slot.Blobs = append(slot.Blobs, payload[blobPos:blobPos+chain.BlobSize]) - blobPos += chain.BlobSize + slot.Blobs = append(slot.Blobs, payload[blobPos:blobPos+fixedgas.BlobSize]) + blobPos += fixedgas.BlobSize } if blobPos != dataPos+dataLen { return 0, fmt.Errorf("%w: extraneous space in blobs", ErrParseTxn) @@ -424,9 +424,9 @@ func (ctx *TxParseContext) parseTransactionBody(payload []byte, pos, p0 int, slo p = dataPos + dataLen } if slot.Type == BlobTxType { - p, err = rlp.U256(payload, p, &slot.DataFeeCap) + p, err = rlp.U256(payload, p, &slot.BlobFeeCap) if err != nil { - return 0, fmt.Errorf("%w: data fee cap: %s", ErrParseTxn, err) //nolint + return 0, fmt.Errorf("%w: blob fee cap: %s", ErrParseTxn, err) //nolint } dataPos, dataLen, err = rlp.List(payload, p) if err != nil { diff --git a/types/txn_test.go b/types/txn_test.go index e1aa92937..8957157b7 100644 --- a/types/txn_test.go +++ b/types/txn_test.go @@ -27,7 +27,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/ledgerwatch/erigon-lib/chain" + "github.com/ledgerwatch/erigon-lib/common/fixedgas" "github.com/ledgerwatch/erigon-lib/common/hexutility" ) @@ -218,9 +218,9 @@ func TestBlobTxParsing(t *testing.T) { blobsRlpPrefix := hexutility.MustDecodeHex("fa040008") blobRlpPrefix := hexutility.MustDecodeHex("ba020000") - blob0 := make([]byte, chain.BlobSize) + blob0 := make([]byte, fixedgas.BlobSize) rand.Read(blob0) - blob1 := make([]byte, chain.BlobSize) + blob1 := make([]byte, fixedgas.BlobSize) rand.Read(blob1) proofsRlpPrefix := hexutility.MustDecodeHex("f862") @@ -268,7 +268,7 @@ func TestBlobTxParsing(t *testing.T) { assert.Equal(t, thinTx.Gas, fatTx.Gas) assert.Equal(t, thinTx.IDHash, fatTx.IDHash) assert.Equal(t, thinTx.Creation, fatTx.Creation) - assert.Equal(t, thinTx.DataFeeCap, fatTx.DataFeeCap) + assert.Equal(t, thinTx.BlobFeeCap, fatTx.BlobFeeCap) assert.Equal(t, thinTx.BlobHashes, fatTx.BlobHashes) require.Equal(t, 2, len(fatTx.Blobs))