@@ -187,10 +187,11 @@ func TransactionToMessage(tx *types.Transaction, s types.Signer, baseFee *big.In
187187// indicates a core error meaning that the message would always fail for that particular
188188// state and would never be accepted within a block.
189189func ApplyMessage (evm * vm.EVM , msg * Message , gp * GasPool ) (* ExecutionResult , error ) {
190- return NewStateTransition (evm , msg , gp ).TransitionDb ()
190+ evm .SetTxContext (NewEVMTxContext (msg ))
191+ return newStateTransition (evm , msg , gp ).execute ()
191192}
192193
193- // StateTransition represents a state transition.
194+ // stateTransition represents a state transition.
194195//
195196// == The State Transitioning Model
196197//
@@ -212,7 +213,7 @@ func ApplyMessage(evm *vm.EVM, msg *Message, gp *GasPool) (*ExecutionResult, err
212213//
213214// 5. Run Script section
214215// 6. Derive new state root
215- type StateTransition struct {
216+ type stateTransition struct {
216217 gp * GasPool
217218 msg * Message
218219 gasRemaining uint64
@@ -221,9 +222,9 @@ type StateTransition struct {
221222 evm * vm.EVM
222223}
223224
224- // NewStateTransition initialises and returns a new state transition object.
225- func NewStateTransition (evm * vm.EVM , msg * Message , gp * GasPool ) * StateTransition {
226- return & StateTransition {
225+ // newStateTransition initialises and returns a new state transition object.
226+ func newStateTransition (evm * vm.EVM , msg * Message , gp * GasPool ) * stateTransition {
227+ return & stateTransition {
227228 gp : gp ,
228229 evm : evm ,
229230 msg : msg ,
@@ -232,14 +233,14 @@ func NewStateTransition(evm *vm.EVM, msg *Message, gp *GasPool) *StateTransition
232233}
233234
234235// to returns the recipient of the message.
235- func (st * StateTransition ) to () common.Address {
236+ func (st * stateTransition ) to () common.Address {
236237 if st .msg == nil || st .msg .To == nil /* contract creation */ {
237238 return common.Address {}
238239 }
239240 return * st .msg .To
240241}
241242
242- func (st * StateTransition ) buyGas () error {
243+ func (st * stateTransition ) buyGas () error {
243244 mgval := new (big.Int ).SetUint64 (st .msg .GasLimit )
244245 mgval .Mul (mgval , st .msg .GasPrice )
245246 balanceCheck := new (big.Int ).Set (mgval )
@@ -283,7 +284,7 @@ func (st *StateTransition) buyGas() error {
283284 return nil
284285}
285286
286- func (st * StateTransition ) preCheck () error {
287+ func (st * stateTransition ) preCheck () error {
287288 // Only check transactions that are not fake
288289 msg := st .msg
289290 if ! msg .SkipNonceChecks {
@@ -368,7 +369,7 @@ func (st *StateTransition) preCheck() error {
368369 return st .buyGas ()
369370}
370371
371- // TransitionDb will transition the state by applying the current message and
372+ // execute will transition the state by applying the current message and
372373// returning the evm execution result with following fields.
373374//
374375// - used gas: total gas used (including gas being refunded)
@@ -378,7 +379,7 @@ func (st *StateTransition) preCheck() error {
378379//
379380// However if any consensus issue encountered, return the error directly with
380381// nil evm execution result.
381- func (st * StateTransition ) TransitionDb () (* ExecutionResult , error ) {
382+ func (st * stateTransition ) execute () (* ExecutionResult , error ) {
382383 // First check this message satisfies all consensus rules before
383384 // applying the message. The rules include these clauses
384385 //
@@ -493,7 +494,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
493494 }, nil
494495}
495496
496- func (st * StateTransition ) refundGas (refundQuotient uint64 ) uint64 {
497+ func (st * stateTransition ) refundGas (refundQuotient uint64 ) uint64 {
497498 // Apply refund counter, capped to a refund quotient
498499 refund := st .gasUsed () / refundQuotient
499500 if refund > st .state .GetRefund () {
@@ -523,11 +524,11 @@ func (st *StateTransition) refundGas(refundQuotient uint64) uint64 {
523524}
524525
525526// gasUsed returns the amount of gas used up by the state transition.
526- func (st * StateTransition ) gasUsed () uint64 {
527+ func (st * stateTransition ) gasUsed () uint64 {
527528 return st .initialGas - st .gasRemaining
528529}
529530
530531// blobGasUsed returns the amount of blob gas used by the message.
531- func (st * StateTransition ) blobGasUsed () uint64 {
532+ func (st * stateTransition ) blobGasUsed () uint64 {
532533 return uint64 (len (st .msg .BlobHashes ) * params .BlobTxBlobGasPerBlob )
533534}
0 commit comments