Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

rename data gas to blob gas #1659

Merged
merged 8 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions fluffy/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -239,51 +239,51 @@ func completeCmdArg*(T: type TrustedDigest, input: string): seq[string] =
return @[]

proc parseCmdArg*(T: type enr.Record, p: string): T
{.raises: [ConfigurationError].} =
{.raises: [ValueError].} =
if not fromURI(result, p):
raise newException(ConfigurationError, "Invalid ENR")
raise newException(ValueError, "Invalid ENR")

proc completeCmdArg*(T: type enr.Record, val: string): seq[string] =
return @[]

proc parseCmdArg*(T: type Node, p: string): T
{.raises: [ConfigurationError].} =
{.raises: [ValueError].} =
var record: enr.Record
if not fromURI(record, p):
raise newException(ConfigurationError, "Invalid ENR")
raise newException(ValueError, "Invalid ENR")

let n = newNode(record)
if n.isErr:
raise newException(ConfigurationError, $n.error)
raise newException(ValueError, $n.error)

if n[].address.isNone():
raise newException(ConfigurationError, "ENR without address")
raise newException(ValueError, "ENR without address")

n[]

proc completeCmdArg*(T: type Node, val: string): seq[string] =
return @[]

proc parseCmdArg*(T: type PrivateKey, p: string): T
{.raises: [ConfigurationError].} =
{.raises: [ValueError].} =
try:
result = PrivateKey.fromHex(p).tryGet()
except CatchableError:
raise newException(ConfigurationError, "Invalid private key")
raise newException(ValueError, "Invalid private key")

proc completeCmdArg*(T: type PrivateKey, val: string): seq[string] =
return @[]

proc parseCmdArg*(T: type ClientConfig, p: string): T
{.raises: [ConfigurationError].} =
{.raises: [ValueError].} =
let uri = parseUri(p)
if (uri.scheme == "http" or uri.scheme == "https"):
getHttpClientConfig(p)
elif (uri.scheme == "ws" or uri.scheme == "wss"):
getWebSocketClientConfig(p)
else:
raise newException(
ConfigurationError, "Proxy uri should have defined scheme (http/https/ws/wss)"
ValueError, "Proxy uri should have defined scheme (http/https/ws/wss)"
)

proc completeCmdArg*(T: type ClientConfig, val: string): seq[string] =
Expand Down
2 changes: 1 addition & 1 deletion fluffy/network/history/history_network.nim
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func validateBlockHeaderBytes*(

let header = ? decodeRlp(bytes, BlockHeader)

if header.excessDataGas.isSome:
if header.excessBlobGas.isSome:
return err("EIP-4844 not yet implemented")

# TODO: Verify timestamp with Shanghai timestamp to if isSome()
Expand Down
10 changes: 5 additions & 5 deletions fluffy/network/wire/portal_protocol_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ proc init*(
)

proc parseCmdArg*(T: type RadiusConfig, p: string): T
{.raises: [ConfigurationError].} =
{.raises: [ValueError].} =
if p.startsWith("dynamic") and len(p) == 7:
RadiusConfig(kind: Dynamic)
elif p.startsWith("static:"):
Expand All @@ -64,11 +64,11 @@ proc parseCmdArg*(T: type RadiusConfig, p: string): T
uint16.parseCmdArg(num)
except ValueError:
let msg = "Provided logRadius: " & num & " is not a valid number"
raise newException(ConfigurationError, msg)
raise newException(ValueError, msg)

if parsed > 256:
raise newException(
ConfigurationError, "Provided logRadius should be <= 256"
ValueError, "Provided logRadius should be <= 256"
)

RadiusConfig(kind: Static, logRadius: parsed)
Expand All @@ -80,11 +80,11 @@ proc parseCmdArg*(T: type RadiusConfig, p: string): T
let msg =
"Not supported radius config option: " & p & " . " &
"Supported options: dynamic and static:logRadius"
raise newException(ConfigurationError, msg)
raise newException(ValueError, msg)

if parsed > 256:
raise newException(
ConfigurationError, "Provided logRadius should be <= 256")
ValueError, "Provided logRadius should be <= 256")

RadiusConfig(kind: Static, logRadius: parsed)

