Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import (
"golang.org/x/crypto/ripemd160"
)

var (
errPrecompileDisabled = errors.New("sha256, ripemd160, blake2f precompiles temporarily disabled")
)

// PrecompiledContract is the basic interface for native Go contracts. The implementation
// requires a deterministic gas count based on the input size of the Run method of the
// contract.
Expand Down Expand Up @@ -96,11 +100,14 @@ var PrecompiledContractsBerlin = map[common.Address]PrecompiledContract{
// contracts used in the Archimedes release. Same as Berlin but without sha2, blake2f, ripemd160
var PrecompiledContractsArchimedes = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{1}): &ecrecover{},
common.BytesToAddress([]byte{2}): &sha256hashDisabled{},
common.BytesToAddress([]byte{3}): &ripemd160hashDisabled{},
common.BytesToAddress([]byte{4}): &dataCopy{},
common.BytesToAddress([]byte{5}): &bigModExp{eip2565: true},
common.BytesToAddress([]byte{6}): &bn256AddIstanbul{},
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{},
common.BytesToAddress([]byte{9}): &blake2FDisabled{},
}

// PrecompiledContractsBLS contains the set of pre-compiled Ethereum
Expand Down Expand Up @@ -227,6 +234,15 @@ func (c *sha256hash) Run(input []byte) ([]byte, error) {
return h[:], nil
}

type sha256hashDisabled struct{}

func (c *sha256hashDisabled) RequiredGas(input []byte) uint64 {
return (&sha256hash{}).RequiredGas(input)
}
func (c *sha256hashDisabled) Run(input []byte) ([]byte, error) {
return nil, errPrecompileDisabled
}

// RIPEMD160 implemented as a native contract.
type ripemd160hash struct{}

Expand All @@ -243,6 +259,15 @@ func (c *ripemd160hash) Run(input []byte) ([]byte, error) {
return common.LeftPadBytes(ripemd.Sum(nil), 32), nil
}

type ripemd160hashDisabled struct{}

func (c *ripemd160hashDisabled) RequiredGas(input []byte) uint64 {
return (&ripemd160hash{}).RequiredGas(input)
}
func (c *ripemd160hashDisabled) Run(input []byte) ([]byte, error) {
return nil, errPrecompileDisabled
}

// data copy implemented as a native contract.
type dataCopy struct{}

Expand Down Expand Up @@ -636,6 +661,15 @@ func (c *blake2F) Run(input []byte) ([]byte, error) {
return output, nil
}

type blake2FDisabled struct{}

func (c *blake2FDisabled) RequiredGas(input []byte) uint64 {
return (&blake2F{}).RequiredGas(input)
}
func (c *blake2FDisabled) Run(input []byte) ([]byte, error) {
return nil, errPrecompileDisabled
}

var (
errBLS12381InvalidInputLength = errors.New("invalid input length")
errBLS12381InvalidFieldElementTopBytes = errors.New("invalid field element top bytes")
Expand Down
4 changes: 2 additions & 2 deletions params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (

const (
VersionMajor = 3 // Major version component of the current release
VersionMinor = 2 // Minor version component of the current release
VersionPatch = 4 // Patch version component of the current release
VersionMinor = 3 // Minor version component of the current release
VersionPatch = 0 // Patch version component of the current release
VersionMeta = "alpha" // Version metadata to append to the version string
)

Expand Down