|
|
@ -27,6 +27,7 @@ import ( |
|
|
|
consensus_engine "github.com/harmony-one/harmony/consensus/engine" |
|
|
|
consensus_engine "github.com/harmony-one/harmony/consensus/engine" |
|
|
|
"github.com/harmony-one/harmony/core/types" |
|
|
|
"github.com/harmony-one/harmony/core/types" |
|
|
|
"github.com/harmony-one/harmony/core/vm" |
|
|
|
"github.com/harmony-one/harmony/core/vm" |
|
|
|
|
|
|
|
"github.com/harmony-one/harmony/internal/utils" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// ChainContext supports retrieving headers and consensus parameters from the
|
|
|
|
// ChainContext supports retrieving headers and consensus parameters from the
|
|
|
@ -43,14 +44,21 @@ type ChainContext interface { |
|
|
|
|
|
|
|
|
|
|
|
// ReadValidatorSnapshot returns the snapshot of validator at the beginning of current epoch.
|
|
|
|
// ReadValidatorSnapshot returns the snapshot of validator at the beginning of current epoch.
|
|
|
|
ReadValidatorSnapshot(common.Address) (*types2.ValidatorWrapper, error) |
|
|
|
ReadValidatorSnapshot(common.Address) (*types2.ValidatorWrapper, error) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GetECDSAFromCoinbase retrieves corresponding ECDSA address from the coinbase (BLS Address)
|
|
|
|
|
|
|
|
GetECDSAFromCoinbase(*block.Header) (common.Address, error) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NewEVMContext creates a new context for use in the EVM.
|
|
|
|
// NewEVMContext creates a new context for use in the EVM.
|
|
|
|
func NewEVMContext(msg Message, header *block.Header, chain ChainContext, author *common.Address) vm.Context { |
|
|
|
func NewEVMContext(msg Message, header *block.Header, chain ChainContext, author *common.Address) vm.Context { |
|
|
|
// If we don't have an explicit author (i.e. not mining), extract from the header
|
|
|
|
// If we don't have an explicit author (i.e. not mining), extract from the header
|
|
|
|
var beneficiary common.Address |
|
|
|
var beneficiary common.Address |
|
|
|
|
|
|
|
var err error |
|
|
|
if author == nil { |
|
|
|
if author == nil { |
|
|
|
beneficiary, _ = chain.Engine().Author(header) // Ignore error, we're past header validation
|
|
|
|
beneficiary, err = chain.GetECDSAFromCoinbase(header) // Ignore error, we're past header validation
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
utils.Logger().Warn().Msg("oops! We cannot find any beneficiary from header") |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
beneficiary = *author |
|
|
|
beneficiary = *author |
|
|
|
} |
|
|
|
} |
|
|
|