Expand Down
8 changes: 4 additions & 4 deletions fluffy/tools/beacon_lc_bridge/beacon_lc_bridge.nim
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ proc asPortalBlockData*(
nonce: default(BlockNonce),
fee: some(payload.baseFeePerGas),
withdrawalsRoot: withdrawalsRoot,
dataGasUsed: options.none(uint64),
excessDataGas: options.none(uint64)
blobGasUsed: options.none(uint64),
excessBlobGas: options.none(uint64)
)

headerWithProof = BlockHeaderWithProof(
Expand Down Expand Up @@ -292,8 +292,8 @@ proc asPortalBlockData*(
nonce: default(BlockNonce),
fee: some(payload.baseFeePerGas),
withdrawalsRoot: withdrawalsRoot,
dataGasUsed: options.none(uint64),
excessDataGas: options.none(uint64) # TODO: adjust later according to deneb fork
blobGasUsed: options.none(uint64),
excessBlobGas: options.none(uint64) # TODO: adjust later according to deneb fork
)

headerWithProof = BlockHeaderWithProof(
Expand Down
4 changes: 2 additions & 2 deletions fluffy/tools/beacon_lc_bridge/beacon_lc_bridge_conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ type BeaconBridgeConf* = object
name: "direct-peer" .}: seq[string]

proc parseCmdArg*(
T: type Web3Url, p: string): T {.raises: [ConfigurationError].} =
T: type Web3Url, p: string): T {.raises: [ValueError].} =
let
url = parseUri(p)
normalizedScheme = url.scheme.toLowerAscii()
Expand All @@ -181,7 +181,7 @@ proc parseCmdArg*(
Web3Url(kind: WsUrl, web3Url: p)
else:
raise newException(
ConfigurationError,
ValueError,
"The Web3 URL must specify one of following protocols: http/https/ws/wss"
)

Expand Down
4 changes: 2 additions & 2 deletions fluffy/tools/blockwalk.nim
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ type
name: "block-hash" .}: Hash256

proc parseCmdArg*(T: type Hash256, p: string): T
{.raises: [ConfigurationError].} =
{.raises: [ValueError].} =
var hash: Hash256
try:
hexToByteArray(p, hash.data)
except ValueError:
raise newException(ConfigurationError, "Invalid Hash256")
raise newException(ValueError, "Invalid Hash256")

return hash

Expand Down
8 changes: 4 additions & 4 deletions fluffy/tools/eth_data_exporter/exporter_conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ type
discard

