diff --git a/concrete/precompiles/precompile_registry.go b/concrete/precompiles/precompile_registry.go index 0d50c33f455ee..fe415ce7de089 100644 --- a/concrete/precompiles/precompile_registry.go +++ b/concrete/precompiles/precompile_registry.go @@ -32,7 +32,7 @@ var PrecompileRegistry *lib.PrecompileWithABI var PrecompileRegistryMetadata = PrecompileMetadata{ Name: "PrecompileRegistry", - Version: "0.1.0", + Version: Version{common.Big0, common.Big1, common.Big0}, Author: "The concrete-geth Authors", Description: "A registry of precompiles indexed by address and name.", Source: "https://github.com/therealbytes/concrete-geth/tree/concrete/concrete/precompiles/precompile_registry.go", @@ -63,9 +63,9 @@ func init() { } type FrameworkMetadata = struct { - Name string `json:"name"` - Version string `json:"version"` - Source string `json:"source"` + Name string `json:"name"` + Version Version `json:"version"` + Source string `json:"source"` } type getFramework struct { @@ -80,7 +80,7 @@ func (p *getFramework) Run(API api.API, input []byte) ([]byte, error) { return p.CallRunWithArgs(func(API api.API, args []interface{}) ([]interface{}, error) { metadata := FrameworkMetadata{ "Concrete", - "0.1.0", + Version{common.Big0, common.Big1, common.Big0}, "https://github.com/therealbytes/concrete-geth", } return []interface{}{metadata}, nil diff --git a/concrete/precompiles/precompile_registry_test.go b/concrete/precompiles/precompile_registry_test.go index 6baa6acf012d1..1da623738a474 100644 --- a/concrete/precompiles/precompile_registry_test.go +++ b/concrete/precompiles/precompile_registry_test.go @@ -17,6 +17,7 @@ package precompiles import ( "encoding/json" + "fmt" "testing" "github.com/ethereum/go-ethereum/common" @@ -67,7 +68,7 @@ func TestPrecompileRegistry(t *testing.T) { r.NoError(err) precompileData, ok := _precompileData[0].(PrecompileMetadata) r.True(ok) - r.EqualValues(expectedMetadata, precompileData) + r.EqualValues(fmt.Sprint(expectedMetadata), fmt.Sprint(precompileData)) // Test getPrecompileByName input, err = pc.ABI.Pack("getPrecompileByName", expectedMetadata.Name) @@ -106,7 +107,7 @@ func TestPrecompileRegistry(t *testing.T) { for _, pc := range pcs { if pc.Addr == address { contains = true - r.EqualValues(expectedMetadata, pc) + r.EqualValues(fmt.Sprint(expectedMetadata), fmt.Sprint(precompileData)) } } r.True(contains) diff --git a/concrete/precompiles/precompiles.go b/concrete/precompiles/precompiles.go index e0a7e2cfd0027..3f96a67a22887 100644 --- a/concrete/precompiles/precompiles.go +++ b/concrete/precompiles/precompiles.go @@ -19,16 +19,23 @@ import ( "encoding/json" "errors" "fmt" + "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/concrete/api" "github.com/ethereum/go-ethereum/concrete/lib" ) +type Version = struct { + Major *big.Int `json:"major"` + Minor *big.Int `json:"minor"` + Patch *big.Int `json:"patch"` +} + type PrecompileMetadata = struct { Addr common.Address `json:"addr"` Name string `json:"name"` - Version string `json:"version"` + Version Version `json:"version"` Author string `json:"author"` Description string `json:"description"` Source string `json:"source"` diff --git a/concrete/precompiles/preimage_registry.go b/concrete/precompiles/preimage_registry.go index 2830caf4f9b02..ef737a8e3ac51 100644 --- a/concrete/precompiles/preimage_registry.go +++ b/concrete/precompiles/preimage_registry.go @@ -38,14 +38,14 @@ var ( var ( PreimageRegistryMetadata = PrecompileMetadata{ Name: "PreimageRegistry", - Version: "0.1.0", + Version: Version{common.Big0, common.Big1, common.Big0}, Author: "The concrete-geth Authors", Description: "A registry of stored preimages indexed by their hash.", Source: "https://github.com/therealbytes/concrete-geth/tree/concrete/concrete/precompiles/preimage_registry.go", } BigPreimageRegistryMetadata = PrecompileMetadata{ Name: "BigPreimageRegistry", - Version: "0.1.0", + Version: Version{common.Big0, common.Big1, common.Big0}, Author: "The concrete-geth Authors", Description: "A registry of stored preimage merkle trees indexed by their root hash.", Source: "https://github.com/therealbytes/concrete-geth/tree/concrete/concrete/precompiles/pi_registry.go", diff --git a/concrete/precompiles/sol/PrecompileRegistry.sol b/concrete/precompiles/sol/PrecompileRegistry.sol index e9306ccdffafc..57aeb59cb3280 100644 --- a/concrete/precompiles/sol/PrecompileRegistry.sol +++ b/concrete/precompiles/sol/PrecompileRegistry.sol @@ -1,16 +1,22 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity ^0.8.0; +struct Version { + uint256 major; + uint256 minor; + uint256 patch; +} + struct FrameworkMetadata { string name; - string version; + Version version; string source; } struct PrecompileMetadata { address addr; string name; - string version; + Version version; string author; string description; string source; diff --git a/concrete/precompiles/sol/abi/PrecompileRegistry.abi b/concrete/precompiles/sol/abi/PrecompileRegistry.abi index a8bbe55fcb0e5..aafad1dffcd93 100644 --- a/concrete/precompiles/sol/abi/PrecompileRegistry.abi +++ b/concrete/precompiles/sol/abi/PrecompileRegistry.abi @@ -1 +1 @@ -[{"inputs":[],"name":"getFramework","outputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"string","name":"source","type":"string"}],"internalType":"struct FrameworkMetadata","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"getPrecompile","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"string","name":"author","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"source","type":"string"},{"internalType":"string","name":"ABI","type":"string"}],"internalType":"struct PrecompileMetadata","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"}],"name":"getPrecompileByName","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrecompiledAddresses","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrecompiles","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"string","name":"author","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"source","type":"string"},{"internalType":"string","name":"ABI","type":"string"}],"internalType":"struct PrecompileMetadata[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"}] \ No newline at end of file +[{"inputs":[],"name":"getFramework","outputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"components":[{"internalType":"uint256","name":"major","type":"uint256"},{"internalType":"uint256","name":"minor","type":"uint256"},{"internalType":"uint256","name":"patch","type":"uint256"}],"internalType":"struct Version","name":"version","type":"tuple"},{"internalType":"string","name":"source","type":"string"}],"internalType":"struct FrameworkMetadata","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"getPrecompile","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"string","name":"name","type":"string"},{"components":[{"internalType":"uint256","name":"major","type":"uint256"},{"internalType":"uint256","name":"minor","type":"uint256"},{"internalType":"uint256","name":"patch","type":"uint256"}],"internalType":"struct Version","name":"version","type":"tuple"},{"internalType":"string","name":"author","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"source","type":"string"},{"internalType":"string","name":"ABI","type":"string"}],"internalType":"struct PrecompileMetadata","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"}],"name":"getPrecompileByName","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrecompiledAddresses","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrecompiles","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"string","name":"name","type":"string"},{"components":[{"internalType":"uint256","name":"major","type":"uint256"},{"internalType":"uint256","name":"minor","type":"uint256"},{"internalType":"uint256","name":"patch","type":"uint256"}],"internalType":"struct Version","name":"version","type":"tuple"},{"internalType":"string","name":"author","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"string","name":"source","type":"string"},{"internalType":"string","name":"ABI","type":"string"}],"internalType":"struct PrecompileMetadata[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"}] \ No newline at end of file