Skip to content

Commit

Permalink
Merge pull request ethereum#157 from etclabscore/feat/openethereum-specs
Browse files Browse the repository at this point in the history
Feat/openethereum specs
  • Loading branch information
meowsbits authored Jul 27, 2020
2 parents cbb3569 + 5089bec commit ae8ba1e
Show file tree
Hide file tree
Showing 10 changed files with 324 additions and 46 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Transition consensus test spec template",
"name": "EIP158 to byzantium (test)",
"engine": {
"Ethash": {
"params": {
Expand Down
89 changes: 84 additions & 5 deletions params/parity.json.d/foundation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4766,10 +4766,6 @@
]
},
"nodes": [
"enode://81863f47e9bd652585d3f78b4b2ee07b93dad603fd9bc3c293e1244250725998adc88da0cef48f1de89b15ab92b15db8f43dc2b6fb8fbd86a6f217a1dd886701@193.70.55.37:30303",
"enode://4afb3a9137a88267c02651052cf6fb217931b8c78ee058bb86643542a4e2e0a8d24d47d871654e1b78a276c363f3c1bc89254a973b00adc359c9e9a48f140686@144.217.139.5:30303",
"enode://c16d390b32e6eb1c312849fe12601412313165df1a705757d671296f1ac8783c5cff09eab0118ac1f981d7148c85072f0f26407e5c68598f3ad49209fade404d@139.99.51.203:30303",
"enode://4faf867a2e5e740f9b874e7c7355afee58a2d1ace79f7b692f1d553a1134eddbeb5f9210dd14dc1b774a46fd5f063a8bc1fa90579e13d9d18d1f59bac4a4b16b@139.99.160.213:30303",
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303",
"enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303",
"enode://ca6de62fce278f96aea6ec5a2daadb877e51651247cb96ee310a318def462913b653963c155a0ef6c7d50048bba6e6cea881130857413d9f50a621546b590758@34.255.23.113:30303",
Expand All @@ -4779,7 +4775,9 @@
"enode://715171f50508aba88aecd1250af392a45a330af91d7b90701c436b618c86aaa1589c9184561907bebbb56439b8f8787bc01f49a7c77276c58c1b09822d75e8e8@52.231.165.108:30303",
"enode://5d6d7cd20d6da4bb83a1d28cadb5d409b64edf314c0335df658c1a54e32c7c4a7ab7823d57c39b6a757556e68ff1df17c748b698544a55cb488b52479a92b60f@104.42.217.25:30303",
"enode://68f46370191198b71a1595dd453c489bbfe28036a9951fc0397fabd1b77462930b3c5a5359b20e99677855939be47b39fc8edcf1e9ff2522a922b86d233bf2df@144.217.153.76:30303",
"enode://ffed6382e05ee42854d862f08e4e39b8452c50a5a5d399072c40f9a0b2d4ad34b0eb5312455ad8bcf0dcb4ce969dc89a9a9fd00183eaf8abf46bbcc59dc6e9d5@51.195.3.238:30303"
"enode://ffed6382e05ee42854d862f08e4e39b8452c50a5a5d399072c40f9a0b2d4ad34b0eb5312455ad8bcf0dcb4ce969dc89a9a9fd00183eaf8abf46bbcc59dc6e9d5@51.195.3.238:30303",
"enode://b47b197244c054d385f25d7740b33cc7e2a74d6f715befad2b789fd3e3594bb1c8dd2ca2faf1a3bf6b4c9ec03e53b52301f722a2316b78976be03ccbe703c581@54.37.94.238:30303",
"enode://5f7d0794c464b2fcd514d41e16e4b535a98ac792a71ca9667c7cef35595dc34c9a1b793c0622554cf87f34006942abb526af7d2e37d715ac32ed02170556cce2@51.161.101.207:30303"
],
"accounts": {
"0x0000000000000000000000000000000000000001": {
Expand Down Expand Up @@ -4890,6 +4888,87 @@
}
}
},
"000000000000000000000000000000000000000a": {
"builtin": {
"name": "bls12_381_g1_add",
"activate_at": "0x7fffffffffffff",
"pricing": {
"bls12_const_operations": { "price": 600 }
}
}
},
"000000000000000000000000000000000000000b": {
"builtin": {
"name": "bls12_381_g1_mul",
"activate_at": "0x7fffffffffffff",
"pricing": {
"bls12_const_operations": { "price": 12000 }
}
}
},
"000000000000000000000000000000000000000c": {
"builtin": {
"name": "bls12_381_g1_multiexp",
"activate_at": "0x7fffffffffffff",
"pricing": {
"bls12_g1_multiexp": { "base": 12000 }
}
}
},
"000000000000000000000000000000000000000d": {
"builtin": {
"name": "bls12_381_g2_add",
"activate_at": "0x7fffffffffffff",
"pricing": {
"bls12_const_operations": { "price": 4500 }
}
}
},
"000000000000000000000000000000000000000e": {
"builtin": {
"name": "bls12_381_g2_mul",
"activate_at": "0x7fffffffffffff",
"pricing": {
"bls12_const_operations": { "price": 55000 }
}
}
},
"000000000000000000000000000000000000000f": {
"builtin": {
"name": "bls12_381_g2_multiexp",
"activate_at": "0x7fffffffffffff",
"pricing": {
"bls12_g2_multiexp": { "base": 55000 }
}
}
},
"0000000000000000000000000000000000000010": {
"builtin": {
"name": "bls12_381_pairing",
"activate_at": "0x7fffffffffffff",
"pricing": {
"bls12_pairing": { "base": 115000, "pair": 23000 }
}
}
},
"0000000000000000000000000000000000000011": {
"builtin": {
"name": "bls12_381_fp_to_g1",
"activate_at": "0x7fffffffffffff",
"pricing": {
"bls12_const_operations": { "price": 5500 }
}
}
},
"0000000000000000000000000000000000000012": {
"builtin": {
"name": "bls12_381_fp2_to_g2",
"activate_at": "0x7fffffffffffff",
"pricing": {
"bls12_const_operations": { "price": 110000 }
}
}
},
"0x3282791d6fd713f1e94f4bfd565eaa78b3a0599d": {
"balance": "0x487a9a304539440000"
},
Expand Down
1 change: 0 additions & 1 deletion params/parity.json.d/ropsten.json
Original file line number Diff line number Diff line change
Expand Up @@ -3591,7 +3591,6 @@
]
},
"nodes": [
"enode://d6cb8cba18828397e22e8852324af7e970b57cadbbd94aba6124790d1895728311b1f274e45d44a7a22b4276726903130a11ac2de19af5bc9294998f948eaad4@144.217.72.209:30303",
"enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:30303",
"enode://30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606@52.176.7.10:30303",
"enode://865a63255b3bb68023b6bffd5095118fcc13e79dcf014fe4e47e065c350c7cc72af2e53eff895f11ba1bbb6a2b33271c1116ee870f266618eadfc2e78aa7349c@52.176.100.77:30303",
Expand Down
26 changes: 11 additions & 15 deletions params/parity.json.d/sync-parity-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,29 @@ if [[ ! $(pwd) =~ go-ethereum$ ]]; then
fi

specs=(
"frontier_test"
"homestead_test"
"eip150_test"
"eip161_test"
"eip210_test"
"byzantium_test"
"constantinople_test"
"st_peters_test"
"istanbul_test"
"transition_test"
"test-specs/frontier_test"
"test-specs/homestead_test"
"test-specs/eip150_test"
"test-specs/eip161_test"
"test-specs/eip210_test"
"test-specs/byzantium_test"
"test-specs/constantinople_test"
"test-specs/constantinople_fix_test"
"test-specs/istanbul_test"
"test-specs/eip158_to_byzantiumat5_test"

"foundation"
"goerli"
"rinkeby"
"ropsten"

"classic"
"mordor"
"kotti"

"mix"
"musicoin"
)

for spec_name in "${specs[@]}"; do
echo "Fetching $spec_name..."
curl -q https://raw.githubusercontent.com/paritytech/parity-ethereum/master/ethcore/res/ethereum/"$spec_name".json > ./params/parity.json.d/"$spec_name".json
curl -q https://raw.githubusercontent.com/paritytech/parity-ethereum/master/ethcore/res/ethereum/"$spec_name".json > ./params/parity.json.d/"$(basename ${spec_name})".json
done

curl -q https://api.github.com/repos/paritytech/parity-ethereum/git/refs/heads/master | jq .object.sha | sed 's/"//g' > ./params/parity.json.d/commit.txt
18 changes: 18 additions & 0 deletions params/types/parity/parity.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ type ParityChainSpecPricing struct {

// Blake2F is the price per round of Blake2 compression
Blake2F *ParityChainSpecBlakePricing `json:"blake2_f,omitempty"`

BLS12ConstOperation *ParityChainSpecBLS12ConstOperationPricing `json:"bls12_const_operations,omitempty"`
BLS12G1MultiExp *ParityChainSpecBLS12MultiExpPricing `json:"bls12_g1_multiexp,omitempty"`
BLS12G2MultiExp *ParityChainSpecBLS12MultiExpPricing `json:"bls12_g2_multiexp,omitempty"`
BLS12Pairing *ParityChainSpecBLS12PairingPricing `json:"bls12_pairing,omitempty"`
}

type ParityChainSpecLinearPricing struct {
Expand Down Expand Up @@ -341,6 +346,19 @@ type ParityChainSpecBlakePricing struct {
GasPerRound uint64 `json:"gas_per_round"`
}

type ParityChainSpecBLS12ConstOperationPricing struct {
Price uint64 `json:"price"`
}

type ParityChainSpecBLS12MultiExpPricing struct {
Base uint64 `json:"base"`
}

type ParityChainSpecBLS12PairingPricing struct {
Base uint64 `json:"base"`
Pair uint64 `json:"pair"`
}

func (spec *ParityChainSpec) GetPrecompile(address common.Address, pricing ParityChainSpecPricing) *ParityU64 {
if spec.Accounts == nil {
return nil
Expand Down
178 changes: 158 additions & 20 deletions params/types/parity/parity_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,30 +459,168 @@ func (spec *ParityChainSpec) SetEIP1108Transition(n *uint64) error {
return nil
}

func (c *ParityChainSpec) GetECIP1080Transition() *uint64 {
return c.Params.ECIP1080Transition.Uint64P()
}

func (c *ParityChainSpec) SetECIP1080Transition(n *uint64) error {
c.Params.ECIP1080Transition = new(ParityU64).SetUint64(n)
return nil
}

func (c *ParityChainSpec) GetEIP1706Transition() *uint64 {
return c.Params.EIP1706Transition.Uint64P() // FIXME when+if upstream implements
}
func (spec *ParityChainSpec) GetECIP1080Transition() *uint64 {
return spec.Params.ECIP1080Transition.Uint64P()
}

func (spec *ParityChainSpec) SetECIP1080Transition(n *uint64) error {
spec.Params.ECIP1080Transition = new(ParityU64).SetUint64(n)
return nil
}

func (spec *ParityChainSpec) GetEIP1706Transition() *uint64 {
return spec.Params.EIP1706Transition.Uint64P() // FIXME when+if upstream implements
}

func (spec *ParityChainSpec) SetEIP1706Transition(n *uint64) error {
spec.Params.EIP1706Transition = new(ParityU64).SetUint64(n)
return nil
}

// GetEIP2537Transition returns the EIP2537 activation, if any.
// https://eips.ethereum.org/EIPS/eip-2537
func (spec *ParityChainSpec) GetEIP2537Transition() *uint64 {
var eip2537Precompiles = map[string]*uint64{
"bls12_381_g1_add": spec.GetPrecompile(common.BytesToAddress([]byte{0xa}),
ParityChainSpecPricing{
BLS12ConstOperation: &ParityChainSpecBLS12ConstOperationPricing{
Price: 600,
},
}).Uint64P(),
"bls12_381_g1_mul": spec.GetPrecompile(common.BytesToAddress([]byte{0xb}),
ParityChainSpecPricing{
BLS12ConstOperation: &ParityChainSpecBLS12ConstOperationPricing{
Price: 12000,
},
}).Uint64P(),
"bls12_381_g1_multiexp": spec.GetPrecompile(common.BytesToAddress([]byte{0xc}),
ParityChainSpecPricing{
BLS12G1MultiExp: &ParityChainSpecBLS12MultiExpPricing{
Base: 12000,
},
}).Uint64P(),
"bls12_381_g2_add": spec.GetPrecompile(common.BytesToAddress([]byte{0xd}),
ParityChainSpecPricing{
BLS12ConstOperation: &ParityChainSpecBLS12ConstOperationPricing{
Price: 4500,
},
}).Uint64P(),
"bls12_381_g2_mul": spec.GetPrecompile(common.BytesToAddress([]byte{0xe}),
ParityChainSpecPricing{
BLS12ConstOperation: &ParityChainSpecBLS12ConstOperationPricing{
Price: 55000,
},
}).Uint64P(),
"bls12_381_g2_multiexp": spec.GetPrecompile(common.BytesToAddress([]byte{0xf}),
ParityChainSpecPricing{
BLS12G2MultiExp: &ParityChainSpecBLS12MultiExpPricing{
Base: 55000,
},
}).Uint64P(),
"bls12_381_pairing": spec.GetPrecompile(common.BytesToAddress([]byte{0x10}),
ParityChainSpecPricing{
BLS12Pairing: &ParityChainSpecBLS12PairingPricing{
Base: 115000,
Pair: 23000,
},
}).Uint64P(),
"bls12_381_fp_to_g1": spec.GetPrecompile(common.BytesToAddress([]byte{0x11}),
ParityChainSpecPricing{
BLS12ConstOperation: &ParityChainSpecBLS12ConstOperationPricing{
Price: 5500,
},
}).Uint64P(),
"bls12_381_fp2_to_g2": spec.GetPrecompile(common.BytesToAddress([]byte{0x12}),
ParityChainSpecPricing{
BLS12ConstOperation: &ParityChainSpecBLS12ConstOperationPricing{
Price: 110000,
},
}).Uint64P(),
}

func (c *ParityChainSpec) SetEIP1706Transition(n *uint64) error {
c.Params.EIP1706Transition = new(ParityU64).SetUint64(n)
return nil
var activation *uint64
for _, v := range eip2537Precompiles {
if v == nil {
return nil
}
if activation == nil {
activation = v
continue
}
if *v != *activation {
return nil
}
}
return activation
}

func (c *ParityChainSpec) GetEIP2537Transition() *uint64 {
return c.Params.EIP2537Transition.Uint64P() // FIXME when+if upstream implements
}
func (spec *ParityChainSpec) SetEIP2537Transition(n *uint64) error {
type setter struct {
name string
pricing ParityChainSpecPricing
}
var eip2537Precompiles = []setter{
{"bls12_381_g1_add",
ParityChainSpecPricing{
BLS12ConstOperation: &ParityChainSpecBLS12ConstOperationPricing{
Price: 600,
},
}},
{"bls12_381_g1_mul",
ParityChainSpecPricing{
BLS12ConstOperation: &ParityChainSpecBLS12ConstOperationPricing{
Price: 12000,
},
}},
{"bls12_381_g1_multiexp",
ParityChainSpecPricing{
BLS12G1MultiExp: &ParityChainSpecBLS12MultiExpPricing{
Base: 12000,
},
}},
{"bls12_381_g2_add",
ParityChainSpecPricing{
BLS12ConstOperation: &ParityChainSpecBLS12ConstOperationPricing{
Price: 4500,
},
}},
{"bls12_381_g2_mul",
ParityChainSpecPricing{
BLS12ConstOperation: &ParityChainSpecBLS12ConstOperationPricing{
Price: 55000,
},
}},
{"bls12_381_g2_multiexp",
ParityChainSpecPricing{
BLS12G2MultiExp: &ParityChainSpecBLS12MultiExpPricing{
Base: 55000,
},
}},
{"bls12_381_pairing",
ParityChainSpecPricing{
BLS12Pairing: &ParityChainSpecBLS12PairingPricing{
Base: 115000,
Pair: 23000,
},
}},
{"bls12_381_fp_to_g1",
ParityChainSpecPricing{
BLS12ConstOperation: &ParityChainSpecBLS12ConstOperationPricing{
Price: 5500,
},
}},
{"bls12_381_fp2_to_g2",
ParityChainSpecPricing{
BLS12ConstOperation: &ParityChainSpecBLS12ConstOperationPricing{
Price: 110000,
},
}},
}

func (c *ParityChainSpec) SetEIP2537Transition(n *uint64) error {
c.Params.EIP2537Transition = new(ParityU64).SetUint64(n)
var addr uint8 = 0xa // EIP2537 BLS precompiles occupy 0xa:0x12 (9 total)
for i, v := range eip2537Precompiles {
spec.SetPrecompile2(common.BytesToAddress([]byte{addr + uint8(i)}), v.name, n, v.pricing)
}
return nil
}

Expand Down
Loading

0 comments on commit ae8ba1e

Please sign in to comment.