change BlockMetadata to ChainedBlock, clean up logic accordingly
fix substr in sql server provider