forked from cerc-io/laconicd-deprecated
ante: check that sender is a EOA (#125)
* ante: check that sender is a EOA * fix: GetCodeSize handles nil case and comments * docs: add TODO comment * fix: use EmptyCodeHash check * lint: evmtypes instead of types * lint: fix suite error * test: set code to act not as EOA * undo comment on GetCodeSize * keeper: fix input checks * Apply suggestions from code review Co-authored-by: Akash Khosla <me@akashkhosla.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
co-authored by
Akash Khosla
Federico Kunze
parent
d3c5df9dda
commit
d7da045fc4
@@ -228,6 +228,9 @@ func (k *Keeper) GetCode(addr common.Address) []byte {
|
||||
|
||||
// SetCode calls CommitStateDB.SetCode using the passed in context
|
||||
func (k *Keeper) SetCode(addr common.Address, code []byte) {
|
||||
if bytes.Equal(code, types.EmptyCodeHash) {
|
||||
k.Logger(k.ctx).Debug("passed in EmptyCodeHash, but expected empty code")
|
||||
}
|
||||
hash := crypto.Keccak256Hash(code)
|
||||
|
||||
// update account code hash
|
||||
@@ -269,9 +272,11 @@ func (k *Keeper) SetCode(addr common.Address, code []byte) {
|
||||
)
|
||||
}
|
||||
|
||||
// GetCodeSize returns the code hash stored in the address account.
|
||||
// GetCodeSize returns the size of the contract code associated with this object,
|
||||
// or zero if none.
|
||||
func (k *Keeper) GetCodeSize(addr common.Address) int {
|
||||
return len(k.GetCode(addr))
|
||||
code := k.GetCode(addr)
|
||||
return len(code)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user