@ -34,9 +34,10 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
final ProtocolContext < C > context ,
final ProtocolContext < C > context ,
final Block block ,
final Block block ,
final List < TransactionReceipt > receipts ,
final List < TransactionReceipt > receipts ,
final Hash worldStateRootHash ) {
final Hash worldStateRootHash ,
final HeaderValidationMode ommerValidationMode ) {
if ( ! validateBodyLight ( context , block , receipts ) ) {
if ( ! validateBodyLight ( context , block , receipts , ommerValidationMode ) ) {
return false ;
return false ;
}
}
@ -51,7 +52,8 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
public boolean validateBodyLight (
public boolean validateBodyLight (
final ProtocolContext < C > context ,
final ProtocolContext < C > context ,
final Block block ,
final Block block ,
final List < TransactionReceipt > receipts ) {
final List < TransactionReceipt > receipts ,
final HeaderValidationMode ommerValidationMode ) {
final BlockHeader header = block . getHeader ( ) ;
final BlockHeader header = block . getHeader ( ) ;
final BlockBody body = block . getBody ( ) ;
final BlockBody body = block . getBody ( ) ;
@ -75,7 +77,7 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
return false ;
return false ;
}
}
if ( ! validateEthHash ( context , block ) ) {
if ( ! validateEthHash ( context , block , ommerValidationMode ) ) {
return false ;
return false ;
}
}
@ -130,7 +132,10 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
return true ;
return true ;
}
}
private boolean validateEthHash ( final ProtocolContext < C > context , final Block block ) {
private boolean validateEthHash (
final ProtocolContext < C > context ,
final Block block ,
final HeaderValidationMode ommerValidationMode ) {
final BlockHeader header = block . getHeader ( ) ;
final BlockHeader header = block . getHeader ( ) ;
final BlockBody body = block . getBody ( ) ;
final BlockBody body = block . getBody ( ) ;
@ -139,7 +144,7 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
return false ;
return false ;
}
}
if ( ! validateOmmers ( context , header , body . getOmmers ( ) ) ) {
if ( ! validateOmmers ( context , header , body . getOmmers ( ) , ommerValidationMode ) ) {
return false ;
return false ;
}
}
@ -156,7 +161,10 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
}
}
private boolean validateOmmers (
private boolean validateOmmers (
final ProtocolContext < C > context , final BlockHeader header , final List < BlockHeader > ommers ) {
final ProtocolContext < C > context ,
final BlockHeader header ,
final List < BlockHeader > ommers ,
final HeaderValidationMode ommerValidationMode ) {
if ( ommers . size ( ) > MAX_OMMERS ) {
if ( ommers . size ( ) > MAX_OMMERS ) {
LOG . warn ( "Invalid block: ommer count {} exceeds ommer limit {}" , ommers . size ( ) , MAX_OMMERS ) ;
LOG . warn ( "Invalid block: ommer count {} exceeds ommer limit {}" , ommers . size ( ) , MAX_OMMERS ) ;
return false ;
return false ;
@ -168,7 +176,7 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
}
}
for ( final BlockHeader ommer : ommers ) {
for ( final BlockHeader ommer : ommers ) {
if ( ! isOmmerValid ( context , header , ommer ) ) {
if ( ! isOmmerValid ( context , header , ommer , ommerValidationMode ) ) {
LOG . warn ( "Invalid block: ommer is invalid" ) ;
LOG . warn ( "Invalid block: ommer is invalid" ) ;
return false ;
return false ;
}
}
@ -193,11 +201,14 @@ public class MainnetBlockBodyValidator<C> implements BlockBodyValidator<C> {
}
}
private boolean isOmmerValid (
private boolean isOmmerValid (
final ProtocolContext < C > context , final BlockHeader current , final BlockHeader ommer ) {
final ProtocolContext < C > context ,
final BlockHeader current ,
final BlockHeader ommer ,
final HeaderValidationMode ommerValidationMode ) {
final ProtocolSpec < C > protocolSpec = protocolSchedule . getByBlockNumber ( ommer . getNumber ( ) ) ;
final ProtocolSpec < C > protocolSpec = protocolSchedule . getByBlockNumber ( ommer . getNumber ( ) ) ;
if ( ! protocolSpec
if ( ! protocolSpec
. getBlockHeaderValidator ( )
. getBlockHeaderValidator ( )
. validateHeader ( ommer , context , HeaderValidationMode . FULL ) ) {
. validateHeader ( ommer , context , ommerValidationMode ) ) {
return false ;
return false ;
}
}