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
10 changes: 9 additions & 1 deletion cmd/gouroboros/chainsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func testChainSync(f *globalFlags) {
os.Exit(1)
}
}()
oConn, err = ouroboros.New(
o, err := ouroboros.New(
ouroboros.WithConnection(conn),
ouroboros.WithNetworkMagic(uint32(f.networkMagic)),
ouroboros.WithErrorChan(errorChan),
Expand All @@ -183,6 +183,11 @@ func testChainSync(f *globalFlags) {
fmt.Printf("ERROR: %s\n", err)
os.Exit(1)
}
if o == nil {
fmt.Println("ERROR: empty connection")
os.Exit(1)
}
oConn = o

var point common.Point
if chainSyncFlags.tip {
Expand Down Expand Up @@ -260,6 +265,9 @@ func chainSyncRollForwardHandler(
blockSlot := v.SlotNumber()
blockHash, _ := hex.DecodeString(v.Hash())
var err error
if oConn == nil {
return fmt.Errorf("empty ouroboros connection, aborting!")
}
block, err = oConn.BlockFetch().Client.GetBlock(common.NewPoint(blockSlot, blockHash))
if err != nil {
return err
Expand Down
6 changes: 5 additions & 1 deletion ledger/allegra/pparams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ func TestAllegraUtxorpc(t *testing.T) {
result := inputParams.Utxorpc()

if !reflect.DeepEqual(result, expectedUtxorpc) {
t.Fatalf("Utxorpc() test failed for Allegra:\nExpected: %#v\nGot: %#v", expectedUtxorpc, result)
t.Fatalf(
"Utxorpc() test failed for Allegra:\nExpected: %#v\nGot: %#v",
expectedUtxorpc,
result,
)
}
}
7 changes: 6 additions & 1 deletion ledger/alonzo/pparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func (p *AlonzoProtocolParameters) Update(
}

func (p *AlonzoProtocolParameters) UpdateFromGenesis(genesis *AlonzoGenesis) {
if genesis == nil {
return
}
// XXX: do we need to convert this?
p.AdaPerUtxoByte = genesis.LovelacePerUtxoWord
p.MaxValueSize = genesis.MaxValueSize
Expand Down Expand Up @@ -144,7 +147,9 @@ func (p *AlonzoProtocolParameters) 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()),
Expand Down
6 changes: 5 additions & 1 deletion ledger/alonzo/pparams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ func TestAlonzoUtxorpc(t *testing.T) {
result := inputParams.Utxorpc()

if !reflect.DeepEqual(result, expectedUtxorpc) {
t.Fatalf("Utxorpc() test failed for Alonzo:\nExpected: %#v\nGot: %#v", expectedUtxorpc, result)
t.Fatalf(
"Utxorpc() test failed for Alonzo:\nExpected: %#v\nGot: %#v",
expectedUtxorpc,
result,
)
}
}
3 changes: 3 additions & 0 deletions ledger/conway/pparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ func (p *ConwayProtocolParameters) Update(
}

func (p *ConwayProtocolParameters) UpdateFromGenesis(genesis *ConwayGenesis) {
if genesis == nil {
return
}
p.MinCommitteeSize = genesis.MinCommitteeSize
p.CommitteeTermLimit = genesis.CommitteeTermLimit
p.GovActionValidityPeriod = genesis.GovActionValidityPeriod
Expand Down
6 changes: 5 additions & 1 deletion ledger/mary/pparams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func TestMaryUtxorpc(t *testing.T) {
result := inputParams.Utxorpc()

if !reflect.DeepEqual(result, expectedUtxorpc) {
t.Fatalf("Utxorpc() test failed for Mary:\nExpected: %#v\nGot: %#v", expectedUtxorpc, result)
t.Fatalf(
"Utxorpc() test failed for Mary:\nExpected: %#v\nGot: %#v",
expectedUtxorpc,
result,
)
}
}
3 changes: 3 additions & 0 deletions ledger/shelley/pparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ func (p *ShelleyProtocolParameters) Update(
}

func (p *ShelleyProtocolParameters) UpdateFromGenesis(genesis *ShelleyGenesis) {
if genesis == nil {
return
}
genesisParams := genesis.ProtocolParameters
p.MinFeeA = genesisParams.MinFeeA
p.MinFeeB = genesisParams.MinFeeB
Expand Down
6 changes: 5 additions & 1 deletion ledger/shelley/pparams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ func TestShelleyUtxorpc(t *testing.T) {
result := inputParams.Utxorpc()

if !reflect.DeepEqual(result, expectedUtxorpc) {
t.Fatalf("Utxorpc() test failed for Shelley:\nExpected: %#v\nGot: %#v", expectedUtxorpc, result)
t.Fatalf(
"Utxorpc() test failed for Shelley:\nExpected: %#v\nGot: %#v",
expectedUtxorpc,
result,
)
}
}
5 changes: 5 additions & 0 deletions ledger/verify_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func VerifyBlock(block BlockHexCbor) (error, bool, string, uint64, uint64) {
headerUnmarshalError.Error(),
), false, "", 0, 0
}
if header == nil {
return fmt.Errorf(
"VerifyBlock: header returned empty",
), false, "", 0, 0
}
isKesValid, errKes := VerifyKes(header, slotPerKesPeriod)
if errKes != nil {
return fmt.Errorf(
Expand Down
31 changes: 31 additions & 0 deletions protocol/handshake/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@ func (s *Server) handleProposeVersions(msg protocol.Message) error {
// Decode protocol parameters for selected version
versionInfo := protocol.GetProtocolVersion(proposedVersion)
versionData := s.config.ProtocolVersionMap[proposedVersion]
if versionData == nil {
msgRefuse := NewMsgRefuse(
[]any{
RefuseReasonDecodeError,
proposedVersion,
fmt.Errorf("handshake failed: refused due to empty version data"),
},
)
if err := s.SendMessage(msgRefuse); err != nil {
return err
}
return fmt.Errorf(
"handshake failed: refused due to empty version data",
)
}
proposedVersionData, err := versionInfo.NewVersionDataFromCborFunc(
msgProposeVersions.VersionMap[proposedVersion],
)
Expand All @@ -148,6 +163,22 @@ func (s *Server) handleProposeVersions(msg protocol.Message) error {
err,
)
}
if proposedVersionData == nil {
msgRefuse := NewMsgRefuse(
[]any{
RefuseReasonDecodeError,
proposedVersion,
fmt.Errorf("handshake failed: refused due to empty version map"),
},
)
if err := s.SendMessage(msgRefuse); err != nil {
return err
}
return fmt.Errorf(
"handshake failed: refused due to empty version map",
)
}

// Check network magic
if proposedVersionData.NetworkMagic() != versionData.NetworkMagic() {
errMsg := fmt.Sprintf(
Expand Down
6 changes: 5 additions & 1 deletion protocol/localstatequery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ func (c *Client) Start() {
func (c *Client) Acquire(point *common.Point) error {
var msg string
if point != nil {
msg = fmt.Sprintf("calling Acquire(point: {Slot: %d, Hash: %x})", point.Slot, point.Hash)
msg = fmt.Sprintf(
"calling Acquire(point: {Slot: %d, Hash: %x})",
point.Slot,
point.Hash,
)
} else {
msg = "calling Acquire(point: latest)"
}
Expand Down