proc parseCmdArg*(
T: type Web3Url, p: string): T {.raises: [ConfigurationError].} =
T: type Web3Url, p: string): T {.raises: [ValueError].} =
let
url = parseUri(p)
normalizedScheme = url.scheme.toLowerAscii()
Expand All @@ -195,22 +195,22 @@ proc parseCmdArg*(
Web3Url(kind: WsUrl, url: p)
else:
raise newException(
ConfigurationError,
ValueError,
"The Web3 URL must specify one of following protocols: http/https/ws/wss"
)

proc completeCmdArg*(T: type Web3Url, val: string): seq[string] =
return @[]

proc parseCmdArg*(T: type StorageMode, p: string): T
{.raises: [ConfigurationError].} =
{.raises: [ValueError].} =
if p == "db":
return DbStorage
elif p == "json":
return JsonStorage
else:
let msg = "Provided mode: " & p & " is not a valid. Should be `json` or `db`"
raise newException(ConfigurationError, msg)
raise newException(ValueError, msg)

proc completeCmdArg*(T: type StorageMode, val: string): seq[string] =
return @[]
Expand Down
12 changes: 6 additions & 6 deletions fluffy/tools/portalcli.nim
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,22 @@ type

proc parseCmdArg*(T: type enr.Record, p: string): T =
if not fromURI(result, p):
raise newException(ConfigurationError, "Invalid ENR")
raise newException(ValueError, "Invalid ENR")

proc completeCmdArg*(T: type enr.Record, val: string): seq[string] =
return @[]

proc parseCmdArg*(T: type Node, p: string): T =
var record: enr.Record
if not fromURI(record, p):
raise newException(ConfigurationError, "Invalid ENR")
raise newException(ValueError, "Invalid ENR")

let n = newNode(record)
if n.isErr:
raise newException(ConfigurationError, $n.error)
raise newException(ValueError, $n.error)

if n[].address.isNone():
raise newException(ConfigurationError, "ENR without address")
raise newException(ValueError, "ENR without address")

n[]

Expand All @@ -169,7 +169,7 @@ proc parseCmdArg*(T: type PrivateKey, p: string): T =
try:
result = PrivateKey.fromHex(p).tryGet()
except CatchableError:
raise newException(ConfigurationError, "Invalid private key")
raise newException(ValueError, "Invalid private key")

proc completeCmdArg*(T: type PrivateKey, val: string): seq[string] =
return @[]
Expand All @@ -178,7 +178,7 @@ proc parseCmdArg*(T: type PortalProtocolId, p: string): T =
try:
result = byteutils.hexToByteArray(p, 2)
except ValueError:
raise newException(ConfigurationError,
raise newException(ValueError,
"Invalid protocol id, not a valid hex value")

proc completeCmdArg*(T: type PortalProtocolId, val: string): seq[string] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ proc parseGenesis(n: JsonNode): Genesis =
for x in genFields:
genesis[x] = gen[x]
optionalField("baseFeePerGas", genesis, gen)
optionalField("dataGasUsed", genesis, gen)
optionalField("excessDataGas", genesis, gen)
optionalField("blobGasUsed", genesis, gen)
optionalField("excessBlobGas", genesis, gen)
genesis["alloc"] = n["pre"]
parseGenesis($genesis)

Expand Down
8 changes: 4 additions & 4 deletions nimbus/common/chain_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type
gasUser* : GasInt
parentHash* : Hash256
baseFeePerGas*: Option[UInt256]
dataGasUsed* : Option[uint64] # EIP-4844
excessDataGas*: Option[uint64] # EIP-4844
blobGasUsed* : Option[uint64] # EIP-4844
excessBlobGas*: Option[uint64] # EIP-4844

GenesisAlloc* = Table[EthAddress, GenesisAccount]
GenesisAccount* = object
Expand Down Expand Up @@ -67,8 +67,8 @@ type
gasUser* : GasInt
parentHash* : Hash256
baseFeePerGas*: Option[UInt256]
dataGasUsed* : Option[uint64] # EIP-4844
excessDataGas*: Option[uint64] # EIP-4844
blobGasUsed* : Option[uint64] # EIP-4844
excessBlobGas*: Option[uint64] # EIP-4844

const
CustomNet* = 0.NetworkId
Expand Down
4 changes: 2 additions & 2 deletions nimbus/common/genesis.nim
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ proc toGenesisHeader*(
result.withdrawalsRoot = some(EMPTY_ROOT_HASH)

if fork >= Cancun:
result.dataGasUsed = g.dataGasUsed
result.excessDataGas = g.excessDataGas
result.blobGasUsed = g.blobGasUsed
result.excessBlobGas = g.excessBlobGas

proc toGenesisHeader*(
genesis: Genesis;
Expand Down
12 changes: 6 additions & 6 deletions nimbus/constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ const
MAX_TX_WRAP_COMMITMENTS* = 1 shl 12 # 2^12
BLOB_COMMITMENT_VERSION_KZG* = 0x01.byte
FIELD_ELEMENTS_PER_BLOB* = 4096
DATA_GAS_PER_BLOB* = (1 shl 17).uint64 # 2^17
TARGET_DATA_GAS_PER_BLOCK* = (1 shl 18).uint64 # 2^18
MIN_DATA_GASPRICE* = 1'u64
DATA_GASPRICE_UPDATE_FRACTION* = 2225652'u64
MAX_DATA_GAS_PER_BLOCK* = (1 shl 19).uint64 # 2^19
MaxAllowedBlob* = MAX_DATA_GAS_PER_BLOCK div DATA_GAS_PER_BLOB
GAS_PER_BLOB* = (1 shl 17).uint64 # 2^17
TARGET_BLOB_GAS_PER_BLOCK* = (1 shl 18).uint64 # 2^18
MIN_BLOB_GASPRICE* = 1'u64
BLOB_GASPRICE_UPDATE_FRACTION* = 2225652'u64
MAX_BLOB_GAS_PER_BLOCK* = (1 shl 19).uint64 # 2^19
MaxAllowedBlob* = MAX_BLOB_GAS_PER_BLOCK div GAS_PER_BLOB

# End