From bdd91a41a479a9ff347d5730f1af26ffaf67376a Mon Sep 17 00:00:00 2001 From: Chris Gianelloni Date: Fri, 25 Oct 2024 18:04:37 -0400 Subject: [PATCH] chore: make golines Signed-off-by: Chris Gianelloni --- ledger/allegra/pparams.go | 4 +- ledger/allegra/pparams_test.go | 6 +- ledger/alonzo/pparams.go | 7 +- ledger/alonzo/pparams_test.go | 28 +- ledger/babbage/pparams.go | 4 +- ledger/babbage/pparams_test.go | 353 ++++++++++++++++++++++++- ledger/common/pparams.go | 4 +- ledger/conway/genesis_test.go | 16 +- ledger/conway/pparams.go | 109 ++++++-- ledger/conway/pparams_test.go | 466 ++++++++++++++++++++++++++++++--- ledger/mary/pparams.go | 4 +- ledger/mary/pparams_test.go | 10 +- ledger/shelley/pparams.go | 8 +- ledger/shelley/pparams_test.go | 16 +- 14 files changed, 944 insertions(+), 91 deletions(-) diff --git a/ledger/allegra/pparams.go b/ledger/allegra/pparams.go index bcfc9060..fb310e88 100644 --- a/ledger/allegra/pparams.go +++ b/ledger/allegra/pparams.go @@ -23,7 +23,9 @@ type AllegraProtocolParameters struct { shelley.ShelleyProtocolParameters } -func (p *AllegraProtocolParameters) Update(paramUpdate *AllegraProtocolParameterUpdate) { +func (p *AllegraProtocolParameters) Update( + paramUpdate *AllegraProtocolParameterUpdate, +) { p.ShelleyProtocolParameters.Update( ¶mUpdate.ShelleyProtocolParameterUpdate, ) diff --git a/ledger/allegra/pparams_test.go b/ledger/allegra/pparams_test.go index a73f008e..d1e196d4 100644 --- a/ledger/allegra/pparams_test.go +++ b/ledger/allegra/pparams_test.go @@ -70,7 +70,11 @@ func TestAllegraProtocolParamsUpdate(t *testing.T) { tmpParams := testDef.startParams tmpParams.Update(&tmpUpdate) if !reflect.DeepEqual(tmpParams, testDef.expectedParams) { - t.Fatalf("did not get expected params:\n got: %#v\n wanted: %#v", tmpParams, testDef.expectedParams) + t.Fatalf( + "did not get expected params:\n got: %#v\n wanted: %#v", + tmpParams, + testDef.expectedParams, + ) } } } diff --git a/ledger/alonzo/pparams.go b/ledger/alonzo/pparams.go index ebf07726..14074431 100644 --- a/ledger/alonzo/pparams.go +++ b/ledger/alonzo/pparams.go @@ -34,7 +34,9 @@ type AlonzoProtocolParameters struct { MaxCollateralInputs uint } -func (p *AlonzoProtocolParameters) Update(paramUpdate *AlonzoProtocolParameterUpdate) { +func (p *AlonzoProtocolParameters) Update( + paramUpdate *AlonzoProtocolParameterUpdate, +) { p.MaryProtocolParameters.Update( ¶mUpdate.MaryProtocolParameterUpdate, ) @@ -81,7 +83,8 @@ func (p *AlonzoProtocolParameters) UpdateFromGenesis(genesis *AlonzoGenesis) { Mem: genesis.MaxBlockExUnits.Mem, Steps: genesis.MaxBlockExUnits.Steps, } - if genesis.ExecutionPrices.Mem != nil && genesis.ExecutionPrices.Steps != nil { + if genesis.ExecutionPrices.Mem != nil && + genesis.ExecutionPrices.Steps != nil { p.ExecutionCosts = common.ExUnitPrice{ MemPrice: &cbor.Rat{Rat: genesis.ExecutionPrices.Mem.Rat}, StepPrice: &cbor.Rat{Rat: genesis.ExecutionPrices.Steps.Rat}, diff --git a/ledger/alonzo/pparams_test.go b/ledger/alonzo/pparams_test.go index 768ac240..ce2eeec3 100644 --- a/ledger/alonzo/pparams_test.go +++ b/ledger/alonzo/pparams_test.go @@ -40,7 +40,9 @@ func TestAlonzoProtocolParamsUpdate(t *testing.T) { MaryProtocolParameters: mary.MaryProtocolParameters{ AllegraProtocolParameters: allegra.AllegraProtocolParameters{ ShelleyProtocolParameters: shelley.ShelleyProtocolParameters{ - Decentralization: &cbor.Rat{Rat: new(big.Rat).SetInt64(1)}, + Decentralization: &cbor.Rat{ + Rat: new(big.Rat).SetInt64(1), + }, }, }, }, @@ -119,7 +121,11 @@ func TestAlonzoProtocolParamsUpdate(t *testing.T) { tmpParams := testDef.startParams tmpParams.Update(&tmpUpdate) if !reflect.DeepEqual(tmpParams, testDef.expectedParams) { - t.Fatalf("did not get expected params:\n got: %#v\n wanted: %#v", tmpParams, testDef.expectedParams) + t.Fatalf( + "did not get expected params:\n got: %#v\n wanted: %#v", + tmpParams, + testDef.expectedParams, + ) } } } @@ -135,7 +141,9 @@ func TestAlonzoProtocolParamsUpdateFromGenesis(t *testing.T) { MaryProtocolParameters: mary.MaryProtocolParameters{ AllegraProtocolParameters: allegra.AllegraProtocolParameters{ ShelleyProtocolParameters: shelley.ShelleyProtocolParameters{ - Decentralization: &cbor.Rat{Rat: new(big.Rat).SetInt64(1)}, + Decentralization: &cbor.Rat{ + Rat: new(big.Rat).SetInt64(1), + }, }, }, }, @@ -145,7 +153,9 @@ func TestAlonzoProtocolParamsUpdateFromGenesis(t *testing.T) { MaryProtocolParameters: mary.MaryProtocolParameters{ AllegraProtocolParameters: allegra.AllegraProtocolParameters{ ShelleyProtocolParameters: shelley.ShelleyProtocolParameters{ - Decentralization: &cbor.Rat{Rat: new(big.Rat).SetInt64(1)}, + Decentralization: &cbor.Rat{ + Rat: new(big.Rat).SetInt64(1), + }, }, }, }, @@ -154,14 +164,20 @@ func TestAlonzoProtocolParamsUpdateFromGenesis(t *testing.T) { }, } for _, testDef := range testDefs { - tmpGenesis, err := alonzo.NewAlonzoGenesisFromReader(strings.NewReader(testDef.genesisJson)) + tmpGenesis, err := alonzo.NewAlonzoGenesisFromReader( + strings.NewReader(testDef.genesisJson), + ) if err != nil { t.Fatalf("unexpected error: %s", err) } tmpParams := testDef.startParams tmpParams.UpdateFromGenesis(&tmpGenesis) if !reflect.DeepEqual(tmpParams, testDef.expectedParams) { - t.Fatalf("did not get expected params:\n got: %#v\n wanted: %#v", tmpParams, testDef.expectedParams) + t.Fatalf( + "did not get expected params:\n got: %#v\n wanted: %#v", + tmpParams, + testDef.expectedParams, + ) } } } diff --git a/ledger/babbage/pparams.go b/ledger/babbage/pparams.go index e30640d5..4913d25d 100644 --- a/ledger/babbage/pparams.go +++ b/ledger/babbage/pparams.go @@ -48,7 +48,9 @@ type BabbageProtocolParameters struct { MaxCollateralInputs uint } -func (p *BabbageProtocolParameters) Update(paramUpdate *BabbageProtocolParameterUpdate) { +func (p *BabbageProtocolParameters) Update( + paramUpdate *BabbageProtocolParameterUpdate, +) { if paramUpdate.MinFeeA != nil { p.MinFeeA = *paramUpdate.MinFeeA } diff --git a/ledger/babbage/pparams_test.go b/ledger/babbage/pparams_test.go index 750f873f..d9dc30d1 100644 --- a/ledger/babbage/pparams_test.go +++ b/ledger/babbage/pparams_test.go @@ -61,8 +61,351 @@ func TestBabbageProtocolParamsUpdate(t *testing.T) { updateCbor: "a112a20098a61a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0a0198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c800", expectedParams: babbage.BabbageProtocolParameters{ CostModels: map[uint][]int64{ - 0: []int64{0x32361, 0x32c, 0x1, 0x1, 0x3e8, 0x23b, 0x0, 0x1, 0x3e8, 0x5e71, 0x4, 0x1, 0x3e8, 0x20, 0x1ca76, 0x28eb, 0x4, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x64, 0x64, 0x59d8, 0x64, 0x4c51, 0x20, 0x2acfa, 0x20, 0xb551, 0x4, 0x36315, 0x1ff, 0x0, 0x1, 0x15c35, 0x20, 0x79775, 0x36f4, 0x4, 0x2, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x3e8, 0x6ff6, 0x4, 0x2, 0x3bd08, 0x34ec5, 0x3e, 0x1, 0x102e0f, 0x312a, 0x1, 0x32e80, 0x1a5, 0x1, 0x2da78, 0x3e8, 0xcf06, 0x1, 0x13a34, 0x20, 0xa8f1, 0x20, 0x3e8, 0x20, 0x13aac, 0x1, 0xe143, 0x4, 0x3e8, 0xa, 0x30219, 0x9c, 0x1, 0x30219, 0x9c, 0x1, 0x3207c, 0x1d9, 0x1, 0x33000, 0x1ff, 0x1, 0xccf3, 0x20, 0xfd40, 0x20, 0xffd5, 0x20, 0x581e, 0x20, 0x40b3, 0x20, 0x12adf, 0x20, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x10f92, 0x2da7, 0x0, 0x1, 0xeabb, 0x20, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0xc504e, 0x7712, 0x4, 0x1d6af6, 0x1425b, 0x4, 0x40c66, 0x0, 0x4, 0x0, 0x14fab, 0x20, 0x32361, 0x32c, 0x1, 0x1, 0xa0de, 0x20, 0x33d76, 0x20, 0x79f4, 0x20, 0x7fb8, 0x20, 0xa95d, 0x20, 0x7df7, 0x20, 0x95aa, 0x20, 0x9063b9, 0x3fd, 0xa}, - 1: []int64{0x32361, 0x32c, 0x1, 0x1, 0x3e8, 0x23b, 0x0, 0x1, 0x3e8, 0x5e71, 0x4, 0x1, 0x3e8, 0x20, 0x1ca76, 0x28eb, 0x4, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x64, 0x64, 0x59d8, 0x64, 0x4c51, 0x20, 0x2acfa, 0x20, 0xb551, 0x4, 0x36315, 0x1ff, 0x0, 0x1, 0x15c35, 0x20, 0x79775, 0x36f4, 0x4, 0x2, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x3e8, 0x6ff6, 0x4, 0x2, 0x3bd08, 0x34ec5, 0x3e, 0x1, 0x102e0f, 0x312a, 0x1, 0x32e80, 0x1a5, 0x1, 0x2da78, 0x3e8, 0xcf06, 0x1, 0x13a34, 0x20, 0xa8f1, 0x20, 0x3e8, 0x20, 0x13aac, 0x1, 0xe143, 0x4, 0x3e8, 0xa, 0x30219, 0x9c, 0x1, 0x30219, 0x9c, 0x1, 0x3207c, 0x1d9, 0x1, 0x33000, 0x1ff, 0x1, 0xccf3, 0x20, 0xfd40, 0x20, 0xffd5, 0x20, 0x581e, 0x20, 0x40b3, 0x20, 0x12adf, 0x20, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x10f92, 0x2da7, 0x0, 0x1, 0xeabb, 0x20, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x11b22c, 0x5fdde, 0x0, 0x2, 0xc504e, 0x7712, 0x4, 0x1d6af6, 0x1425b, 0x4, 0x40c66, 0x0, 0x4, 0x0, 0x14fab, 0x20, 0x32361, 0x32c, 0x1, 0x1, 0xa0de, 0x20, 0x33d76, 0x20, 0x79f4, 0x20, 0x7fb8, 0x20, 0xa95d, 0x20, 0x7df7, 0x20, 0x95aa, 0x20, 0x4a817c800, 0x4a817c800, 0x9063b9, 0x3fd, 0xa, 0x4a817c800, 0x0, 0x4a817c800}, + 0: { + 0x32361, + 0x32c, + 0x1, + 0x1, + 0x3e8, + 0x23b, + 0x0, + 0x1, + 0x3e8, + 0x5e71, + 0x4, + 0x1, + 0x3e8, + 0x20, + 0x1ca76, + 0x28eb, + 0x4, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x64, + 0x64, + 0x59d8, + 0x64, + 0x4c51, + 0x20, + 0x2acfa, + 0x20, + 0xb551, + 0x4, + 0x36315, + 0x1ff, + 0x0, + 0x1, + 0x15c35, + 0x20, + 0x79775, + 0x36f4, + 0x4, + 0x2, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x3e8, + 0x6ff6, + 0x4, + 0x2, + 0x3bd08, + 0x34ec5, + 0x3e, + 0x1, + 0x102e0f, + 0x312a, + 0x1, + 0x32e80, + 0x1a5, + 0x1, + 0x2da78, + 0x3e8, + 0xcf06, + 0x1, + 0x13a34, + 0x20, + 0xa8f1, + 0x20, + 0x3e8, + 0x20, + 0x13aac, + 0x1, + 0xe143, + 0x4, + 0x3e8, + 0xa, + 0x30219, + 0x9c, + 0x1, + 0x30219, + 0x9c, + 0x1, + 0x3207c, + 0x1d9, + 0x1, + 0x33000, + 0x1ff, + 0x1, + 0xccf3, + 0x20, + 0xfd40, + 0x20, + 0xffd5, + 0x20, + 0x581e, + 0x20, + 0x40b3, + 0x20, + 0x12adf, + 0x20, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x10f92, + 0x2da7, + 0x0, + 0x1, + 0xeabb, + 0x20, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0xc504e, + 0x7712, + 0x4, + 0x1d6af6, + 0x1425b, + 0x4, + 0x40c66, + 0x0, + 0x4, + 0x0, + 0x14fab, + 0x20, + 0x32361, + 0x32c, + 0x1, + 0x1, + 0xa0de, + 0x20, + 0x33d76, + 0x20, + 0x79f4, + 0x20, + 0x7fb8, + 0x20, + 0xa95d, + 0x20, + 0x7df7, + 0x20, + 0x95aa, + 0x20, + 0x9063b9, + 0x3fd, + 0xa, + }, + 1: { + 0x32361, + 0x32c, + 0x1, + 0x1, + 0x3e8, + 0x23b, + 0x0, + 0x1, + 0x3e8, + 0x5e71, + 0x4, + 0x1, + 0x3e8, + 0x20, + 0x1ca76, + 0x28eb, + 0x4, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x64, + 0x64, + 0x59d8, + 0x64, + 0x4c51, + 0x20, + 0x2acfa, + 0x20, + 0xb551, + 0x4, + 0x36315, + 0x1ff, + 0x0, + 0x1, + 0x15c35, + 0x20, + 0x79775, + 0x36f4, + 0x4, + 0x2, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x3e8, + 0x6ff6, + 0x4, + 0x2, + 0x3bd08, + 0x34ec5, + 0x3e, + 0x1, + 0x102e0f, + 0x312a, + 0x1, + 0x32e80, + 0x1a5, + 0x1, + 0x2da78, + 0x3e8, + 0xcf06, + 0x1, + 0x13a34, + 0x20, + 0xa8f1, + 0x20, + 0x3e8, + 0x20, + 0x13aac, + 0x1, + 0xe143, + 0x4, + 0x3e8, + 0xa, + 0x30219, + 0x9c, + 0x1, + 0x30219, + 0x9c, + 0x1, + 0x3207c, + 0x1d9, + 0x1, + 0x33000, + 0x1ff, + 0x1, + 0xccf3, + 0x20, + 0xfd40, + 0x20, + 0xffd5, + 0x20, + 0x581e, + 0x20, + 0x40b3, + 0x20, + 0x12adf, + 0x20, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x10f92, + 0x2da7, + 0x0, + 0x1, + 0xeabb, + 0x20, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x11b22c, + 0x5fdde, + 0x0, + 0x2, + 0xc504e, + 0x7712, + 0x4, + 0x1d6af6, + 0x1425b, + 0x4, + 0x40c66, + 0x0, + 0x4, + 0x0, + 0x14fab, + 0x20, + 0x32361, + 0x32c, + 0x1, + 0x1, + 0xa0de, + 0x20, + 0x33d76, + 0x20, + 0x79f4, + 0x20, + 0x7fb8, + 0x20, + 0xa95d, + 0x20, + 0x7df7, + 0x20, + 0x95aa, + 0x20, + 0x4a817c800, + 0x4a817c800, + 0x9063b9, + 0x3fd, + 0xa, + 0x4a817c800, + 0x0, + 0x4a817c800, + }, }, }, }, @@ -79,7 +422,11 @@ func TestBabbageProtocolParamsUpdate(t *testing.T) { tmpParams := testDef.startParams tmpParams.Update(&tmpUpdate) if !reflect.DeepEqual(tmpParams, testDef.expectedParams) { - t.Fatalf("did not get expected params:\n got: %#v\n wanted: %#v", tmpParams, testDef.expectedParams) + t.Fatalf( + "did not get expected params:\n got: %#v\n wanted: %#v", + tmpParams, + testDef.expectedParams, + ) } } } diff --git a/ledger/common/pparams.go b/ledger/common/pparams.go index 57fe3a65..1a979921 100644 --- a/ledger/common/pparams.go +++ b/ledger/common/pparams.go @@ -88,7 +88,9 @@ type ExUnitPrice struct { // ConvertToUtxorpcCardanoCostModels converts a map of cost models for Plutus scripts into cardano.CostModels // Only PlutusV(keys 1, 2, and 3) are supported. -func ConvertToUtxorpcCardanoCostModels(models map[uint][]int64) *cardano.CostModels { +func ConvertToUtxorpcCardanoCostModels( + models map[uint][]int64, +) *cardano.CostModels { costModels := &cardano.CostModels{} for k, v := range models { costModel := &cardano.CostModel{Values: v} diff --git a/ledger/conway/genesis_test.go b/ledger/conway/genesis_test.go index 9f1877e3..79021509 100644 --- a/ledger/conway/genesis_test.go +++ b/ledger/conway/genesis_test.go @@ -350,13 +350,15 @@ var expectedGenesisObj = conway.ConwayGenesis{ TreasuryWithdrawal: &common.GenesisRat{Rat: big.NewRat(67, 100)}, UpdateToConstitution: &common.GenesisRat{Rat: big.NewRat(75, 100)}, }, - MinCommitteeSize: 7, - CommitteeTermLimit: 146, - GovActionValidityPeriod: 6, - GovActionDeposit: 100000000000, - DRepDeposit: 500000000, - DRepInactivityPeriod: 20, - MinFeeRefScriptCostPerByte: &common.GenesisRat{Rat: new(big.Rat).SetUint64(15)}, + MinCommitteeSize: 7, + CommitteeTermLimit: 146, + GovActionValidityPeriod: 6, + GovActionDeposit: 100000000000, + DRepDeposit: 500000000, + DRepInactivityPeriod: 20, + MinFeeRefScriptCostPerByte: &common.GenesisRat{ + Rat: new(big.Rat).SetUint64(15), + }, PlutusV3CostModel: []int64{ 100788, 420, 1, 1, 1000, 173, 0, 1, 1000, 59957, 4, 1, 11183, 32, 201305, 8356, 4, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 100, 100, 16000, 100, 94375, 32, 132994, 32, 61462, 4, 72010, 178, 0, 1, 22151, 32, 91189, 769, 4, 2, 85848, 123203, 7305, -900, 1716, 549, 57, 85848, 0, 1, 1, 1000, 42921, 4, 2, 24548, 29498, 38, 1, 898148, 27279, 1, 51775, 558, 1, 39184, 1000, 60594, 1, 141895, 32, 83150, 32, 15299, 32, 76049, 1, 13169, 4, 22100, 10, 28999, 74, 1, 28999, 74, 1, 43285, 552, 1, 44749, 541, 1, 33852, 32, 68246, 32, 72362, 32, 7243, 32, 7391, 32, 11546, 32, 85848, 123203, 7305, -900, 1716, 549, 57, 85848, 0, 1, 90434, 519, 0, 1, 74433, 32, 85848, 123203, 7305, -900, 1716, 549, 57, 85848, 0, 1, 1, 85848, 123203, 7305, -900, 1716, 549, 57, 85848, 0, 1, 955506, 213312, 0, 2, 270652, 22588, 4, 1457325, 64566, 4, 20467, 1, 4, 0, 141992, 32, 100788, 420, 1, 1, 81663, 32, 59498, 32, 20142, 32, 24588, 32, 20744, 32, 25933, 32, 24623, 32, 43053543, 10, 53384111, 14333, 10, 43574283, 26308, 10, 16000, 100, 16000, 100, 962335, 18, 2780678, 6, 442008, 1, 52538055, 3756, 18, 267929, 18, 76433006, 8868, 18, 52948122, 18, 1995836, 36, 3227919, 12, 901022, 1, 166917843, 4307, 36, 284546, 36, 158221314, 26549, 36, 74698472, 36, 333849714, 1, 254006273, 72, 2174038, 72, 2261318, 64571, 4, 207616, 8310, 4, 1293828, 28716, 63, 0, 1, 1006041, 43623, 251, 0, 1, }, diff --git a/ledger/conway/pparams.go b/ledger/conway/pparams.go index 29eb603f..74338c5c 100644 --- a/ledger/conway/pparams.go +++ b/ledger/conway/pparams.go @@ -68,10 +68,19 @@ func (p *ConwayProtocolParameters) Utxorpc() *cardano.PParams { PoolDeposit: uint64(p.PoolDeposit), PoolRetirementEpochBound: uint64(p.MaxEpoch), DesiredNumberOfPools: uint64(p.NOpt), - PoolInfluence: &cardano.RationalNumber{Numerator: int32(p.A0.Num().Int64()), Denominator: uint32(p.A0.Denom().Int64())}, - MonetaryExpansion: &cardano.RationalNumber{Numerator: int32(p.Rho.Num().Int64()), Denominator: uint32(p.Rho.Denom().Int64())}, - TreasuryExpansion: &cardano.RationalNumber{Numerator: int32(p.Tau.Num().Int64()), Denominator: uint32(p.Tau.Denom().Int64())}, - MinPoolCost: p.MinPoolCost, + PoolInfluence: &cardano.RationalNumber{ + Numerator: int32(p.A0.Num().Int64()), + Denominator: uint32(p.A0.Denom().Int64()), + }, + MonetaryExpansion: &cardano.RationalNumber{ + Numerator: int32(p.Rho.Num().Int64()), + Denominator: uint32(p.Rho.Denom().Int64()), + }, + TreasuryExpansion: &cardano.RationalNumber{ + Numerator: int32(p.Tau.Num().Int64()), + Denominator: uint32(p.Tau.Denom().Int64()), + }, + MinPoolCost: p.MinPoolCost, ProtocolVersion: &cardano.ProtocolVersion{ Major: uint32(p.ProtocolVersion.Major), Minor: uint32(p.ProtocolVersion.Minor), @@ -79,17 +88,33 @@ func (p *ConwayProtocolParameters) Utxorpc() *cardano.PParams { MaxValueSize: uint64(p.MaxValueSize), CollateralPercentage: uint64(p.CollateralPercentage), MaxCollateralInputs: uint64(p.MaxCollateralInputs), - CostModels: common.ConvertToUtxorpcCardanoCostModels(p.CostModels), + CostModels: common.ConvertToUtxorpcCardanoCostModels( + p.CostModels, + ), Prices: &cardano.ExPrices{ - Memory: &cardano.RationalNumber{Numerator: int32(p.ExecutionCosts.MemPrice.Num().Int64()), Denominator: uint32(p.ExecutionCosts.MemPrice.Denom().Int64())}, - Steps: &cardano.RationalNumber{Numerator: int32(p.ExecutionCosts.StepPrice.Num().Int64()), Denominator: uint32(p.ExecutionCosts.StepPrice.Denom().Int64())}, + Memory: &cardano.RationalNumber{ + Numerator: int32(p.ExecutionCosts.MemPrice.Num().Int64()), + Denominator: uint32(p.ExecutionCosts.MemPrice.Denom().Int64()), + }, + Steps: &cardano.RationalNumber{ + Numerator: int32(p.ExecutionCosts.StepPrice.Num().Int64()), + Denominator: uint32(p.ExecutionCosts.StepPrice.Denom().Int64()), + }, + }, + MaxExecutionUnitsPerTransaction: &cardano.ExUnits{ + Memory: uint64(p.MaxTxExUnits.Mem), + Steps: uint64(p.MaxTxExUnits.Steps), + }, + MaxExecutionUnitsPerBlock: &cardano.ExUnits{ + Memory: uint64(p.MaxBlockExUnits.Mem), + Steps: uint64(p.MaxBlockExUnits.Steps), }, - MaxExecutionUnitsPerTransaction: &cardano.ExUnits{Memory: uint64(p.MaxTxExUnits.Mem), Steps: uint64(p.MaxTxExUnits.Steps)}, - MaxExecutionUnitsPerBlock: &cardano.ExUnits{Memory: uint64(p.MaxBlockExUnits.Mem), Steps: uint64(p.MaxBlockExUnits.Steps)}, } } -func (p *ConwayProtocolParameters) Update(paramUpdate *ConwayProtocolParameterUpdate) { +func (p *ConwayProtocolParameters) Update( + paramUpdate *ConwayProtocolParameterUpdate, +) { if paramUpdate.MinFeeA != nil { p.MinFeeA = *paramUpdate.MinFeeA } @@ -193,55 +218,87 @@ func (p *ConwayProtocolParameters) UpdateFromGenesis(genesis *ConwayGenesis) { p.DRepDeposit = genesis.DRepDeposit p.DRepInactivityPeriod = genesis.DRepInactivityPeriod if genesis.MinFeeRefScriptCostPerByte != nil { - p.MinFeeRefScriptCostPerByte = &cbor.Rat{Rat: genesis.MinFeeRefScriptCostPerByte.Rat} + p.MinFeeRefScriptCostPerByte = &cbor.Rat{ + Rat: genesis.MinFeeRefScriptCostPerByte.Rat, + } } if len(genesis.PlutusV3CostModel) > 0 { p.CostModels[2] = genesis.PlutusV3CostModel } if genesis.PoolVotingThresholds.MotionNoConfidence != nil { - p.PoolVotingThresholds.MotionNoConfidence = cbor.Rat{Rat: genesis.PoolVotingThresholds.MotionNoConfidence.Rat} + p.PoolVotingThresholds.MotionNoConfidence = cbor.Rat{ + Rat: genesis.PoolVotingThresholds.MotionNoConfidence.Rat, + } } if genesis.PoolVotingThresholds.CommitteeNormal != nil { - p.PoolVotingThresholds.CommitteeNormal = cbor.Rat{Rat: genesis.PoolVotingThresholds.CommitteeNormal.Rat} + p.PoolVotingThresholds.CommitteeNormal = cbor.Rat{ + Rat: genesis.PoolVotingThresholds.CommitteeNormal.Rat, + } } if genesis.PoolVotingThresholds.CommitteeNoConfidence != nil { - p.PoolVotingThresholds.CommitteeNoConfidence = cbor.Rat{Rat: genesis.PoolVotingThresholds.CommitteeNoConfidence.Rat} + p.PoolVotingThresholds.CommitteeNoConfidence = cbor.Rat{ + Rat: genesis.PoolVotingThresholds.CommitteeNoConfidence.Rat, + } } if genesis.PoolVotingThresholds.HardForkInitiation != nil { - p.PoolVotingThresholds.HardForkInitiation = cbor.Rat{Rat: genesis.PoolVotingThresholds.HardForkInitiation.Rat} + p.PoolVotingThresholds.HardForkInitiation = cbor.Rat{ + Rat: genesis.PoolVotingThresholds.HardForkInitiation.Rat, + } } if genesis.PoolVotingThresholds.PpSecurityGroup != nil { - p.PoolVotingThresholds.PpSecurityGroup = cbor.Rat{Rat: genesis.PoolVotingThresholds.PpSecurityGroup.Rat} + p.PoolVotingThresholds.PpSecurityGroup = cbor.Rat{ + Rat: genesis.PoolVotingThresholds.PpSecurityGroup.Rat, + } } if genesis.DRepVotingThresholds.MotionNoConfidence != nil { - p.DRepVotingThresholds.MotionNoConfidence = cbor.Rat{Rat: genesis.DRepVotingThresholds.MotionNoConfidence.Rat} + p.DRepVotingThresholds.MotionNoConfidence = cbor.Rat{ + Rat: genesis.DRepVotingThresholds.MotionNoConfidence.Rat, + } } if genesis.DRepVotingThresholds.CommitteeNormal != nil { - p.DRepVotingThresholds.CommitteeNormal = cbor.Rat{Rat: genesis.DRepVotingThresholds.CommitteeNormal.Rat} + p.DRepVotingThresholds.CommitteeNormal = cbor.Rat{ + Rat: genesis.DRepVotingThresholds.CommitteeNormal.Rat, + } } if genesis.DRepVotingThresholds.CommitteeNoConfidence != nil { - p.DRepVotingThresholds.CommitteeNoConfidence = cbor.Rat{Rat: genesis.DRepVotingThresholds.CommitteeNoConfidence.Rat} + p.DRepVotingThresholds.CommitteeNoConfidence = cbor.Rat{ + Rat: genesis.DRepVotingThresholds.CommitteeNoConfidence.Rat, + } } if genesis.DRepVotingThresholds.UpdateToConstitution != nil { - p.DRepVotingThresholds.UpdateToConstitution = cbor.Rat{Rat: genesis.DRepVotingThresholds.UpdateToConstitution.Rat} + p.DRepVotingThresholds.UpdateToConstitution = cbor.Rat{ + Rat: genesis.DRepVotingThresholds.UpdateToConstitution.Rat, + } } if genesis.DRepVotingThresholds.HardForkInitiation != nil { - p.DRepVotingThresholds.HardForkInitiation = cbor.Rat{Rat: genesis.DRepVotingThresholds.HardForkInitiation.Rat} + p.DRepVotingThresholds.HardForkInitiation = cbor.Rat{ + Rat: genesis.DRepVotingThresholds.HardForkInitiation.Rat, + } } if genesis.DRepVotingThresholds.PpNetworkGroup != nil { - p.DRepVotingThresholds.PpNetworkGroup = cbor.Rat{Rat: genesis.DRepVotingThresholds.PpNetworkGroup.Rat} + p.DRepVotingThresholds.PpNetworkGroup = cbor.Rat{ + Rat: genesis.DRepVotingThresholds.PpNetworkGroup.Rat, + } } if genesis.DRepVotingThresholds.PpEconomicGroup != nil { - p.DRepVotingThresholds.PpEconomicGroup = cbor.Rat{Rat: genesis.DRepVotingThresholds.PpEconomicGroup.Rat} + p.DRepVotingThresholds.PpEconomicGroup = cbor.Rat{ + Rat: genesis.DRepVotingThresholds.PpEconomicGroup.Rat, + } } if genesis.DRepVotingThresholds.PpTechnicalGroup != nil { - p.DRepVotingThresholds.PpTechnicalGroup = cbor.Rat{Rat: genesis.DRepVotingThresholds.PpTechnicalGroup.Rat} + p.DRepVotingThresholds.PpTechnicalGroup = cbor.Rat{ + Rat: genesis.DRepVotingThresholds.PpTechnicalGroup.Rat, + } } if genesis.DRepVotingThresholds.PpGovGroup != nil { - p.DRepVotingThresholds.PpGovGroup = cbor.Rat{Rat: genesis.DRepVotingThresholds.PpGovGroup.Rat} + p.DRepVotingThresholds.PpGovGroup = cbor.Rat{ + Rat: genesis.DRepVotingThresholds.PpGovGroup.Rat, + } } if genesis.DRepVotingThresholds.TreasuryWithdrawal != nil { - p.DRepVotingThresholds.TreasuryWithdrawal = cbor.Rat{Rat: genesis.DRepVotingThresholds.TreasuryWithdrawal.Rat} + p.DRepVotingThresholds.TreasuryWithdrawal = cbor.Rat{ + Rat: genesis.DRepVotingThresholds.TreasuryWithdrawal.Rat, + } } } diff --git a/ledger/conway/pparams_test.go b/ledger/conway/pparams_test.go index 022b87b6..127e50a7 100644 --- a/ledger/conway/pparams_test.go +++ b/ledger/conway/pparams_test.go @@ -68,8 +68,351 @@ func TestConwayProtocolParamsUpdate(t *testing.T) { updateCbor: "a112a20098a61a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0a0198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c800", expectedParams: conway.ConwayProtocolParameters{ CostModels: map[uint][]int64{ - 0: []int64{0x32361, 0x32c, 0x1, 0x1, 0x3e8, 0x23b, 0x0, 0x1, 0x3e8, 0x5e71, 0x4, 0x1, 0x3e8, 0x20, 0x1ca76, 0x28eb, 0x4, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x64, 0x64, 0x59d8, 0x64, 0x4c51, 0x20, 0x2acfa, 0x20, 0xb551, 0x4, 0x36315, 0x1ff, 0x0, 0x1, 0x15c35, 0x20, 0x79775, 0x36f4, 0x4, 0x2, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x3e8, 0x6ff6, 0x4, 0x2, 0x3bd08, 0x34ec5, 0x3e, 0x1, 0x102e0f, 0x312a, 0x1, 0x32e80, 0x1a5, 0x1, 0x2da78, 0x3e8, 0xcf06, 0x1, 0x13a34, 0x20, 0xa8f1, 0x20, 0x3e8, 0x20, 0x13aac, 0x1, 0xe143, 0x4, 0x3e8, 0xa, 0x30219, 0x9c, 0x1, 0x30219, 0x9c, 0x1, 0x3207c, 0x1d9, 0x1, 0x33000, 0x1ff, 0x1, 0xccf3, 0x20, 0xfd40, 0x20, 0xffd5, 0x20, 0x581e, 0x20, 0x40b3, 0x20, 0x12adf, 0x20, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x10f92, 0x2da7, 0x0, 0x1, 0xeabb, 0x20, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0xc504e, 0x7712, 0x4, 0x1d6af6, 0x1425b, 0x4, 0x40c66, 0x0, 0x4, 0x0, 0x14fab, 0x20, 0x32361, 0x32c, 0x1, 0x1, 0xa0de, 0x20, 0x33d76, 0x20, 0x79f4, 0x20, 0x7fb8, 0x20, 0xa95d, 0x20, 0x7df7, 0x20, 0x95aa, 0x20, 0x9063b9, 0x3fd, 0xa}, - 1: []int64{0x32361, 0x32c, 0x1, 0x1, 0x3e8, 0x23b, 0x0, 0x1, 0x3e8, 0x5e71, 0x4, 0x1, 0x3e8, 0x20, 0x1ca76, 0x28eb, 0x4, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x59d8, 0x64, 0x64, 0x64, 0x59d8, 0x64, 0x4c51, 0x20, 0x2acfa, 0x20, 0xb551, 0x4, 0x36315, 0x1ff, 0x0, 0x1, 0x15c35, 0x20, 0x79775, 0x36f4, 0x4, 0x2, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x3e8, 0x6ff6, 0x4, 0x2, 0x3bd08, 0x34ec5, 0x3e, 0x1, 0x102e0f, 0x312a, 0x1, 0x32e80, 0x1a5, 0x1, 0x2da78, 0x3e8, 0xcf06, 0x1, 0x13a34, 0x20, 0xa8f1, 0x20, 0x3e8, 0x20, 0x13aac, 0x1, 0xe143, 0x4, 0x3e8, 0xa, 0x30219, 0x9c, 0x1, 0x30219, 0x9c, 0x1, 0x3207c, 0x1d9, 0x1, 0x33000, 0x1ff, 0x1, 0xccf3, 0x20, 0xfd40, 0x20, 0xffd5, 0x20, 0x581e, 0x20, 0x40b3, 0x20, 0x12adf, 0x20, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x10f92, 0x2da7, 0x0, 0x1, 0xeabb, 0x20, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x2ff94, 0x6ea78, 0xdc, 0x0, 0x1, 0x1, 0x11b22c, 0x5fdde, 0x0, 0x2, 0xc504e, 0x7712, 0x4, 0x1d6af6, 0x1425b, 0x4, 0x40c66, 0x0, 0x4, 0x0, 0x14fab, 0x20, 0x32361, 0x32c, 0x1, 0x1, 0xa0de, 0x20, 0x33d76, 0x20, 0x79f4, 0x20, 0x7fb8, 0x20, 0xa95d, 0x20, 0x7df7, 0x20, 0x95aa, 0x20, 0x4a817c800, 0x4a817c800, 0x9063b9, 0x3fd, 0xa, 0x4a817c800, 0x0, 0x4a817c800}, + 0: { + 0x32361, + 0x32c, + 0x1, + 0x1, + 0x3e8, + 0x23b, + 0x0, + 0x1, + 0x3e8, + 0x5e71, + 0x4, + 0x1, + 0x3e8, + 0x20, + 0x1ca76, + 0x28eb, + 0x4, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x64, + 0x64, + 0x59d8, + 0x64, + 0x4c51, + 0x20, + 0x2acfa, + 0x20, + 0xb551, + 0x4, + 0x36315, + 0x1ff, + 0x0, + 0x1, + 0x15c35, + 0x20, + 0x79775, + 0x36f4, + 0x4, + 0x2, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x3e8, + 0x6ff6, + 0x4, + 0x2, + 0x3bd08, + 0x34ec5, + 0x3e, + 0x1, + 0x102e0f, + 0x312a, + 0x1, + 0x32e80, + 0x1a5, + 0x1, + 0x2da78, + 0x3e8, + 0xcf06, + 0x1, + 0x13a34, + 0x20, + 0xa8f1, + 0x20, + 0x3e8, + 0x20, + 0x13aac, + 0x1, + 0xe143, + 0x4, + 0x3e8, + 0xa, + 0x30219, + 0x9c, + 0x1, + 0x30219, + 0x9c, + 0x1, + 0x3207c, + 0x1d9, + 0x1, + 0x33000, + 0x1ff, + 0x1, + 0xccf3, + 0x20, + 0xfd40, + 0x20, + 0xffd5, + 0x20, + 0x581e, + 0x20, + 0x40b3, + 0x20, + 0x12adf, + 0x20, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x10f92, + 0x2da7, + 0x0, + 0x1, + 0xeabb, + 0x20, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0xc504e, + 0x7712, + 0x4, + 0x1d6af6, + 0x1425b, + 0x4, + 0x40c66, + 0x0, + 0x4, + 0x0, + 0x14fab, + 0x20, + 0x32361, + 0x32c, + 0x1, + 0x1, + 0xa0de, + 0x20, + 0x33d76, + 0x20, + 0x79f4, + 0x20, + 0x7fb8, + 0x20, + 0xa95d, + 0x20, + 0x7df7, + 0x20, + 0x95aa, + 0x20, + 0x9063b9, + 0x3fd, + 0xa, + }, + 1: { + 0x32361, + 0x32c, + 0x1, + 0x1, + 0x3e8, + 0x23b, + 0x0, + 0x1, + 0x3e8, + 0x5e71, + 0x4, + 0x1, + 0x3e8, + 0x20, + 0x1ca76, + 0x28eb, + 0x4, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x59d8, + 0x64, + 0x64, + 0x64, + 0x59d8, + 0x64, + 0x4c51, + 0x20, + 0x2acfa, + 0x20, + 0xb551, + 0x4, + 0x36315, + 0x1ff, + 0x0, + 0x1, + 0x15c35, + 0x20, + 0x79775, + 0x36f4, + 0x4, + 0x2, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x3e8, + 0x6ff6, + 0x4, + 0x2, + 0x3bd08, + 0x34ec5, + 0x3e, + 0x1, + 0x102e0f, + 0x312a, + 0x1, + 0x32e80, + 0x1a5, + 0x1, + 0x2da78, + 0x3e8, + 0xcf06, + 0x1, + 0x13a34, + 0x20, + 0xa8f1, + 0x20, + 0x3e8, + 0x20, + 0x13aac, + 0x1, + 0xe143, + 0x4, + 0x3e8, + 0xa, + 0x30219, + 0x9c, + 0x1, + 0x30219, + 0x9c, + 0x1, + 0x3207c, + 0x1d9, + 0x1, + 0x33000, + 0x1ff, + 0x1, + 0xccf3, + 0x20, + 0xfd40, + 0x20, + 0xffd5, + 0x20, + 0x581e, + 0x20, + 0x40b3, + 0x20, + 0x12adf, + 0x20, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x10f92, + 0x2da7, + 0x0, + 0x1, + 0xeabb, + 0x20, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x2ff94, + 0x6ea78, + 0xdc, + 0x0, + 0x1, + 0x1, + 0x11b22c, + 0x5fdde, + 0x0, + 0x2, + 0xc504e, + 0x7712, + 0x4, + 0x1d6af6, + 0x1425b, + 0x4, + 0x40c66, + 0x0, + 0x4, + 0x0, + 0x14fab, + 0x20, + 0x32361, + 0x32c, + 0x1, + 0x1, + 0xa0de, + 0x20, + 0x33d76, + 0x20, + 0x79f4, + 0x20, + 0x7fb8, + 0x20, + 0xa95d, + 0x20, + 0x7df7, + 0x20, + 0x95aa, + 0x20, + 0x4a817c800, + 0x4a817c800, + 0x9063b9, + 0x3fd, + 0xa, + 0x4a817c800, + 0x0, + 0x4a817c800, + }, }, }, }, @@ -86,7 +429,11 @@ func TestConwayProtocolParamsUpdate(t *testing.T) { tmpParams := testDef.startParams tmpParams.Update(&tmpUpdate) if !reflect.DeepEqual(tmpParams, testDef.expectedParams) { - t.Fatalf("did not get expected params:\n got: %#v\n wanted: %#v", tmpParams, testDef.expectedParams) + t.Fatalf( + "did not get expected params:\n got: %#v\n wanted: %#v", + tmpParams, + testDef.expectedParams, + ) } } } @@ -109,14 +456,20 @@ func TestConwayProtocolParamsUpdateFromGenesis(t *testing.T) { }, } for _, testDef := range testDefs { - tmpGenesis, err := conway.NewConwayGenesisFromReader(strings.NewReader(testDef.genesisJson)) + tmpGenesis, err := conway.NewConwayGenesisFromReader( + strings.NewReader(testDef.genesisJson), + ) if err != nil { t.Fatalf("unexpected error: %s", err) } tmpParams := testDef.startParams tmpParams.UpdateFromGenesis(&tmpGenesis) if !reflect.DeepEqual(tmpParams, testDef.expectedParams) { - t.Fatalf("did not get expected params:\n got: %#v\n wanted: %#v", tmpParams, testDef.expectedParams) + t.Fatalf( + "did not get expected params:\n got: %#v\n wanted: %#v", + tmpParams, + testDef.expectedParams, + ) } } } @@ -128,27 +481,39 @@ func TestUtxorpc(t *testing.T) { }{ { startParams: conway.ConwayProtocolParameters{ - AdaPerUtxoByte: 44, - MaxTxSize: 16384, - MinFeeA: 500, - MinFeeB: 2, - MaxBlockBodySize: 65536, - MaxBlockHeaderSize: 1024, - KeyDeposit: 2000, - PoolDeposit: 500000, - MaxEpoch: 2160, - NOpt: 100, - A0: &cbor.Rat{Rat: big.NewRat(1, 2)}, - Rho: &cbor.Rat{Rat: big.NewRat(3, 4)}, - Tau: &cbor.Rat{Rat: big.NewRat(5, 6)}, - MinPoolCost: 340000000, - ProtocolVersion: common.ProtocolParametersProtocolVersion{Major: 8, Minor: 0}, + AdaPerUtxoByte: 44, + MaxTxSize: 16384, + MinFeeA: 500, + MinFeeB: 2, + MaxBlockBodySize: 65536, + MaxBlockHeaderSize: 1024, + KeyDeposit: 2000, + PoolDeposit: 500000, + MaxEpoch: 2160, + NOpt: 100, + A0: &cbor.Rat{Rat: big.NewRat(1, 2)}, + Rho: &cbor.Rat{Rat: big.NewRat(3, 4)}, + Tau: &cbor.Rat{Rat: big.NewRat(5, 6)}, + MinPoolCost: 340000000, + ProtocolVersion: common.ProtocolParametersProtocolVersion{ + Major: 8, + Minor: 0, + }, MaxValueSize: 1024, CollateralPercentage: 150, MaxCollateralInputs: 5, - ExecutionCosts: common.ExUnitPrice{MemPrice: &cbor.Rat{Rat: big.NewRat(1, 2)}, StepPrice: &cbor.Rat{Rat: big.NewRat(2, 3)}}, - MaxTxExUnits: common.ExUnit{Mem: 1000000, Steps: 200000}, - MaxBlockExUnits: common.ExUnit{Mem: 5000000, Steps: 1000000}, + ExecutionCosts: common.ExUnitPrice{ + MemPrice: &cbor.Rat{Rat: big.NewRat(1, 2)}, + StepPrice: &cbor.Rat{Rat: big.NewRat(2, 3)}, + }, + MaxTxExUnits: common.ExUnit{ + Mem: 1000000, + Steps: 200000, + }, + MaxBlockExUnits: common.ExUnit{ + Mem: 5000000, + Steps: 1000000, + }, CostModels: map[uint][]int64{ 1: {100, 200, 300}, 2: {400, 500, 600}, @@ -166,10 +531,19 @@ func TestUtxorpc(t *testing.T) { PoolDeposit: 500000, PoolRetirementEpochBound: 2160, DesiredNumberOfPools: 100, - PoolInfluence: &cardano.RationalNumber{Numerator: int32(1), Denominator: uint32(2)}, - MonetaryExpansion: &cardano.RationalNumber{Numerator: int32(3), Denominator: uint32(4)}, - TreasuryExpansion: &cardano.RationalNumber{Numerator: int32(5), Denominator: uint32(6)}, - MinPoolCost: 340000000, + PoolInfluence: &cardano.RationalNumber{ + Numerator: int32(1), + Denominator: uint32(2), + }, + MonetaryExpansion: &cardano.RationalNumber{ + Numerator: int32(3), + Denominator: uint32(4), + }, + TreasuryExpansion: &cardano.RationalNumber{ + Numerator: int32(5), + Denominator: uint32(6), + }, + MinPoolCost: 340000000, ProtocolVersion: &cardano.ProtocolVersion{ Major: 8, Minor: 0, @@ -178,16 +552,34 @@ func TestUtxorpc(t *testing.T) { CollateralPercentage: 150, MaxCollateralInputs: 5, CostModels: &cardano.CostModels{ - PlutusV1: &cardano.CostModel{Values: []int64{100, 200, 300}}, - PlutusV2: &cardano.CostModel{Values: []int64{400, 500, 600}}, - PlutusV3: &cardano.CostModel{Values: []int64{700, 800, 900}}, + PlutusV1: &cardano.CostModel{ + Values: []int64{100, 200, 300}, + }, + PlutusV2: &cardano.CostModel{ + Values: []int64{400, 500, 600}, + }, + PlutusV3: &cardano.CostModel{ + Values: []int64{700, 800, 900}, + }, }, Prices: &cardano.ExPrices{ - Memory: &cardano.RationalNumber{Numerator: int32(1), Denominator: uint32(2)}, - Steps: &cardano.RationalNumber{Numerator: int32(2), Denominator: uint32(3)}, + Memory: &cardano.RationalNumber{ + Numerator: int32(1), + Denominator: uint32(2), + }, + Steps: &cardano.RationalNumber{ + Numerator: int32(2), + Denominator: uint32(3), + }, + }, + MaxExecutionUnitsPerTransaction: &cardano.ExUnits{ + Memory: 1000000, + Steps: 200000, + }, + MaxExecutionUnitsPerBlock: &cardano.ExUnits{ + Memory: 5000000, + Steps: 1000000, }, - MaxExecutionUnitsPerTransaction: &cardano.ExUnits{Memory: 1000000, Steps: 200000}, - MaxExecutionUnitsPerBlock: &cardano.ExUnits{Memory: 5000000, Steps: 1000000}, }, }, } @@ -196,7 +588,11 @@ func TestUtxorpc(t *testing.T) { result := testDef.startParams.Utxorpc() // Compare the result with the expected value if !reflect.DeepEqual(result, testDef.expectedUtxorpc) { - t.Fatalf("Utxorpc() test failed:\nExpected: %#v\nGot: %#v", testDef.expectedUtxorpc, result) + t.Fatalf( + "Utxorpc() test failed:\nExpected: %#v\nGot: %#v", + testDef.expectedUtxorpc, + result, + ) } } } diff --git a/ledger/mary/pparams.go b/ledger/mary/pparams.go index 12b14e2d..c61f4b37 100644 --- a/ledger/mary/pparams.go +++ b/ledger/mary/pparams.go @@ -20,7 +20,9 @@ type MaryProtocolParameters struct { allegra.AllegraProtocolParameters } -func (p *MaryProtocolParameters) Update(paramUpdate *MaryProtocolParameterUpdate) { +func (p *MaryProtocolParameters) Update( + paramUpdate *MaryProtocolParameterUpdate, +) { p.AllegraProtocolParameters.Update( ¶mUpdate.AllegraProtocolParameterUpdate, ) diff --git a/ledger/mary/pparams_test.go b/ledger/mary/pparams_test.go index 2dacbbaf..76fb1e1a 100644 --- a/ledger/mary/pparams_test.go +++ b/ledger/mary/pparams_test.go @@ -36,7 +36,9 @@ func TestMaryProtocolParamsUpdate(t *testing.T) { startParams: mary.MaryProtocolParameters{ AllegraProtocolParameters: allegra.AllegraProtocolParameters{ ShelleyProtocolParameters: shelley.ShelleyProtocolParameters{ - Decentralization: &cbor.Rat{Rat: new(big.Rat).SetInt64(1)}, + Decentralization: &cbor.Rat{ + Rat: new(big.Rat).SetInt64(1), + }, }, }, }, @@ -79,7 +81,11 @@ func TestMaryProtocolParamsUpdate(t *testing.T) { tmpParams := testDef.startParams tmpParams.Update(&tmpUpdate) if !reflect.DeepEqual(tmpParams, testDef.expectedParams) { - t.Fatalf("did not get expected params:\n got: %#v\n wanted: %#v", tmpParams, testDef.expectedParams) + t.Fatalf( + "did not get expected params:\n got: %#v\n wanted: %#v", + tmpParams, + testDef.expectedParams, + ) } } } diff --git a/ledger/shelley/pparams.go b/ledger/shelley/pparams.go index 718b38bf..7da9fd15 100644 --- a/ledger/shelley/pparams.go +++ b/ledger/shelley/pparams.go @@ -42,7 +42,9 @@ type ShelleyProtocolParameters struct { MinUtxoValue uint } -func (p *ShelleyProtocolParameters) Update(paramUpdate *ShelleyProtocolParameterUpdate) { +func (p *ShelleyProtocolParameters) Update( + paramUpdate *ShelleyProtocolParameterUpdate, +) { if paramUpdate.MinFeeA != nil { p.MinFeeA = *paramUpdate.MinFeeA } @@ -115,7 +117,9 @@ func (p *ShelleyProtocolParameters) UpdateFromGenesis(genesis *ShelleyGenesis) { p.Tau = &cbor.Rat{Rat: new(big.Rat).Set(genesisParams.Tau.Rat)} } if genesisParams.Decentralization != nil { - p.Decentralization = &cbor.Rat{Rat: new(big.Rat).Set(genesisParams.Decentralization.Rat)} + p.Decentralization = &cbor.Rat{ + Rat: new(big.Rat).Set(genesisParams.Decentralization.Rat), + } } p.ProtocolMajor = genesisParams.ProtocolVersion.Major p.ProtocolMinor = genesisParams.ProtocolVersion.Minor diff --git a/ledger/shelley/pparams_test.go b/ledger/shelley/pparams_test.go index 47da504a..e576d610 100644 --- a/ledger/shelley/pparams_test.go +++ b/ledger/shelley/pparams_test.go @@ -62,7 +62,11 @@ func TestShelleyProtocolParamsUpdate(t *testing.T) { tmpParams := testDef.startParams tmpParams.Update(&tmpUpdate) if !reflect.DeepEqual(tmpParams, testDef.expectedParams) { - t.Fatalf("did not get expected params:\n got: %#v\n wanted: %#v", tmpParams, testDef.expectedParams) + t.Fatalf( + "did not get expected params:\n got: %#v\n wanted: %#v", + tmpParams, + testDef.expectedParams, + ) } } } @@ -82,14 +86,20 @@ func TestShelleyProtocolParamsUpdateFromGenesis(t *testing.T) { }, } for _, testDef := range testDefs { - tmpGenesis, err := shelley.NewShelleyGenesisFromReader(strings.NewReader(testDef.genesisJson)) + tmpGenesis, err := shelley.NewShelleyGenesisFromReader( + strings.NewReader(testDef.genesisJson), + ) if err != nil { t.Fatalf("unexpected error: %s", err) } tmpParams := testDef.startParams tmpParams.UpdateFromGenesis(&tmpGenesis) if !reflect.DeepEqual(tmpParams, testDef.expectedParams) { - t.Fatalf("did not get expected params:\n got: %#v\n wanted: %#v", tmpParams, testDef.expectedParams) + t.Fatalf( + "did not get expected params:\n got: %#v\n wanted: %#v", + tmpParams, + testDef.expectedParams, + ) } } }