@ -187,10 +187,11 @@ func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.In
// indicates a core error meaning that the message would always fail for that particular
// state and would never be accepted within a block.
func ApplyMessage ( evm * vm . EVM , msg * Message , gp * GasPool ) ( * ExecutionResult , error ) {
return NewStateTransition ( evm , msg , gp ) . TransitionDb ( )
evm . SetTxContext ( NewEVMTxContext ( msg ) )
return newStateTransition ( evm , msg , gp ) . execute ( )
}
// S tateTransition represents a state transition.
// s tateTransition represents a state transition.
//
// == The State Transitioning Model
//
@ -212,7 +213,7 @@ func ApplyMessage(evm *vm.EVM, msg *Message, gp *GasPool) (*ExecutionResult, err
//
// 5. Run Script section
// 6. Derive new state root
type S tateTransition struct {
type s tateTransition struct {
gp * GasPool
msg * Message
gasRemaining uint64
@ -221,9 +222,9 @@ type StateTransition struct {
evm * vm . EVM
}
// N ewStateTransition initialises and returns a new state transition object.
func N ewStateTransition( evm * vm . EVM , msg * Message , gp * GasPool ) * S tateTransition {
return & S tateTransition{
// n ewStateTransition initialises and returns a new state transition object.
func n ewStateTransition( evm * vm . EVM , msg * Message , gp * GasPool ) * s tateTransition {
return & s tateTransition{
gp : gp ,
evm : evm ,
msg : msg ,
@ -232,14 +233,14 @@ func NewStateTransition(evm *vm.EVM, msg *Message, gp *GasPool) *StateTransition
}
// to returns the recipient of the message.
func ( st * S tateTransition) to ( ) common . Address {
func ( st * s tateTransition) to ( ) common . Address {
if st . msg == nil || st . msg . To == nil /* contract creation */ {
return common . Address { }
}
return * st . msg . To
}
func ( st * S tateTransition) buyGas ( ) error {
func ( st * s tateTransition) buyGas ( ) error {
mgval := new ( big . Int ) . SetUint64 ( st . msg . GasLimit )
mgval . Mul ( mgval , st . msg . GasPrice )
balanceCheck := new ( big . Int ) . Set ( mgval )
@ -283,7 +284,7 @@ func (st *StateTransition) buyGas() error {
return nil
}
func ( st * S tateTransition) preCheck ( ) error {
func ( st * s tateTransition) preCheck ( ) error {
// Only check transactions that are not fake
msg := st . msg
if ! msg . SkipNonceChecks {
@ -368,7 +369,7 @@ func (st *StateTransition) preCheck() error {
return st . buyGas ( )
}
// TransitionDb will transition the state by applying the current message and
// execute will transition the state by applying the current message and
// returning the evm execution result with following fields.
//
// - used gas: total gas used (including gas being refunded)
@ -378,7 +379,7 @@ func (st *StateTransition) preCheck() error {
//
// However if any consensus issue encountered, return the error directly with
// nil evm execution result.
func ( st * StateTransition ) TransitionDb ( ) ( * ExecutionResult , error ) {
func ( st * stateTransition ) execute ( ) ( * ExecutionResult , error ) {
// First check this message satisfies all consensus rules before
// applying the message. The rules include these clauses
//
@ -493,7 +494,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
} , nil
}
func ( st * S tateTransition) refundGas ( refundQuotient uint64 ) uint64 {
func ( st * s tateTransition) refundGas ( refundQuotient uint64 ) uint64 {
// Apply refund counter, capped to a refund quotient
refund := st . gasUsed ( ) / refundQuotient
if refund > st . state . GetRefund ( ) {
@ -523,11 +524,11 @@ func (st *StateTransition) refundGas(refundQuotient uint64) uint64 {
}
// gasUsed returns the amount of gas used up by the state transition.
func ( st * S tateTransition) gasUsed ( ) uint64 {
func ( st * s tateTransition) gasUsed ( ) uint64 {
return st . initialGas - st . gasRemaining
}
// blobGasUsed returns the amount of blob gas used by the message.
func ( st * S tateTransition) blobGasUsed ( ) uint64 {
func ( st * s tateTransition) blobGasUsed ( ) uint64 {
return uint64 ( len ( st . msg . BlobHashes ) * params . BlobTxBlobGasPerBlob )
}