diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-11-27 22:40:29 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2016-02-18 17:08:11 +0800 |
commit | 371871d685d54b916aef28de689d6f0af7822083 (patch) | |
tree | e704b02ba2ffd2d1164001885fba15106b0f7d94 /core/types | |
parent | aa36a6ae4f24f07e2c470a21c93ff37ad5861982 (diff) | |
download | go-tangerine-371871d685d54b916aef28de689d6f0af7822083.tar.gz go-tangerine-371871d685d54b916aef28de689d6f0af7822083.tar.zst go-tangerine-371871d685d54b916aef28de689d6f0af7822083.zip |
parmas, crypto, core, core/vm: homestead consensus protocol changes
* change gas cost for contract creating txs
* invalidate signature with s value greater than secp256k1 N / 2
* OOG contract creation if not enough gas to store code
* new difficulty adjustment algorithm
* new DELEGATECALL op code
Diffstat (limited to 'core/types')
-rw-r--r-- | core/types/transaction.go | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/core/types/transaction.go b/core/types/transaction.go index 4049ae888..af952e450 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -157,11 +157,26 @@ func (tx *Transaction) Size() common.StorageSize { return common.StorageSize(c) } +// From() caches the address, allowing it to be used regardless of +// Frontier / Homestead. however, the first time called it runs +// signature validations, so we need two versions. This makes it +// easier to ensure backwards compatibility of things like package rpc +// where eth_getblockbynumber uses tx.From() and needs to work for +// both txs before and after the first homestead block. Signatures +// valid in homestead are a subset of valid ones in Frontier) func (tx *Transaction) From() (common.Address, error) { + return doFrom(tx, true) +} + +func (tx *Transaction) FromFrontier() (common.Address, error) { + return doFrom(tx, false) +} + +func doFrom(tx *Transaction, homestead bool) (common.Address, error) { if from := tx.from.Load(); from != nil { return from.(common.Address), nil } - pubkey, err := tx.publicKey() + pubkey, err := tx.publicKey(homestead) if err != nil { return common.Address{}, err } @@ -182,8 +197,8 @@ func (tx *Transaction) SignatureValues() (v byte, r *big.Int, s *big.Int) { return tx.data.V, new(big.Int).Set(tx.data.R), new(big.Int).Set(tx.data.S) } -func (tx *Transaction) publicKey() ([]byte, error) { - if !crypto.ValidateSignatureValues(tx.data.V, tx.data.R, tx.data.S) { +func (tx *Transaction) publicKey(homestead bool) ([]byte, error) { + if !crypto.ValidateSignatureValues(tx.data.V, tx.data.R, tx.data.S, homestead) { return nil, ErrInvalidSig } |