Compare commits
No commits in common. "6a10dfd0fe1fcae73b9b2d5574e45faa213fe690" and "6b68ff92d33d08ddfd2def83d84130b5661a6d4f" have entirely different histories.
6a10dfd0fe
...
6b68ff92d3
|
@ -21,7 +21,6 @@ import
|
|||
../../evm/state,
|
||||
../../evm/types,
|
||||
../../constants,
|
||||
../eip4844,
|
||||
../validate
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -93,12 +92,6 @@ proc processTransactionImpl(
|
|||
|
||||
vmState.gasPool -= tx.gasLimit
|
||||
|
||||
let blobGasUsed = tx.getTotalBlobGas
|
||||
if vmState.blobGasUsed + blobGasUsed > MAX_BLOB_GAS_PER_BLOCK:
|
||||
return err("blobGasUsed " & $blobGasUsed &
|
||||
" exceeds maximum allowance " & $MAX_BLOB_GAS_PER_BLOCK)
|
||||
vmState.blobGasUsed += blobGasUsed
|
||||
|
||||
# Actually, the eip-1559 reference does not mention an early exit.
|
||||
#
|
||||
# Even though database was not changed yet but, a `persist()` directive
|
||||
|
|
|
@ -22,7 +22,7 @@ import
|
|||
../../../common/common,
|
||||
../../../utils/utils,
|
||||
../../../constants,
|
||||
"../.."/[dao, executor, validate, casper],
|
||||
"../.."/[dao, executor, validate, eip4844, casper],
|
||||
../../../transaction/call_evm,
|
||||
../../../transaction,
|
||||
../../../evm/state,
|
||||
|
@ -39,6 +39,7 @@ type
|
|||
tr: CoreDbMptRef
|
||||
cleanState: bool
|
||||
balance: UInt256
|
||||
blobGasUsed: uint64
|
||||
numBlobPerBlock: int
|
||||
|
||||
const
|
||||
|
@ -130,6 +131,10 @@ proc runTxCommit(pst: TxPackerStateRef; item: TxItemRef; gasBurned: GasInt)
|
|||
vmState.cumulativeGasUsed += gasBurned
|
||||
vmState.receipts[inx] = vmState.makeReceipt(item.tx.txType)
|
||||
|
||||
# EIP-4844, count blobGasUsed
|
||||
if item.tx.txType >= TxEip4844:
|
||||
pst.blobGasUsed += item.tx.getTotalBlobGas
|
||||
|
||||
# Update txRoot
|
||||
pst.tr.merge(rlp.encode(inx), rlp.encode(item.tx)).isOkOr:
|
||||
raiseAssert "runTxCommit(): merge failed, " & $$error
|
||||
|
@ -257,7 +262,7 @@ proc vmExecCommit(pst: TxPackerStateRef)
|
|||
if vmState.com.forkGTE(Cancun):
|
||||
# EIP-4844
|
||||
xp.chain.excessBlobGas = Opt.some(vmState.blockCtx.excessBlobGas)
|
||||
xp.chain.blobGasUsed = Opt.some(vmState.blobGasUsed)
|
||||
xp.chain.blobGasUsed = Opt.some(pst.blobGasUsed)
|
||||
|
||||
proc balanceDelta: UInt256 =
|
||||
let postBalance = vmState.readOnlyStateDB.getBalance(xp.chain.feeRecipient)
|
||||
|
|
|
@ -183,19 +183,20 @@ func toVoidRc[T](
|
|||
# ------------------------------------------------------------------------------
|
||||
# Private `MPT` call back functions
|
||||
# ------------------------------------------------------------------------------
|
||||
proc mptMethods(): CoreDbMptFns =
|
||||
# These templates are a hack to remove a closure environment that was using
|
||||
# hundreds of mb of memory to have this syntactic convenience
|
||||
# TODO remove methods / abstraction entirely - it is no longer needed
|
||||
template base: untyped = cMpt.base
|
||||
template db: untyped = base.parent # Ditto
|
||||
template api: untyped = base.api # Ditto
|
||||
template mpt: untyped = base.ctx.mpt # Ditto
|
||||
|
||||
proc mptBackend(cMpt: AristoCoreDbMptRef): CoreDbMptBackendRef =
|
||||
proc mptMethods(cMpt: AristoCoreDbMptRef): CoreDbMptFns =
|
||||
## Generic columns database handlers
|
||||
let
|
||||
cMpt = cMpt # So it can savely be captured
|
||||
base = cMpt.base # Will not change and can be captured
|
||||
db = base.parent # Ditto
|
||||
api = base.api # Ditto
|
||||
mpt = base.ctx.mpt # Ditto
|
||||
|
||||
proc mptBackend(): CoreDbMptBackendRef =
|
||||
db.bless AristoCoreDbMptBE(adb: mpt)
|
||||
|
||||
proc mptColFn(cMpt: AristoCoreDbMptRef): CoreDbColRef =
|
||||
proc mptColFn(): CoreDbColRef =
|
||||
if cMpt.mptRoot.distinctBase < LEAST_FREE_VID:
|
||||
return db.bless(AristoColRef(
|
||||
base: base,
|
||||
|
@ -218,7 +219,7 @@ proc mptMethods(): CoreDbMptFns =
|
|||
stoRoot: cMpt.mptRoot,
|
||||
stoAddr: cMpt.address)
|
||||
|
||||
proc mptFetch(cMpt: AristoCoreDbMptRef, key: openArray[byte]): CoreDbRc[Blob] =
|
||||
proc mptFetch(key: openArray[byte]): CoreDbRc[Blob] =
|
||||
const info = "fetchFn()"
|
||||
|
||||
let rc = block:
|
||||
|
@ -240,7 +241,7 @@ proc mptMethods(): CoreDbMptFns =
|
|||
else:
|
||||
err(rc.error.toError(base, info, MptNotFound))
|
||||
|
||||
proc mptMerge(cMpt: AristoCoreDbMptRef, k: openArray[byte]; v: openArray[byte]): CoreDbRc[void] =
|
||||
proc mptMerge(k: openArray[byte]; v: openArray[byte]): CoreDbRc[void] =
|
||||
const info = "mergeFn()"
|
||||
|
||||
if cMpt.accPath.isValid:
|
||||
|
@ -256,7 +257,7 @@ proc mptMethods(): CoreDbMptFns =
|
|||
|
||||
ok()
|
||||
|
||||
proc mptDelete(cMpt: AristoCoreDbMptRef, key: openArray[byte]): CoreDbRc[void] =
|
||||
proc mptDelete(key: openArray[byte]): CoreDbRc[void] =
|
||||
const info = "deleteFn()"
|
||||
|
||||
let rc = block:
|
||||
|
@ -280,7 +281,7 @@ proc mptMethods(): CoreDbMptFns =
|
|||
|
||||
ok()
|
||||
|
||||
proc mptHasPath(cMpt: AristoCoreDbMptRef, key: openArray[byte]): CoreDbRc[bool] =
|
||||
proc mptHasPath(key: openArray[byte]): CoreDbRc[bool] =
|
||||
const info = "hasPathFn()"
|
||||
|
||||
let rc = block:
|
||||
|
@ -294,50 +295,52 @@ proc mptMethods(): CoreDbMptFns =
|
|||
return err(rc.error.toError(base, info))
|
||||
ok(rc.value)
|
||||
|
||||
## Generic columns database handlers
|
||||
|
||||
CoreDbMptFns(
|
||||
backendFn: proc(cMpt: CoreDbMptRef): CoreDbMptBackendRef =
|
||||
mptBackend(AristoCoreDbMptRef(cMpt)),
|
||||
backendFn: proc(): CoreDbMptBackendRef =
|
||||
mptBackend(),
|
||||
|
||||
fetchFn: proc(cMpt: CoreDbMptRef, k: openArray[byte]): CoreDbRc[Blob] =
|
||||
mptFetch(AristoCoreDbMptRef(cMpt), k),
|
||||
fetchFn: proc(k: openArray[byte]): CoreDbRc[Blob] =
|
||||
mptFetch(k),
|
||||
|
||||
deleteFn: proc(cMpt: CoreDbMptRef, k: openArray[byte]): CoreDbRc[void] =
|
||||
mptDelete(AristoCoreDbMptRef(cMpt), k),
|
||||
deleteFn: proc(k: openArray[byte]): CoreDbRc[void] =
|
||||
mptDelete(k),
|
||||
|
||||
mergeFn: proc(cMpt: CoreDbMptRef, k: openArray[byte]; v: openArray[byte]): CoreDbRc[void] =
|
||||
mptMerge(AristoCoreDbMptRef(cMpt), k, v),
|
||||
mergeFn: proc(k: openArray[byte]; v: openArray[byte]): CoreDbRc[void] =
|
||||
mptMerge(k, v),
|
||||
|
||||
hasPathFn: proc(cMpt: CoreDbMptRef, k: openArray[byte]): CoreDbRc[bool] =
|
||||
mptHasPath(AristoCoreDbMptRef(cMpt), k),
|
||||
hasPathFn: proc(k: openArray[byte]): CoreDbRc[bool] =
|
||||
mptHasPath(k),
|
||||
|
||||
getColFn: proc(cMpt: CoreDbMptRef): CoreDbColRef =
|
||||
mptColFn(AristoCoreDbMptRef(cMpt)))
|
||||
getColFn: proc(): CoreDbColRef =
|
||||
mptColFn())
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Private account call back functions
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
proc accMethods(): CoreDbAccFns =
|
||||
proc accMethods(cAcc: AristoCoreDbAccRef): CoreDbAccFns =
|
||||
## Account columns database handlers
|
||||
template base: untyped = cAcc.base
|
||||
template db: untyped = base.parent
|
||||
template api: untyped = base.api
|
||||
template mpt: untyped = base.ctx.mpt
|
||||
let
|
||||
cAcc = cAcc # So it can savely be captured
|
||||
base = cAcc.base # Will not change and can be captured
|
||||
db = base.parent # Ditto
|
||||
api = base.api # Ditto
|
||||
mpt = base.ctx.mpt # Ditto
|
||||
|
||||
proc getColFn(cAcc: AristoCoreDbAccRef): CoreDbColRef =
|
||||
proc getColFn(): CoreDbColRef =
|
||||
db.bless AristoColRef(
|
||||
base: base,
|
||||
colType: CtAccounts)
|
||||
|
||||
proc accCloneMpt(cAcc: AristoCoreDbAccRef): CoreDbRc[CoreDbMptRef] =
|
||||
proc accCloneMpt(): CoreDbRc[CoreDbMptRef] =
|
||||
var xpt = AristoCoreDbMptRef(
|
||||
base: base,
|
||||
mptRoot: AccountsVID)
|
||||
xpt.methods = mptMethods()
|
||||
xpt.methods = xpt.mptMethods
|
||||
ok(db.bless xpt)
|
||||
|
||||
proc accFetch(cAcc: AristoCoreDbAccRef, address: EthAddress): CoreDbRc[CoreDbAccount] =
|
||||
proc accFetch(address: EthAddress): CoreDbRc[CoreDbAccount] =
|
||||
const info = "acc/fetchFn()"
|
||||
|
||||
let
|
||||
|
@ -349,7 +352,7 @@ proc accMethods(): CoreDbAccFns =
|
|||
|
||||
ok cAcc.toCoreDbAccount(acc, address)
|
||||
|
||||
proc accMerge(cAcc: AristoCoreDbAccRef, account: CoreDbAccount): CoreDbRc[void] =
|
||||
proc accMerge(account: CoreDbAccount): CoreDbRc[void] =
|
||||
const info = "acc/mergeFn()"
|
||||
|
||||
let
|
||||
|
@ -360,7 +363,7 @@ proc accMethods(): CoreDbAccFns =
|
|||
return err(rc.error.toError(base, info))
|
||||
ok()
|
||||
|
||||
proc accDelete(cAcc: AristoCoreDbAccRef, address: EthAddress): CoreDbRc[void] =
|
||||
proc accDelete(address: EthAddress): CoreDbRc[void] =
|
||||
const info = "acc/deleteFn()"
|
||||
|
||||
let key = address.keccakHash.data
|
||||
|
@ -371,7 +374,7 @@ proc accMethods(): CoreDbAccFns =
|
|||
|
||||
ok()
|
||||
|
||||
proc accStoDelete(cAcc: AristoCoreDbAccRef, address: EthAddress): CoreDbRc[void] =
|
||||
proc accStoDelete(address: EthAddress): CoreDbRc[void] =
|
||||
const info = "stoDeleteFn()"
|
||||
|
||||
let rc = api.deleteStorageTree(mpt, address.to(PathID))
|
||||
|
@ -380,7 +383,7 @@ proc accMethods(): CoreDbAccFns =
|
|||
|
||||
ok()
|
||||
|
||||
proc accHasPath(cAcc: AristoCoreDbAccRef, address: EthAddress): CoreDbRc[bool] =
|
||||
proc accHasPath(address: EthAddress): CoreDbRc[bool] =
|
||||
const info = "hasPathFn()"
|
||||
|
||||
let
|
||||
|
@ -391,39 +394,40 @@ proc accMethods(): CoreDbAccFns =
|
|||
|
||||
|
||||
CoreDbAccFns(
|
||||
getMptFn: proc(cAcc: CoreDbAccRef): CoreDbRc[CoreDbMptRef] =
|
||||
accCloneMpt(AristoCoreDbAccRef(cAcc)),
|
||||
getMptFn: proc(): CoreDbRc[CoreDbMptRef] =
|
||||
accCloneMpt(),
|
||||
|
||||
fetchFn: proc(cAcc: CoreDbAccRef, address: EthAddress): CoreDbRc[CoreDbAccount] =
|
||||
accFetch(AristoCoreDbAccRef(cAcc), address),
|
||||
fetchFn: proc(address: EthAddress): CoreDbRc[CoreDbAccount] =
|
||||
accFetch(address),
|
||||
|
||||
deleteFn: proc(cAcc: CoreDbAccRef, address: EthAddress): CoreDbRc[void] =
|
||||
accDelete(AristoCoreDbAccRef(cAcc), address),
|
||||
deleteFn: proc(address: EthAddress): CoreDbRc[void] =
|
||||
accDelete(address),
|
||||
|
||||
stoDeleteFn: proc(cAcc: CoreDbAccRef, address: EthAddress): CoreDbRc[void] =
|
||||
accStoDelete(AristoCoreDbAccRef(cAcc), address),
|
||||
stoDeleteFn: proc(address: EthAddress): CoreDbRc[void] =
|
||||
accStoDelete(address),
|
||||
|
||||
mergeFn: proc(cAcc: CoreDbAccRef, acc: CoreDbAccount): CoreDbRc[void] =
|
||||
accMerge(AristoCoreDbAccRef(cAcc), acc),
|
||||
mergeFn: proc(acc: CoreDbAccount): CoreDbRc[void] =
|
||||
accMerge(acc),
|
||||
|
||||
hasPathFn: proc(cAcc: CoreDbAccRef, address: EthAddress): CoreDbRc[bool] =
|
||||
accHasPath(AristoCoreDbAccRef(cAcc), address),
|
||||
hasPathFn: proc(address: EthAddress): CoreDbRc[bool] =
|
||||
accHasPath(address),
|
||||
|
||||
getColFn: proc(cAcc: CoreDbAccRef): CoreDbColRef =
|
||||
getColFn(AristoCoreDbAccRef(cAcc)))
|
||||
getColFn: proc(): CoreDbColRef =
|
||||
getColFn())
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Private context call back functions
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
proc ctxMethods(cCtx: AristoCoreDbCtxRef): CoreDbCtxFns =
|
||||
template base: untyped = cCtx.base
|
||||
template db: untyped = base.parent
|
||||
template api: untyped = base.api
|
||||
template mpt: untyped = cCtx.mpt
|
||||
let
|
||||
cCtx = cCtx # So it can savely be captured
|
||||
base = cCtx.base # Will not change and can be captured
|
||||
db = base.parent # Ditto
|
||||
api = base.api # Ditto
|
||||
mpt = cCtx.mpt # Ditto
|
||||
|
||||
proc ctxNewCol(
|
||||
cCtx: AristoCoreDbCtxRef,
|
||||
colType: CoreDbColType;
|
||||
colState: Hash256;
|
||||
address: Opt[EthAddress];
|
||||
|
@ -459,7 +463,7 @@ proc ctxMethods(cCtx: AristoCoreDbCtxRef): CoreDbCtxFns =
|
|||
err(aristo.GenericError.toError(base, info, RootNotFound))
|
||||
|
||||
|
||||
proc ctxGetMpt(cCtx: AristoCoreDbCtxRef, col: CoreDbColRef): CoreDbRc[CoreDbMptRef] =
|
||||
proc ctxGetMpt(col: CoreDbColRef): CoreDbRc[CoreDbMptRef] =
|
||||
const
|
||||
info = "ctx/getMptFn()"
|
||||
let
|
||||
|
@ -501,10 +505,10 @@ proc ctxMethods(cCtx: AristoCoreDbCtxRef): CoreDbCtxFns =
|
|||
col.reset = false
|
||||
|
||||
newMpt.base = base
|
||||
newMpt.methods = mptMethods()
|
||||
newMpt.methods = newMpt.mptMethods()
|
||||
ok(db.bless newMpt)
|
||||
|
||||
proc ctxGetAcc(cCtx: AristoCoreDbCtxRef, col: CoreDbColRef): CoreDbRc[CoreDbAccRef] =
|
||||
proc ctxGetAcc(col: CoreDbColRef): CoreDbRc[CoreDbAccRef] =
|
||||
const info = "getAccFn()"
|
||||
|
||||
let col = AristoColRef(col)
|
||||
|
@ -513,32 +517,31 @@ proc ctxMethods(cCtx: AristoCoreDbCtxRef): CoreDbCtxFns =
|
|||
return err(error.toError(base, info, RootUnacceptable))
|
||||
|
||||
let acc = AristoCoreDbAccRef(base: base)
|
||||
acc.methods = accMethods()
|
||||
acc.methods = acc.accMethods()
|
||||
|
||||
ok(db.bless acc)
|
||||
|
||||
proc ctxForget(cCtx: AristoCoreDbCtxRef) =
|
||||
proc ctxForget() =
|
||||
api.forget(mpt).isOkOr:
|
||||
raiseAssert "forgetFn(): " & $error
|
||||
|
||||
|
||||
CoreDbCtxFns(
|
||||
newColFn: proc(
|
||||
cCtx: CoreDbCtxRef;
|
||||
col: CoreDbColType;
|
||||
colState: Hash256;
|
||||
address: Opt[EthAddress];
|
||||
): CoreDbRc[CoreDbColRef] =
|
||||
ctxNewCol(AristoCoreDbCtxRef(cCtx), col, colState, address),
|
||||
ctxNewCol(col, colState, address),
|
||||
|
||||
getMptFn: proc(cCtx: CoreDbCtxRef, col: CoreDbColRef): CoreDbRc[CoreDbMptRef] =
|
||||
ctxGetMpt(AristoCoreDbCtxRef(cCtx), col),
|
||||
getMptFn: proc(col: CoreDbColRef): CoreDbRc[CoreDbMptRef] =
|
||||
ctxGetMpt(col),
|
||||
|
||||
getAccFn: proc(cCtx: CoreDbCtxRef, col: CoreDbColRef): CoreDbRc[CoreDbAccRef] =
|
||||
ctxGetAcc(AristoCoreDbCtxRef(cCtx), col),
|
||||
getAccFn: proc(col: CoreDbColRef): CoreDbRc[CoreDbAccRef] =
|
||||
ctxGetAcc(col),
|
||||
|
||||
forgetFn: proc(cCtx: CoreDbCtxRef) =
|
||||
ctxForget(AristoCoreDbCtxRef(cCtx)))
|
||||
forgetFn: proc() =
|
||||
ctxForget())
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Public handlers and helpers
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
{.push raises: [].}
|
||||
|
||||
import
|
||||
chronicles,
|
||||
eth/common,
|
||||
"../.."/[constants, errors],
|
||||
./base/[api_tracking, base_desc]
|
||||
|
@ -204,20 +205,13 @@ proc parent*[T: CoreDbKvtRef |
|
|||
##
|
||||
result = child.parent
|
||||
|
||||
proc backend*(dsc: CoreDbKvtRef): auto =
|
||||
proc backend*(dsc: CoreDbKvtRef | CoreDbMptRef): auto =
|
||||
## Getter, retrieves the *raw* backend object for special/localised support.
|
||||
##
|
||||
dsc.setTrackNewApi AnyBackendFn
|
||||
result = dsc.methods.backendFn()
|
||||
dsc.ifTrackNewApi: debug newApiTxt, api, elapsed
|
||||
|
||||
proc backend*(mpt: CoreDbMptRef): auto =
|
||||
## Getter, retrieves the *raw* backend object for special/localised support.
|
||||
##
|
||||
mpt.setTrackNewApi AnyBackendFn
|
||||
result = mpt.methods.backendFn(mpt)
|
||||
mpt.ifTrackNewApi: debug newApiTxt, api, elapsed
|
||||
|
||||
proc finish*(db: CoreDbRef; eradicate = false) =
|
||||
## Database destructor. If the argument `eradicate` is set `false`, the
|
||||
## database is left as-is and only the in-memory handlers are cleaned up.
|
||||
|
@ -343,7 +337,7 @@ proc forget*(ctx: CoreDbCtxRef) =
|
|||
## context. This function fails if `ctx` is the default context.
|
||||
##
|
||||
ctx.setTrackNewApi CtxForgetFn
|
||||
ctx.methods.forgetFn(ctx)
|
||||
ctx.methods.forgetFn()
|
||||
ctx.ifTrackNewApi: debug newApiTxt, api, elapsed
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -387,7 +381,7 @@ proc newColumn*(
|
|||
## db.getAcc col
|
||||
##
|
||||
ctx.setTrackNewApi CtxNewColFn
|
||||
result = ctx.methods.newColFn(ctx, colType, colState, address)
|
||||
result = ctx.methods.newColFn(colType, colState, address)
|
||||
ctx.ifTrackNewApi:
|
||||
debug newApiTxt, api, elapsed, colType, colState, address, result
|
||||
|
||||
|
@ -399,7 +393,7 @@ proc newColumn*(
|
|||
## Shortcut for `ctx.newColumn(CtStorage,colState,some(address))`.
|
||||
##
|
||||
ctx.setTrackNewApi CtxNewColFn
|
||||
result = ctx.methods.newColFn(ctx, CtStorage, colState, Opt.some(address))
|
||||
result = ctx.methods.newColFn(CtStorage, colState, Opt.some(address))
|
||||
ctx.ifTrackNewApi: debug newApiTxt, api, elapsed, colState, address, result
|
||||
|
||||
proc newColumn*(
|
||||
|
@ -412,7 +406,7 @@ proc newColumn*(
|
|||
##
|
||||
ctx.setTrackNewApi CtxNewColFn
|
||||
result = ctx.methods.newColFn(
|
||||
ctx, CtStorage, EMPTY_ROOT_HASH, Opt.some(address)).valueOr:
|
||||
CtStorage, EMPTY_ROOT_HASH, Opt.some(address)).valueOr:
|
||||
raiseAssert error.prettyText()
|
||||
ctx.ifTrackNewApi: debug newApiTxt, api, elapsed, address, result
|
||||
|
||||
|
@ -480,7 +474,7 @@ proc getMpt*(
|
|||
## function `getColumn()`.
|
||||
##
|
||||
ctx.setTrackNewApi CtxGetMptFn
|
||||
result = ctx.methods.getMptFn(ctx, col)
|
||||
result = ctx.methods.getMptFn col
|
||||
ctx.ifTrackNewApi: debug newApiTxt, api, elapsed, col, result
|
||||
|
||||
proc getMpt*(
|
||||
|
@ -493,8 +487,8 @@ proc getMpt*(
|
|||
## return a non-nil descriptor or throw an exception.
|
||||
##
|
||||
ctx.setTrackNewApi CtxGetMptFn
|
||||
let col = ctx.methods.newColFn(ctx, colType, EMPTY_ROOT_HASH, address).value
|
||||
result = ctx.methods.getMptFn(ctx, col).valueOr:
|
||||
let col = ctx.methods.newColFn(colType, EMPTY_ROOT_HASH, address).value
|
||||
result = ctx.methods.getMptFn(col).valueOr:
|
||||
raiseAssert error.prettyText()
|
||||
ctx.ifTrackNewApi: debug newApiTxt, api, colType, elapsed
|
||||
|
||||
|
@ -506,7 +500,7 @@ proc getMpt*(acc: CoreDbAccRef): CoreDbMptRef =
|
|||
## argument.
|
||||
##
|
||||
acc.setTrackNewApi AccToMptFn
|
||||
result = acc.methods.getMptFn(acc).valueOr:
|
||||
result = acc.methods.getMptFn().valueOr:
|
||||
raiseAssert error.prettyText()
|
||||
acc.ifTrackNewApi:
|
||||
let colState = result.methods.getColFn()
|
||||
|
@ -532,7 +526,7 @@ proc getAcc*(
|
|||
## This function works similar to `getMpt()` for handling accounts.
|
||||
##
|
||||
ctx.setTrackNewApi CtxGetAccFn
|
||||
result = ctx.methods.getAccFn(ctx, col)
|
||||
result = ctx.methods.getAccFn col
|
||||
ctx.ifTrackNewApi: debug newApiTxt, api, elapsed, col, result
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -543,14 +537,14 @@ proc getColumn*(acc: CoreDbAccRef): CoreDbColRef =
|
|||
## Getter, result is not `nil`
|
||||
##
|
||||
acc.setTrackNewApi AccGetColFn
|
||||
result = acc.methods.getColFn(acc)
|
||||
result = acc.methods.getColFn()
|
||||
acc.ifTrackNewApi: debug newApiTxt, api, elapsed, result
|
||||
|
||||
proc getColumn*(mpt: CoreDbMptRef): CoreDbColRef =
|
||||
## Variant of `getColumn()`
|
||||
##
|
||||
mpt.setTrackNewApi MptGetColFn
|
||||
result = mpt.methods.getColFn(mpt)
|
||||
result = mpt.methods.getColFn()
|
||||
mpt.ifTrackNewApi: debug newApiTxt, api, elapsed, result
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -562,9 +556,9 @@ proc fetch*(mpt: CoreDbMptRef; key: openArray[byte]): CoreDbRc[Blob] =
|
|||
## non-empty `Blob` or an error code.
|
||||
##
|
||||
mpt.setTrackNewApi MptFetchFn
|
||||
result = mpt.methods.fetchFn(mpt, key)
|
||||
result = mpt.methods.fetchFn key
|
||||
mpt.ifTrackNewApi:
|
||||
let col = mpt.methods.getColFn(mpt)
|
||||
let col = mpt.methods.getColFn()
|
||||
debug newApiTxt, api, elapsed, col, key=key.toStr, result
|
||||
|
||||
proc fetchOrEmpty*(mpt: CoreDbMptRef; key: openArray[byte]): CoreDbRc[Blob] =
|
||||
|
@ -572,16 +566,16 @@ proc fetchOrEmpty*(mpt: CoreDbMptRef; key: openArray[byte]): CoreDbRc[Blob] =
|
|||
## on the database.
|
||||
##
|
||||
mpt.setTrackNewApi MptFetchOrEmptyFn
|
||||
result = mpt.methods.fetchFn(mpt, key)
|
||||
result = mpt.methods.fetchFn key
|
||||
if result.isErr and result.error.error == MptNotFound:
|
||||
result = CoreDbRc[Blob].ok(EmptyBlob)
|
||||
mpt.ifTrackNewApi:
|
||||
let col = mpt.methods.getColFn(mpt)
|
||||
let col = mpt.methods.getColFn()
|
||||
debug newApiTxt, api, elapsed, col, key=key.toStr, result
|
||||
|
||||
proc delete*(mpt: CoreDbMptRef; key: openArray[byte]): CoreDbRc[void] =
|
||||
mpt.setTrackNewApi MptDeleteFn
|
||||
result = mpt.methods.deleteFn(mpt, key)
|
||||
result = mpt.methods.deleteFn key
|
||||
mpt.ifTrackNewApi:
|
||||
let col = mpt.methods.getColFn()
|
||||
debug newApiTxt, api, elapsed, col, key=key.toStr, result
|
||||
|
@ -592,9 +586,9 @@ proc merge*(
|
|||
val: openArray[byte];
|
||||
): CoreDbRc[void] =
|
||||
mpt.setTrackNewApi MptMergeFn
|
||||
result = mpt.methods.mergeFn(mpt, key, val)
|
||||
result = mpt.methods.mergeFn(key, val)
|
||||
mpt.ifTrackNewApi:
|
||||
let col = mpt.methods.getColFn(mpt)
|
||||
let col = mpt.methods.getColFn()
|
||||
debug newApiTxt, api, elapsed, col, key=key.toStr, val=val.toLenStr, result
|
||||
|
||||
proc hasPath*(mpt: CoreDbMptRef; key: openArray[byte]): CoreDbRc[bool] =
|
||||
|
@ -602,9 +596,9 @@ proc hasPath*(mpt: CoreDbMptRef; key: openArray[byte]): CoreDbRc[bool] =
|
|||
## than a `Result[]`.
|
||||
##
|
||||
mpt.setTrackNewApi MptHasPathFn
|
||||
result = mpt.methods.hasPathFn(mpt, key)
|
||||
result = mpt.methods.hasPathFn key
|
||||
mpt.ifTrackNewApi:
|
||||
let col = mpt.methods.getColFn(mpt)
|
||||
let col = mpt.methods.getColFn()
|
||||
debug newApiTxt, api, elapsed, col, key=key.toStr, result
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -615,7 +609,7 @@ proc fetch*(acc: CoreDbAccRef; address: EthAddress): CoreDbRc[CoreDbAccount] =
|
|||
## Fetch data from the argument `acc`.
|
||||
##
|
||||
acc.setTrackNewApi AccFetchFn
|
||||
result = acc.methods.fetchFn(acc, address)
|
||||
result = acc.methods.fetchFn address
|
||||
acc.ifTrackNewApi:
|
||||
let storage = if result.isErr: "n/a" else: result.value.storage.prettyText()
|
||||
debug newApiTxt, api, elapsed, address, storage, result
|
||||
|
@ -623,7 +617,7 @@ proc fetch*(acc: CoreDbAccRef; address: EthAddress): CoreDbRc[CoreDbAccount] =
|
|||
|
||||
proc delete*(acc: CoreDbAccRef; address: EthAddress): CoreDbRc[void] =
|
||||
acc.setTrackNewApi AccDeleteFn
|
||||
result = acc.methods.deleteFn(acc, address)
|
||||
result = acc.methods.deleteFn address
|
||||
acc.ifTrackNewApi: debug newApiTxt, api, elapsed, address, result
|
||||
|
||||
proc stoDelete*(acc: CoreDbAccRef; address: EthAddress): CoreDbRc[void] =
|
||||
|
@ -638,7 +632,7 @@ proc stoDelete*(acc: CoreDbAccRef; address: EthAddress): CoreDbRc[void] =
|
|||
## backend.
|
||||
##
|
||||
acc.setTrackNewApi AccStoDeleteFn
|
||||
result = acc.methods.stoDeleteFn(acc, address)
|
||||
result = acc.methods.stoDeleteFn address
|
||||
acc.ifTrackNewApi: debug newApiTxt, api, elapsed, address, result
|
||||
|
||||
|
||||
|
@ -647,7 +641,7 @@ proc merge*(
|
|||
account: CoreDbAccount;
|
||||
): CoreDbRc[void] =
|
||||
acc.setTrackNewApi AccMergeFn
|
||||
result = acc.methods.mergeFn(acc, account)
|
||||
result = acc.methods.mergeFn account
|
||||
acc.ifTrackNewApi:
|
||||
let address = account.address
|
||||
debug newApiTxt, api, elapsed, address, result
|
||||
|
@ -657,7 +651,7 @@ proc hasPath*(acc: CoreDbAccRef; address: EthAddress): CoreDbRc[bool] =
|
|||
## Would be named `contains` if it returned `bool` rather than `Result[]`.
|
||||
##
|
||||
acc.setTrackNewApi AccHasPathFn
|
||||
result = acc.methods.hasPathFn(acc, address)
|
||||
result = acc.methods.hasPathFn address
|
||||
acc.ifTrackNewApi: debug newApiTxt, api, elapsed, address, result
|
||||
|
||||
|
||||
|
|
|
@ -160,14 +160,16 @@ type
|
|||
# --------------------------------------------------
|
||||
# Sub-descriptor: MPT context methods
|
||||
# --------------------------------------------------
|
||||
CoreDbCtxFromTxFn* =
|
||||
proc(root: Hash256; kind: CoreDbColType): CoreDbRc[CoreDbCtxRef] {.noRaise.}
|
||||
CoreDbCtxNewColFn* = proc(
|
||||
cCtx: CoreDbCtxRef; colType: CoreDbColType; colState: Hash256; address: Opt[EthAddress];
|
||||
colType: CoreDbColType; colState: Hash256; address: Opt[EthAddress];
|
||||
): CoreDbRc[CoreDbColRef] {.noRaise.}
|
||||
CoreDbCtxGetMptFn* = proc(
|
||||
cCtx: CoreDbCtxRef; root: CoreDbColRef): CoreDbRc[CoreDbMptRef] {.noRaise.}
|
||||
root: CoreDbColRef): CoreDbRc[CoreDbMptRef] {.noRaise.}
|
||||
CoreDbCtxGetAccFn* = proc(
|
||||
cCtx: CoreDbCtxRef; root: CoreDbColRef): CoreDbRc[CoreDbAccRef] {.noRaise.}
|
||||
CoreDbCtxForgetFn* = proc(cCtx: CoreDbCtxRef) {.noRaise.}
|
||||
root: CoreDbColRef): CoreDbRc[CoreDbAccRef] {.noRaise.}
|
||||
CoreDbCtxForgetFn* = proc() {.noRaise.}
|
||||
|
||||
CoreDbCtxFns* = object
|
||||
## Methods for context maniulation
|
||||
|
@ -179,20 +181,20 @@ type
|
|||
# --------------------------------------------------
|
||||
# Sub-descriptor: generic Mpt/hexary trie methods
|
||||
# --------------------------------------------------
|
||||
CoreDbMptBackendFn* = proc(cMpt: CoreDbMptRef): CoreDbMptBackendRef {.noRaise.}
|
||||
CoreDbMptBackendFn* = proc(): CoreDbMptBackendRef {.noRaise.}
|
||||
CoreDbMptFetchFn* =
|
||||
proc(cMpt: CoreDbMptRef, k: openArray[byte]): CoreDbRc[Blob] {.noRaise.}
|
||||
proc(k: openArray[byte]): CoreDbRc[Blob] {.noRaise.}
|
||||
CoreDbMptFetchAccountFn* =
|
||||
proc(cMpt: CoreDbMptRef, k: openArray[byte]): CoreDbRc[CoreDbAccount] {.noRaise.}
|
||||
proc(k: openArray[byte]): CoreDbRc[CoreDbAccount] {.noRaise.}
|
||||
CoreDbMptDeleteFn* =
|
||||
proc(cMpt: CoreDbMptRef, k: openArray[byte]): CoreDbRc[void] {.noRaise.}
|
||||
proc(k: openArray[byte]): CoreDbRc[void] {.noRaise.}
|
||||
CoreDbMptMergeFn* =
|
||||
proc(cMpt: CoreDbMptRef, k: openArray[byte]; v: openArray[byte]): CoreDbRc[void] {.noRaise.}
|
||||
proc(k: openArray[byte]; v: openArray[byte]): CoreDbRc[void] {.noRaise.}
|
||||
CoreDbMptMergeAccountFn* =
|
||||
proc(cMpt: CoreDbMptRef, k: openArray[byte]; v: CoreDbAccount): CoreDbRc[void] {.noRaise.}
|
||||
CoreDbMptHasPathFn* = proc(cMpt: CoreDbMptRef, k: openArray[byte]): CoreDbRc[bool] {.noRaise.}
|
||||
CoreDbMptGetColFn* = proc(cMpt: CoreDbMptRef): CoreDbColRef {.noRaise.}
|
||||
CoreDbMptForgetFn* = proc(cMpt: CoreDbMptRef): CoreDbRc[void] {.noRaise.}
|
||||
proc(k: openArray[byte]; v: CoreDbAccount): CoreDbRc[void] {.noRaise.}
|
||||
CoreDbMptHasPathFn* = proc(k: openArray[byte]): CoreDbRc[bool] {.noRaise.}
|
||||
CoreDbMptGetColFn* = proc(): CoreDbColRef {.noRaise.}
|
||||
CoreDbMptForgetFn* = proc(): CoreDbRc[void] {.noRaise.}
|
||||
|
||||
CoreDbMptFns* = object
|
||||
## Methods for trie objects
|
||||
|
@ -207,13 +209,14 @@ type
|
|||
# ----------------------------------------------------
|
||||
# Sub-descriptor: Mpt/hexary trie methods for accounts
|
||||
# ------------------------------------------------------
|
||||
CoreDbAccGetMptFn* = proc(cAcc: CoreDbAccRef): CoreDbRc[CoreDbMptRef] {.noRaise.}
|
||||
CoreDbAccFetchFn* = proc(cAcc: CoreDbAccRef, k: EthAddress): CoreDbRc[CoreDbAccount] {.noRaise.}
|
||||
CoreDbAccDeleteFn* = proc(cAcc: CoreDbAccRef, k: EthAddress): CoreDbRc[void] {.noRaise.}
|
||||
CoreDbAccStoDeleteFn* = proc(cAcc: CoreDbAccRef,k: EthAddress): CoreDbRc[void] {.noRaise.}
|
||||
CoreDbAccMergeFn* = proc(cAcc: CoreDbAccRef, v: CoreDbAccount): CoreDbRc[void] {.noRaise.}
|
||||
CoreDbAccHasPathFn* = proc(cAcc: CoreDbAccRef, k: EthAddress): CoreDbRc[bool] {.noRaise.}
|
||||
CoreDbAccGetColFn* = proc(cAcc: CoreDbAccRef): CoreDbColRef {.noRaise.}
|
||||
CoreDbAccGetMptFn* = proc(): CoreDbRc[CoreDbMptRef] {.noRaise.}
|
||||
CoreDbAccFetchFn* = proc(k: EthAddress): CoreDbRc[CoreDbAccount] {.noRaise.}
|
||||
CoreDbAccDeleteFn* = proc(k: EthAddress): CoreDbRc[void] {.noRaise.}
|
||||
CoreDbAccStoDeleteFn* = proc(k: EthAddress): CoreDbRc[void] {.noRaise.}
|
||||
CoreDbAccMergeFn* = proc(v: CoreDbAccount): CoreDbRc[void] {.noRaise.}
|
||||
CoreDbAccHasPathFn* = proc(k: EthAddress): CoreDbRc[bool] {.noRaise.}
|
||||
CoreDbAccGetColFn* = proc(): CoreDbColRef {.noRaise.}
|
||||
CoreDbAccForgetFn* = proc(): CoreDbRc[void] {.noRaise.}
|
||||
|
||||
CoreDbAccFns* = object
|
||||
## Methods for trie objects
|
||||
|
|
|
@ -97,7 +97,7 @@ const
|
|||
#
|
||||
# to pick right function when <op> is a variable . Using
|
||||
#
|
||||
# VmOpHandlers[fork][op].exec
|
||||
# VmOpHandlers[fork][op].exec.run
|
||||
#
|
||||
# only works when <op> is a constant. There seems to be some optimisation
|
||||
# that garbles the <exec> sub-structures elements <prep>, <run>, and <post>.
|
||||
|
@ -113,7 +113,7 @@ const
|
|||
for op in Op:
|
||||
rc[fork][op].name = tab[op].name
|
||||
rc[fork][op].info = tab[op].info
|
||||
rc[fork][op].run = tab[op].exec
|
||||
rc[fork][op].run = tab[op].exec.run
|
||||
rc
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -290,157 +290,179 @@ const
|
|||
forks: VmOpAllForks,
|
||||
name: "add",
|
||||
info: "Addition operation",
|
||||
exec: VmOpFn addOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: VmOpFn addOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Mul, ## 0x02, Multiplication
|
||||
forks: VmOpAllForks,
|
||||
name: "mul",
|
||||
info: "Multiplication operation",
|
||||
exec: mulOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: mulOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Sub, ## 0x03, Subtraction
|
||||
forks: VmOpAllForks,
|
||||
name: "sub",
|
||||
info: "Subtraction operation",
|
||||
exec: subOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: subOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Div, ## 0x04, Division
|
||||
forks: VmOpAllForks,
|
||||
name: "divide",
|
||||
info: "Integer division operation",
|
||||
exec: divideOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: divideOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Sdiv, ## 0x05, Signed division
|
||||
forks: VmOpAllForks,
|
||||
name: "sdiv",
|
||||
info: "Signed integer division operation (truncated)",
|
||||
exec: sdivOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: sdivOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Mod, ## 0x06, Modulo
|
||||
forks: VmOpAllForks,
|
||||
name: "modulo",
|
||||
info: "Modulo remainder operation",
|
||||
exec: moduloOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: moduloOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Smod, ## 0x07, Signed modulo
|
||||
forks: VmOpAllForks,
|
||||
name: "smod",
|
||||
info: "Signed modulo remainder operation",
|
||||
exec: smodOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: smodOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Addmod, ## 0x08, Modulo addition, Intermediate
|
||||
## computations do not roll over at 2^256
|
||||
forks: VmOpAllForks,
|
||||
name: "addmod",
|
||||
info: "Modulo addition operation",
|
||||
exec: addmodOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: addmodOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Mulmod, ## 0x09, Modulo multiplication, Intermediate
|
||||
## computations do not roll over at 2^256
|
||||
forks: VmOpAllForks,
|
||||
name: "mulmod",
|
||||
info: "Modulo multiplication operation",
|
||||
exec: mulmodOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: mulmodOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Exp, ## 0x0a, Exponentiation
|
||||
forks: VmOpAllForks,
|
||||
name: "exp",
|
||||
info: "Exponentiation operation",
|
||||
exec: expOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: expOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: SignExtend, ## 0x0b, Extend 2's complemet length
|
||||
forks: VmOpAllForks,
|
||||
name: "signExtend",
|
||||
info: "Extend length of two’s complement signed integer",
|
||||
exec: signExtendOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: signExtendOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Lt, ## 0x10, Less-than
|
||||
forks: VmOpAllForks,
|
||||
name: "lt",
|
||||
info: "Less-than comparison",
|
||||
exec: ltOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: ltOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Gt, ## 0x11, Greater-than
|
||||
forks: VmOpAllForks,
|
||||
name: "gt",
|
||||
info: "Greater-than comparison",
|
||||
exec: gtOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: gtOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Slt, ## 0x12, Signed less-than
|
||||
forks: VmOpAllForks,
|
||||
name: "slt",
|
||||
info: "Signed less-than comparison",
|
||||
exec: sltOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: sltOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Sgt, ## 0x13, Signed greater-than
|
||||
forks: VmOpAllForks,
|
||||
name: "sgt",
|
||||
info: "Signed greater-than comparison",
|
||||
exec: sgtOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: sgtOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Eq, ## 0x14, Equality
|
||||
forks: VmOpAllForks,
|
||||
name: "eq",
|
||||
info: "Equality comparison",
|
||||
exec: eqOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: eqOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: IsZero, ## 0x15, Not operator
|
||||
forks: VmOpAllForks,
|
||||
name: "isZero",
|
||||
info: "Simple not operator (Note: real Yellow Paper description)",
|
||||
exec: isZeroOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: isZeroOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: And, ## 0x16, AND
|
||||
forks: VmOpAllForks,
|
||||
name: "andOp",
|
||||
info: "Bitwise AND operation",
|
||||
exec: andOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: andOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Or, ## 0x17, OR
|
||||
forks: VmOpAllForks,
|
||||
name: "orOp",
|
||||
info: "Bitwise OR operation",
|
||||
exec: orOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: orOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Xor, ## 0x18, XOR
|
||||
forks: VmOpAllForks,
|
||||
name: "xorOp",
|
||||
info: "Bitwise XOR operation",
|
||||
exec: xorOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: xorOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Not, ## 0x19, NOT
|
||||
forks: VmOpAllForks,
|
||||
name: "notOp",
|
||||
info: "Bitwise NOT operation",
|
||||
exec: notOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: notOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Byte, ## 0x1a, Retrieve byte
|
||||
forks: VmOpAllForks,
|
||||
name: "byteOp",
|
||||
info: "Retrieve single byte from word",
|
||||
exec: byteOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: byteOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
# Constantinople's new opcodes
|
||||
|
||||
|
@ -448,21 +470,25 @@ const
|
|||
forks: VmOpConstantinopleAndLater,
|
||||
name: "shlOp",
|
||||
info: "Shift left",
|
||||
exec: shlOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: shlOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Shr, ## 0x1c, Shift right logical
|
||||
forks: VmOpConstantinopleAndLater,
|
||||
name: "shrOp",
|
||||
info: "Logical shift right",
|
||||
exec: shrOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: shrOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Sar, ## 0x1d, Shift right arithmetic
|
||||
forks: VmOpConstantinopleAndLater,
|
||||
name: "sarOp",
|
||||
info: "Arithmetic shift right",
|
||||
exec: sarOp)]
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: sarOp,
|
||||
post: VmOpIgnore))]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# End
|
||||
|
|
|
@ -100,77 +100,89 @@ const
|
|||
forks: VmOpAllForks,
|
||||
name: "blockhash",
|
||||
info: "Get the hash of one of the 256 most recent complete blocks",
|
||||
exec: blockhashOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: blockhashOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Coinbase, ## 0x41, Beneficiary address
|
||||
forks: VmOpAllForks,
|
||||
name: "coinbase",
|
||||
info: "Get the block's beneficiary address",
|
||||
exec: coinBaseOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: coinBaseOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Timestamp, ## 0x42, Block timestamp.
|
||||
forks: VmOpAllForks,
|
||||
name: "timestamp",
|
||||
info: "Get the block's timestamp",
|
||||
exec: timestampOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: timestampOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Number, ## 0x43, Block number
|
||||
forks: VmOpAllForks,
|
||||
name: "blockNumber",
|
||||
info: "Get the block's number",
|
||||
exec: blocknumberOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: blocknumberOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Difficulty, ## 0x44, Block difficulty
|
||||
forks: VmOpAllForks,
|
||||
name: "difficulty",
|
||||
info: "Get the block's difficulty",
|
||||
exec: difficultyOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: difficultyOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: GasLimit, ## 0x45, Block gas limit
|
||||
forks: VmOpAllForks,
|
||||
name: "gasLimit",
|
||||
info: "Get the block's gas limit",
|
||||
exec: gasLimitOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: gasLimitOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: ChainIdOp, ## 0x46, EIP-155 chain identifier
|
||||
forks: VmOpIstanbulAndLater,
|
||||
name: "chainId",
|
||||
info: "Get current chain’s EIP-155 unique identifier",
|
||||
exec: chainIdOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: chainIdOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: SelfBalance, ## 0x47, Contract balance.
|
||||
forks: VmOpIstanbulAndLater,
|
||||
name: "selfBalance",
|
||||
info: "Get current contract's balance",
|
||||
exec: selfBalanceOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: selfBalanceOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: BaseFee, ## 0x48, EIP-1559 Block base fee.
|
||||
forks: VmOpLondonAndLater,
|
||||
name: "baseFee",
|
||||
info: "Get current block's EIP-1559 base fee",
|
||||
exec: baseFeeOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: baseFeeOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: BlobHash, ## 0x49, EIP-4844 Transaction versioned hash
|
||||
forks: VmOpCancunAndLater,
|
||||
name: "blobHash",
|
||||
info: "Get current transaction's EIP-4844 versioned hash",
|
||||
exec: blobHashOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: blobHashOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: BlobBaseFee, ## 0x4a, EIP-7516 Returns the current data-blob base-fee
|
||||
forks: VmOpCancunAndLater,
|
||||
name: "blobBaseFee",
|
||||
info: "Returns the current data-blob base-fee",
|
||||
exec: blobBaseFeeOp)]
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: blobBaseFeeOp,
|
||||
post: VmOpIgnore))]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# End
|
||||
|
|
|
@ -514,29 +514,34 @@ const
|
|||
forks: VmOpAllForks,
|
||||
name: "call",
|
||||
info: "Message-Call into an account",
|
||||
exec: callOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: callOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: CallCode, ## 0xf2, Message-Call with alternative code
|
||||
forks: VmOpAllForks,
|
||||
name: "callCode",
|
||||
info: "Message-call into this account with alternative account's code",
|
||||
exec: callCodeOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: callCodeOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: DelegateCall, ## 0xf4, CallCode with persisting sender and value
|
||||
forks: VmOpHomesteadAndLater,
|
||||
name: "delegateCall",
|
||||
info: "Message-call into this account with an alternative account's " &
|
||||
"code but persisting the current values for sender and value.",
|
||||
exec: delegateCallOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: delegateCallOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: StaticCall, ## 0xfa, Static message-call into an account
|
||||
forks: VmOpByzantiumAndLater,
|
||||
name: "staticCall",
|
||||
info: "Static message-call into an account",
|
||||
exec: staticCallOp)]
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: staticCallOp,
|
||||
post: VmOpIgnore))]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# End
|
||||
|
|
|
@ -255,14 +255,17 @@ const
|
|||
forks: VmOpAllForks,
|
||||
name: "create",
|
||||
info: "Create a new account with associated code",
|
||||
exec: createOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: createOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Create2, ## 0xf5, Create using keccak256
|
||||
forks: VmOpConstantinopleAndLater,
|
||||
name: "create2",
|
||||
info: "Behaves identically to CREATE, except using keccak256",
|
||||
exec: create2Op)]
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: create2Op,
|
||||
post: VmOpIgnore))]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# End
|
||||
|
|
|
@ -28,12 +28,20 @@ type
|
|||
## back via argument descriptor ``k``
|
||||
proc(k: var VmCtx): EvmResultVoid {.nimcall, gcsafe, raises:[].}
|
||||
|
||||
|
||||
VmOpHanders* = tuple ## three step op code execution, typically
|
||||
## only the ``run`` entry is activated
|
||||
prep: VmOpFn
|
||||
run: VmOpFn
|
||||
post: VmOpFn
|
||||
|
||||
|
||||
VmOpExec* = tuple ## op code handler entry
|
||||
opCode: Op ## index back-reference
|
||||
forks: set[EVMFork] ## forks applicable for this operation
|
||||
name: string ## handler name
|
||||
info: string ## handter info, explainer
|
||||
exec: VmOpFn
|
||||
exec: VmOpHanders
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Public
|
||||
|
|
|
@ -253,142 +253,163 @@ const
|
|||
forks: VmOpAllForks,
|
||||
name: "address",
|
||||
info: "Get address of currently executing account",
|
||||
exec: VmOpFn addressOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: VmOpFn addressOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Balance, ## 0x31, Balance
|
||||
forks: VmOpAllForks - VmOpBerlinAndLater,
|
||||
name: "balance",
|
||||
info: "Get balance of the given account",
|
||||
exec: balanceOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: balanceOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Balance, ## 0x31, Balance for Berlin and later
|
||||
forks: VmOpBerlinAndLater,
|
||||
name: "balanceEIP2929",
|
||||
info: "EIP2929: Get balance of the given account",
|
||||
exec: balanceEIP2929Op),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: balanceEIP2929Op,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Origin, ## 0x32, Origination address
|
||||
forks: VmOpAllForks,
|
||||
name: "origin",
|
||||
info: "Get execution origination address",
|
||||
exec: originOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: originOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Caller, ## 0x33, Caller address
|
||||
forks: VmOpAllForks,
|
||||
name: "caller",
|
||||
info: "Get caller address",
|
||||
exec: callerOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: callerOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: CallValue, ## 0x34, Execution deposited value
|
||||
forks: VmOpAllForks,
|
||||
name: "callValue",
|
||||
info: "Get deposited value by the instruction/transaction " &
|
||||
"responsible for this execution",
|
||||
exec: callValueOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: callValueOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: CallDataLoad, ## 0x35, Input data
|
||||
forks: VmOpAllForks,
|
||||
name: "callDataLoad",
|
||||
info: "Get input data of current environment",
|
||||
exec: callDataLoadOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: callDataLoadOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: CallDataSize, ## 0x36, Size of input data
|
||||
forks: VmOpAllForks,
|
||||
name: "callDataSize",
|
||||
info: "Get size of input data in current environment",
|
||||
exec: callDataSizeOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: callDataSizeOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: CallDataCopy, ## 0x37, Copy input data to memory.
|
||||
forks: VmOpAllForks,
|
||||
name: "callDataCopy",
|
||||
info: "Copy input data in current environment to memory",
|
||||
exec: callDataCopyOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: callDataCopyOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: CodeSize, ## 0x38, Size of code
|
||||
forks: VmOpAllForks,
|
||||
name: "codeSize",
|
||||
info: "Get size of code running in current environment",
|
||||
exec: codeSizeOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: codeSizeOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: CodeCopy, ## 0x39, Copy code to memory.
|
||||
forks: VmOpAllForks,
|
||||
name: "codeCopy",
|
||||
info: "Copy code running in current environment to memory",
|
||||
exec: codeCopyOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: codeCopyOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: GasPrice, ## 0x3a, Gas price
|
||||
forks: VmOpAllForks,
|
||||
name: "gasPrice",
|
||||
info: "Get price of gas in current environment",
|
||||
exec: gasPriceOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: gasPriceOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: ExtCodeSize, ## 0x3b, Account code size
|
||||
forks: VmOpAllForks - VmOpBerlinAndLater,
|
||||
name: "extCodeSize",
|
||||
info: "Get size of an account's code",
|
||||
exec: extCodeSizeOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: extCodeSizeOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: ExtCodeSize, ## 0x3b, Account code size for Berlin and later
|
||||
forks: VmOpBerlinAndLater,
|
||||
name: "extCodeSizeEIP2929",
|
||||
info: "EIP2929: Get size of an account's code",
|
||||
exec: extCodeSizeEIP2929Op),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: extCodeSizeEIP2929Op,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: ExtCodeCopy, ## 0x3c, Account code copy to memory.
|
||||
forks: VmOpAllForks - VmOpBerlinAndLater,
|
||||
name: "extCodeCopy",
|
||||
info: "Copy an account's code to memory",
|
||||
exec: extCodeCopyOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: extCodeCopyOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: ExtCodeCopy, ## 0x3c, Account Code-copy for Berlin and later
|
||||
forks: VmOpBerlinAndLater,
|
||||
name: "extCodeCopyEIP2929",
|
||||
info: "EIP2929: Copy an account's code to memory",
|
||||
exec: extCodeCopyEIP2929Op),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: extCodeCopyEIP2929Op,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: ReturnDataSize, ## 0x3d, Previous call output data size
|
||||
forks: VmOpByzantiumAndLater,
|
||||
name: "returnDataSize",
|
||||
info: "Get size of output data from the previous call " &
|
||||
"from the current environment",
|
||||
exec: returnDataSizeOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: returnDataSizeOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: ReturnDataCopy, ## 0x3e, Previous call output data copy to memory
|
||||
forks: VmOpByzantiumAndLater,
|
||||
name: "returnDataCopy",
|
||||
info: "Copy output data from the previous call to memory",
|
||||
exec: returnDataCopyOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: returnDataCopyOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: ExtCodeHash, ## 0x3f, Contract hash
|
||||
forks: VmOpConstantinopleAndLater - VmOpBerlinAndLater,
|
||||
name: "extCodeHash",
|
||||
info: "Returns the keccak256 hash of a contract’s code",
|
||||
exec: extCodeHashOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: extCodeHashOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: ExtCodeHash, ## 0x3f, Contract hash for berlin and later
|
||||
forks: VmOpBerlinAndLater,
|
||||
name: "extCodeHashEIP2929",
|
||||
info: "EIP2929: Returns the keccak256 hash of a contract’s code",
|
||||
exec: extCodeHashEIP2929Op)]
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: extCodeHashEIP2929Op,
|
||||
post: VmOpIgnore))]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# End
|
||||
|
|
|
@ -99,7 +99,10 @@ macro genOphList*(runHandler: static[OphNumToTextFn];
|
|||
"info".asText(n.handlerInfo),
|
||||
nnkExprColonExpr.newTree(
|
||||
newIdentNode("exec"),
|
||||
newIdentNode(n.runHandler)))
|
||||
nnkPar.newTree(
|
||||
"prep".asIdent("VmOpIgnore"),
|
||||
"run".asIdent(n.runHandler),
|
||||
"post".asIdent("VmOpIgnore"))))
|
||||
|
||||
# => const <varName>*: seq[VmOpExec] = @[ <records> ]
|
||||
result = nnkStmtList.newTree(
|
||||
|
|
|
@ -62,7 +62,9 @@ const
|
|||
forks: VmOpAllForks,
|
||||
name: "sha3",
|
||||
info: "Compute Keccak-256 hash",
|
||||
exec: sha3Op)]
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: sha3Op,
|
||||
post: VmOpIgnore))]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# End
|
||||
|
|
|
@ -324,143 +324,164 @@ const
|
|||
forks: VmOpAllForks,
|
||||
name: "pop",
|
||||
info: "Remove item from stack",
|
||||
exec: VmOpFn popOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: VmOpFn popOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Mload, ## 0x51, Load word from memory
|
||||
forks: VmOpAllForks,
|
||||
name: "mload",
|
||||
info: "Load word from memory",
|
||||
exec: mloadOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: mloadOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Mstore, ## 0x52, Save word to memory
|
||||
forks: VmOpAllForks,
|
||||
name: "mstore",
|
||||
info: "Save word to memory",
|
||||
exec: mstoreOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: mstoreOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Mstore8, ## 0x53, Save byte to memory
|
||||
forks: VmOpAllForks,
|
||||
name: "mstore8",
|
||||
info: "Save byte to memory",
|
||||
exec: mstore8Op),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: mstore8Op,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Sload, ## 0x54, Load word from storage
|
||||
forks: VmOpAllForks - VmOpBerlinAndLater,
|
||||
name: "sload",
|
||||
info: "Load word from storage",
|
||||
exec: sloadOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: sloadOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Sload, ## 0x54, sload for Berlin and later
|
||||
forks: VmOpBerlinAndLater,
|
||||
name: "sloadEIP2929",
|
||||
info: "EIP2929: sload for Berlin and later",
|
||||
exec: sloadEIP2929Op),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: sloadEIP2929Op,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Sstore, ## 0x55, Save word
|
||||
forks: VmOpAllForks - VmOpConstantinopleAndLater,
|
||||
name: "sstore",
|
||||
info: "Save word to storage",
|
||||
exec: sstoreOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: sstoreOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Sstore, ## 0x55, sstore for Constantinople and later
|
||||
forks: VmOpConstantinopleAndLater - VmOpPetersburgAndLater,
|
||||
name: "sstoreEIP1283",
|
||||
info: "EIP1283: sstore for Constantinople and later",
|
||||
exec: sstoreEIP1283Op),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: sstoreEIP1283Op,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Sstore, ## 0x55, sstore for Petersburg and later
|
||||
forks: VmOpPetersburgAndLater - VmOpIstanbulAndLater,
|
||||
name: "sstore",
|
||||
info: "sstore for Constantinople and later",
|
||||
exec: sstoreOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: sstoreOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Sstore, ## 0x55, sstore for Istanbul and later
|
||||
forks: VmOpIstanbulAndLater - VmOpBerlinAndLater,
|
||||
name: "sstoreEIP2200",
|
||||
info: "EIP2200: sstore for Istanbul and later",
|
||||
exec: sstoreEIP2200Op),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: sstoreEIP2200Op,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Sstore, ## 0x55, sstore for Berlin and later
|
||||
forks: VmOpBerlinAndLater,
|
||||
name: "sstoreEIP2929",
|
||||
info: "EIP2929: sstore for Istanbul and later",
|
||||
exec: sstoreEIP2929Op),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: sstoreEIP2929Op,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Jump, ## 0x56, Jump
|
||||
forks: VmOpAllForks,
|
||||
name: "jump",
|
||||
info: "Alter the program counter",
|
||||
exec: jumpOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: jumpOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: JumpI, ## 0x57, Conditional jump
|
||||
forks: VmOpAllForks,
|
||||
name: "jumpI",
|
||||
info: "Conditionally alter the program counter",
|
||||
exec: jumpIOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: jumpIOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Pc, ## 0x58, Program counter prior to instruction
|
||||
forks: VmOpAllForks,
|
||||
name: "pc",
|
||||
info: "Get the value of the program counter prior to the increment "&
|
||||
"corresponding to this instruction",
|
||||
exec: pcOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: pcOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Msize, ## 0x59, Memory size
|
||||
forks: VmOpAllForks,
|
||||
name: "msize",
|
||||
info: "Get the size of active memory in bytes",
|
||||
exec: msizeOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: msizeOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Gas, ## 0x5a, Get available gas
|
||||
forks: VmOpAllForks,
|
||||
name: "gas",
|
||||
info: "Get the amount of available gas, including the corresponding "&
|
||||
"reduction for the cost of this instruction",
|
||||
exec: gasOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: gasOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: JumpDest, ## 0x5b, Mark jump target. This operation has no effect
|
||||
## on machine state during execution
|
||||
forks: VmOpAllForks,
|
||||
name: "jumpDest",
|
||||
info: "Mark a valid destination for jumps",
|
||||
exec: jumpDestOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: jumpDestOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Tload, ## 0x5c, Load word from transient storage.
|
||||
forks: VmOpCancunAndLater,
|
||||
name: "tLoad",
|
||||
info: "Load word from transient storage",
|
||||
exec: tloadOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: tloadOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Tstore, ## 0x5d, Save word to transient storage.
|
||||
forks: VmOpCancunAndLater,
|
||||
name: "tStore",
|
||||
info: "Save word to transient storage",
|
||||
exec: tstoreOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: tstoreOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Mcopy, ## 0x5e, Copy memory
|
||||
forks: VmOpCancunAndLater,
|
||||
name: "MCopy",
|
||||
info: "Copy memory",
|
||||
exec: mCopyOp)]
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: mCopyOp,
|
||||
post: VmOpIgnore))]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# End
|
||||
|
|
|
@ -76,7 +76,9 @@ const
|
|||
forks: VmOpShanghaiAndLater,
|
||||
name: "Push0",
|
||||
info: "Push 0 on the stack",
|
||||
exec: push0Op)]
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: push0Op,
|
||||
post: VmOpIgnore))]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# End
|
||||
|
|
|
@ -164,50 +164,58 @@ const
|
|||
forks: VmOpAllForks,
|
||||
name: "returnOp",
|
||||
info: "Halt execution returning output data",
|
||||
exec: returnOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: returnOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Revert, ## 0xfd, Halt and revert state changes
|
||||
forks: VmOpByzantiumAndLater,
|
||||
name: "revert",
|
||||
info: "Halt execution reverting state changes but returning data " &
|
||||
"and remaining gas",
|
||||
exec: revertOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: revertOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: Invalid, ## 0xfe, invalid instruction.
|
||||
forks: VmOpAllForks,
|
||||
name: "invalidInstruction",
|
||||
info: "Designated invalid instruction",
|
||||
exec: invalidOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: invalidOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: SelfDestruct, ## 0xff, Halt execution, prep for later deletion
|
||||
forks: VmOpAllForks - VmOpTangerineAndLater,
|
||||
name: "selfDestruct",
|
||||
info: "Halt execution and register account for later deletion",
|
||||
exec: selfDestructOp),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: selfDestructOp,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: SelfDestruct, ## 0xff, EIP150: self destruct, Tangerine
|
||||
forks: VmOpTangerineAndLater - VmOpSpuriousAndLater,
|
||||
name: "selfDestructEIP150",
|
||||
info: "EIP150: Halt execution and register account for later deletion",
|
||||
exec: selfDestructEIP150Op),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: selfDestructEIP150Op,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: SelfDestruct, ## 0xff, EIP161: self destruct, Spurious and later
|
||||
forks: VmOpSpuriousAndLater - VmOpBerlinAndLater,
|
||||
name: "selfDestructEIP161",
|
||||
info: "EIP161: Halt execution and register account for later deletion",
|
||||
exec: selfDestructEIP161Op),
|
||||
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: selfDestructEIP161Op,
|
||||
post: VmOpIgnore)),
|
||||
|
||||
(opCode: SelfDestruct, ## 0xff, EIP2929: self destruct, Berlin and later
|
||||
forks: VmOpBerlinAndLater,
|
||||
name: "selfDestructEIP2929",
|
||||
info: "EIP2929: Halt execution and register account for later deletion",
|
||||
exec: selfDestructEIP2929Op)]
|
||||
exec: (prep: VmOpIgnore,
|
||||
run: selfDestructEIP2929Op,
|
||||
post: VmOpIgnore))]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# End
|
||||
|
|
|
@ -36,7 +36,6 @@ proc init(
|
|||
self.tracer = tracer
|
||||
self.stateDB = ac
|
||||
self.flags = flags
|
||||
self.blobGasUsed = 0'u64
|
||||
|
||||
func blockCtx(com: CommonRef, header: BlockHeader):
|
||||
BlockContext =
|
||||
|
|
|
@ -66,7 +66,6 @@ type
|
|||
receipts* : seq[Receipt]
|
||||
cumulativeGasUsed*: GasInt
|
||||
gasCosts* : GasCosts
|
||||
blobGasUsed* : uint64
|
||||
|
||||
Computation* = ref object
|
||||
# The execution computation
|
||||
|
|
|
@ -21,9 +21,6 @@ import
|
|||
./db/era1_db,
|
||||
beacon_chain/era_db
|
||||
|
||||
declareGauge nec_import_block_number,
|
||||
"Latest imported block number"
|
||||
|
||||
declareCounter nec_imported_blocks,
|
||||
"Blocks processed during import"
|
||||
|
||||
|
@ -108,8 +105,6 @@ proc importBlocks*(conf: NimbusConf, com: CommonRef) =
|
|||
if csv != nil:
|
||||
close(csv)
|
||||
|
||||
nec_import_block_number.set(start.int64)
|
||||
|
||||
template blockNumber(): uint64 =
|
||||
start + imported
|
||||
|
||||
|
@ -160,7 +155,6 @@ proc importBlocks*(conf: NimbusConf, com: CommonRef) =
|
|||
avgMGps = f(gas.float / 1000000 / diff0),
|
||||
elapsed = shortLog(time2 - time0, 3)
|
||||
|
||||
metrics.set(nec_import_block_number, int64(blockNumber))
|
||||
nec_imported_blocks.inc(blocks.len)
|
||||
nec_imported_transactions.inc(statsRes[].txs)
|
||||
nec_imported_gas.inc(statsRes[].gas)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Nimbus
|
||||
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
||||
# Copyright (c) 2022 Status Research & Development GmbH
|
||||
# Licensed under either of
|
||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
@ -569,15 +569,6 @@ const
|
|||
output: T8nOutput(trace: true, result: true),
|
||||
expOut: "istanbul.txt",
|
||||
),
|
||||
TestSpec(
|
||||
name : "Blob gas used exceeds max allowance",
|
||||
base : "testdata/00-523",
|
||||
input : t8nInput(
|
||||
"alloc.json", "txs.rlp", "env.json", "Cancun", "0",
|
||||
),
|
||||
output: T8nOutput(result: true),
|
||||
expOut: "exp.json",
|
||||
),
|
||||
]
|
||||
|
||||
proc main() =
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"0x000f3df6d732807ef1319fb7b8bb8522d0beac02": {
|
||||
"balance": "0x00",
|
||||
"code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500",
|
||||
"nonce": "0x01",
|
||||
"storage": {
|
||||
}
|
||||
},
|
||||
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
|
||||
"balance": "0x1db38f",
|
||||
"code": "0x",
|
||||
"nonce": "0x00",
|
||||
"storage": {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"blockHashes": {
|
||||
"0": "0x142abad1cb1f9c8a277d59f52cc29560472cf7bf4c46e12bfca8cf6b728acee2",
|
||||
"1": "0x13af3033e1f55060b7d587ab559289599c74454c74403f3d8f05c6e237bb619e"
|
||||
},
|
||||
"currentBaseFee": "0x7",
|
||||
"currentBlobGasUsed": "0xe0000",
|
||||
"currentCoinbase": "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
|
||||
"currentDifficulty": "0x0",
|
||||
"currentExcessBlobGas": "0xe0000",
|
||||
"currentGasLimit": "0x16345785d8a0000",
|
||||
"currentNumber": "0x1",
|
||||
"currentRandom": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"currentTimestamp": "0xc",
|
||||
"parentBaseFee": "0x7",
|
||||
"parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"parentBlobGasUsed": "0x0",
|
||||
"parentDifficulty": "0x0",
|
||||
"parentExcessBlobGas": "0x140000",
|
||||
"parentGasLimit": "0x16345785d8a0000",
|
||||
"parentGasUsed": "0x0",
|
||||
"parentTimestamp": "0x0",
|
||||
"parentUncleHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
|
||||
"withdrawals": [
|
||||
]
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
{
|
||||
"result": {
|
||||
"stateRoot": "0x2d5a3738dc0d76c5d1625b96d1597549c4cd218934167a672be4cc364646bdfc",
|
||||
"txRoot": "0x3836ad4f15ec36789c84c94fb8342a0e5765d80446986c417b22954d1c9a5e8b",
|
||||
"receiptsRoot": "0xc88bbb6ffab5658b295a44086ed7e77d4526e07e4025496e68a55042b24c81be",
|
||||
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"receipts": [
|
||||
{
|
||||
"root": "0x",
|
||||
"status": "0x1",
|
||||
"cumulativeGasUsed": "0x5208",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"logs": null,
|
||||
"transactionHash": "0x2f68a5bb6b843147e9ef8628047b6c5d5a0df834dc572007af7d4fce8e644c20",
|
||||
"contractAddress": "0x0000000000000000000000000000000000000000",
|
||||
"gasUsed": "0x5208",
|
||||
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"transactionIndex": "0x0",
|
||||
"type": "0x3"
|
||||
},
|
||||
{
|
||||
"root": "0x",
|
||||
"status": "0x1",
|
||||
"cumulativeGasUsed": "0xa410",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"logs": null,
|
||||
"transactionHash": "0xfd836af5a833b60c4b07612a7d77f4fc9d9412841c03f94c6eef90ab2e716bf6",
|
||||
"contractAddress": "0x0000000000000000000000000000000000000000",
|
||||
"gasUsed": "0x5208",
|
||||
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"transactionIndex": "0x1",
|
||||
"type": "0x3"
|
||||
},
|
||||
{
|
||||
"root": "0x",
|
||||
"status": "0x1",
|
||||
"cumulativeGasUsed": "0xf618",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"logs": null,
|
||||
"transactionHash": "0xa15a612ac2c6c92a62da1c8e8431a0335ad67066f078ea0434ee6bd48243caa5",
|
||||
"contractAddress": "0x0000000000000000000000000000000000000000",
|
||||
"gasUsed": "0x5208",
|
||||
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"transactionIndex": "0x2",
|
||||
"type": "0x3"
|
||||
},
|
||||
{
|
||||
"root": "0x",
|
||||
"status": "0x1",
|
||||
"cumulativeGasUsed": "0x14820",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"logs": null,
|
||||
"transactionHash": "0x53402f0a35345a4a4b6d47eb19fedfcaa21ba2239ed3997a080e317377f1b777",
|
||||
"contractAddress": "0x0000000000000000000000000000000000000000",
|
||||
"gasUsed": "0x5208",
|
||||
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"transactionIndex": "0x3",
|
||||
"type": "0x3"
|
||||
},
|
||||
{
|
||||
"root": "0x",
|
||||
"status": "0x1",
|
||||
"cumulativeGasUsed": "0x19a28",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"logs": null,
|
||||
"transactionHash": "0x5bd89296bd9454785bed316caeba5e6381552ed1f24f8386ee4774e390d6823e",
|
||||
"contractAddress": "0x0000000000000000000000000000000000000000",
|
||||
"gasUsed": "0x5208",
|
||||
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"transactionIndex": "0x4",
|
||||
"type": "0x3"
|
||||
},
|
||||
{
|
||||
"root": "0x",
|
||||
"status": "0x1",
|
||||
"cumulativeGasUsed": "0x1ec30",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"logs": null,
|
||||
"transactionHash": "0xdbb3a1b212d44a97f43b0b9f0db7e47d91c3d8baf3745accffe16b607901eba7",
|
||||
"contractAddress": "0x0000000000000000000000000000000000000000",
|
||||
"gasUsed": "0x5208",
|
||||
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"transactionIndex": "0x5",
|
||||
"type": "0x3"
|
||||
}
|
||||
],
|
||||
"currentDifficulty": null,
|
||||
"gasUsed": "0x1ec30",
|
||||
"rejected": [
|
||||
{
|
||||
"index": 6,
|
||||
"error": "blobGasUsed 917504 exceeds maximum allowance 786432"
|
||||
}
|
||||
],
|
||||
"currentBaseFee": "0x7",
|
||||
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||
"currentExcessBlobGas": "0xe0000",
|
||||
"blobGasUsed": "0xe0000"
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
"0xf903c6b88803f885018080078252089400000000000000000000000000000000000001000180c001e1a0010000000000000000000000000000000000000000000000000000000000000001a0a8f4757869fbb831ba4ed3a7c8f868b0e2e0c1eda97937aab035560fffdedf3ca019d9b041540e3d6f5f56dc29deb8834a08171e92037cf567b922357e70f8e54ab88803f885010180078252089400000000000000000000000000000000000001000180c001e1a0010000000000000000000000000000000000000000000000000000000000000001a0ef4c93a2afbe03bc2f31334b5c42654f2b88f3d1526e2719454638d2c87f3eaaa06234b91bfba07b555f8e11d44486319ef599f61fdb70bd5ec02085a41ff8e2ccb88803f885010280078252089400000000000000000000000000000000000001000180c001e1a0010000000000000000000000000000000000000000000000000000000000000080a0fe46a6659784d1c49e66bfe79f53c9282521940f406d321a953600d3297498e1a011d6bd31ffcfc37bd89923bd565eca3df245ab923b95799811f227502a95a429b88803f885010380078252089400000000000000000000000000000000000001000180c001e1a0010000000000000000000000000000000000000000000000000000000000000001a05d87fd0644fda3b8ae7c840519b0a51c86e54097b63c394a8ebfb13f0212da78a07054fc9d2468c15c2d8257a54e42419e6a53fe0d4568ccf95ecd4414e3481cdeb88803f885010480078252089400000000000000000000000000000000000001000180c001e1a0010000000000000000000000000000000000000000000000000000000000000001a0903154f2ee69dbdc29f7369ac4270a31d32b8af6c28959d5c6b2b2ba696e9e7da06989cf772024d3efa30b4b99bc1e1dee27813964f39448d07377537a2681d139b88803f885010580078252089400000000000000000000000000000000000001000180c001e1a0010000000000000000000000000000000000000000000000000000000000000080a07efec980ef3b40c74b2de3dee9e9f081b9b4ae4ae1732d64ba0e9553aaf08dc4a0464e6720d2d74b4d68f37f339608278be3a16802b61a46dc9895b898a70939eab88803f885010680078252089400000000000000000000000000000000000001000180c001e1a0010000000000000000000000000000000000000000000000000000000000000001a02145ded5025c6144b8f5ae446db8b617c5ff760eb7c17fa439dedb576ada3ab3a03a15f5307cc6a12f853f6f3732a1d2598d117a387256ab0f8f49d9431caf43bf"
|
|
@ -234,6 +234,7 @@ proc exec(ctx: var TransContext,
|
|||
vmState.processBeaconBlockRoot(ctx.env.parentBeaconBlockRoot.get).isOkOr:
|
||||
raise newError(ErrorConfig, error)
|
||||
|
||||
var blobGasUsed = 0'u64
|
||||
for txIndex, txRes in txList:
|
||||
if txRes.isErr:
|
||||
rejected.add RejectedTx(
|
||||
|
@ -273,6 +274,7 @@ proc exec(ctx: var TransContext,
|
|||
rec, tx, sender, txIndex, gasUsed
|
||||
)
|
||||
includedTx.add tx
|
||||
blobGasUsed += tx.getTotalBlobGas
|
||||
|
||||
# Add mining reward? (-1 means rewards are disabled)
|
||||
if stateReward.isSome and stateReward.get >= 0:
|
||||
|
@ -321,7 +323,7 @@ proc exec(ctx: var TransContext,
|
|||
)
|
||||
|
||||
if fork >= FkCancun:
|
||||
result.result.blobGasUsed = Opt.some vmState.blobGasUsed
|
||||
result.result.blobGasUsed = Opt.some blobGasUsed
|
||||
if ctx.env.currentExcessBlobGas.isSome:
|
||||
result.result.currentExcessBlobGas = ctx.env.currentExcessBlobGas
|
||||
elif ctx.env.parentExcessBlobGas.isSome and ctx.env.parentBlobGasUsed.isSome:
|
||||
|
|
Loading…
Reference in New Issue