good morning!!!!

Skip to content
Snippets Groups Projects
Select Git revision
  • ddccea75e8f4931689fdf6b57ec7159b65c0d3c5
  • master default protected
  • v0.2.16-candidate
  • shivam/rpcAddBorTx
  • default-cli-config
  • shivam/minerRecommitFix
  • vcastellm/pos-296-bump-go-version-in-bor-and-heimdall
  • shivam/ethstats-backend-fix
  • v0.2.16-beta1-candidate
  • v0.2.15-beta3-candidate
  • shivam/newCli-IPC
  • v0.3.0-dev
  • checkpoint-whitelist-master
  • shivam/codecov
  • jdkanani/fix-typo-log
  • shivam/hardcoded-spans-v0.2.14
  • shivam/hardcoded-spans
  • shivam/fast-state-sync
  • shivam/fast-state-sync-master
  • gethv1.10.15-merge
  • fix-txpool-2
  • v0.2.14-tmp-span-hotfix
  • v0.2.15-beta2
  • v0.2.15-beta1
  • v0.3.0-beta3
  • v0.3.0-beta2
  • v0.3.0-beta1
  • v0.2.14
  • v0.2.13
  • v0.2.13-beta2
  • v0.2.13-beta1
  • v0.2.12
  • v0.2.12-beta3
  • v0.2.12-beta1
  • v0.2.12-beta2
  • v0.2.11
  • v0.2.10
  • v0.2.10-beta2
  • v0.2.9
  • v0.2.9-beta1
  • v0.2.8
41 results

message.go

Blame
  • Forked from github / maticnetwork / bor
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    state_transition.go 6.38 KiB
    package ethchain
    
    import (
    	"fmt"
    	"math/big"
    )
    
    /*
     * The State transitioning model
     *
     * A state transition is a change made when a transaction is applied to the current world state
     * The state transitioning model does all all the necessary work to work out a valid new state root.
     * 1) Nonce handling
     * 2) Pre pay / buy gas of the coinbase (miner)
     * 3) Create a new state object if the recipient is \0*32
     * 4) Value transfer
     * == If contract creation ==
     * 4a) Attempt to run transaction data
     * 4b) If valid, use result as code for the new state object
     * == end ==
     * 5) Run Script section
     * 6) Derive new state root
     */
    type StateTransition struct {
    	coinbase, receiver []byte
    	tx                 *Transaction
    	gas, gasPrice      *big.Int
    	value              *big.Int
    	data               []byte
    	state              *State
    	block              *Block
    
    	cb, rec, sen *StateObject
    }
    
    func NewStateTransition(coinbase *StateObject, tx *Transaction, state *State, block *Block) *StateTransition {
    	return &StateTransition{coinbase.Address(), tx.Recipient, tx, new(big.Int), new(big.Int).Set(tx.GasPrice), tx.Value, tx.Data, state, block, coinbase, nil, nil}
    }
    
    func (self *StateTransition) Coinbase() *StateObject {
    	if self.cb != nil {
    		return self.cb
    	}
    
    	self.cb = self.state.GetAccount(self.coinbase)
    	return self.cb
    }
    func (self *StateTransition) Sender() *StateObject {
    	if self.sen != nil {
    		return self.sen
    	}
    
    	self.sen = self.state.GetAccount(self.tx.Sender())
    
    	return self.sen
    }
    func (self *StateTransition) Receiver() *StateObject {
    	if self.tx != nil && self.tx.CreatesContract() {
    		return nil
    	}
    
    	if self.rec != nil {
    		return self.rec
    	}
    
    	self.rec = self.state.GetAccount(self.tx.Recipient)
    	return self.rec
    }
    
    func (self *StateTransition) MakeStateObject(state *State, tx *Transaction) *StateObject {