Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompile dispatch table #88

Closed
wants to merge 10 commits into from
Closed
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
3 changes: 3 additions & 0 deletions accounts/abi/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type Type struct {
TupleElems []*Type // Type information of all tuple fields
TupleRawNames []string // Raw field name of all tuple fields
TupleType reflect.Type // Underlying struct of the tuple

InternalType string
}

var (
Expand Down Expand Up @@ -223,6 +225,7 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
return Type{}, fmt.Errorf("unsupported arg type: %s", t)
}

typ.InternalType = internalType
return
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/geth/forgecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/suave/artifacts"
"github.com/urfave/cli/v2"
)

Expand All @@ -33,7 +33,7 @@ var (
// 2. The name of the precompile.
addr := args.Get(0)
if !strings.HasPrefix(addr, "0x") {
mAddr, ok := artifacts.SuaveMethods[addr]
mAddr, ok := vm.GetRuntime().GetAddrFromName(addr)
if !ok {
return fmt.Errorf("unknown precompile name '%s'", addr)
}
Expand Down
38 changes: 1 addition & 37 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ type PrecompiledContract interface {
Run(input []byte) ([]byte, error) // Run runs the precompiled contract
}

// SuavePrecompiledContract is an optional interface for precompiled Suave contracts.
// During confidential execution the contract will be called with their RunConfidential method.
type SuavePrecompiledContract interface {
PrecompiledContract
RunConfidential(context *SuaveContext, input []byte) ([]byte, error)
}

// PrecompiledContractsHomestead contains the default set of pre-compiled Ethereum
// contracts used in the Frontier and Homestead releases.
var PrecompiledContractsHomestead = map[common.Address]PrecompiledContract{
Expand Down Expand Up @@ -83,31 +76,6 @@ var PrecompiledContractsIstanbul = map[common.Address]PrecompiledContract{
common.BytesToAddress([]byte{9}): &blake2F{},
}

// PrecompiledContractsSuave contains the default set of pre-compiled SUAVE VM
// contracts used in the suave testnet. It's a superset of Berlin precompiles.
// Confidential contracts (implementing SuavePrecompiledContract)
// are ran with their respective RunConfidential in confidential setting
var PrecompiledContractsSuave = map[common.Address]SuavePrecompiledContract{
isConfidentialAddress: &isConfidentialPrecompile{},
confidentialInputsAddress: &confidentialInputsPrecompile{},

confStoreStoreAddress: newConfStoreStore(),
confStoreRetrieveAddress: newConfStoreRetrieve(),

newBidAddress: newNewBid(),
fetchBidsAddress: newFetchBids(),
extractHintAddress: &extractHint{},

signEthTransactionAddress: &signEthTransaction{},
simulateBundleAddress: &simulateBundle{},
buildEthBlockAddress: &buildEthBlock{},
submitEthBlockBidToRelayAddress: &submitEthBlockBidToRelay{},
submitBundleJsonRPCAddress: &submitBundleJsonRPC{},
fillMevShareBundleAddress: &fillMevShareBundle{},

ethcallAddr: &ethCallPrecompile{},
}

// PrecompiledContractsBerlin contains the default set of pre-compiled Ethereum
// contracts used in the Berlin release.
var PrecompiledContractsBerlin = map[common.Address]PrecompiledContract{
Expand Down Expand Up @@ -137,7 +105,6 @@ var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{
}

var (
PrecompiledAddressesSuave []common.Address
PrecompiledAddressesBerlin []common.Address
PrecompiledAddressesIstanbul []common.Address
PrecompiledAddressesByzantium []common.Address
Expand All @@ -157,9 +124,6 @@ func init() {
for k := range PrecompiledContractsBerlin {
PrecompiledAddressesBerlin = append(PrecompiledAddressesBerlin, k)
}
for k := range PrecompiledContractsSuave {
PrecompiledAddressesSuave = append(PrecompiledAddressesSuave, k)
}
}

// ActivePrecompiles returns the precompiles enabled with the current configuration.
Expand All @@ -178,7 +142,7 @@ func ActivePrecompiles(rules params.Rules) []common.Address {
}

if rules.IsSuave {
return append(basePrecompiles, PrecompiledAddressesSuave...)
return append(basePrecompiles, dd.addrs...)
}

return basePrecompiles
Expand Down
Loading
Loading